Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consistent testing #118

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/publish-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Needed to publish test results in fork
name: Testing Callback

on:
workflow_run:
workflows: ["PR Testing"]
types:
- completed

jobs:
call-reusable-workflow:
name: Call Reusable Testing Callback Workflow
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-publish-result.yml@v1
24 changes: 24 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PR Testing

on:
pull_request:
types:
- opened
- synchronize

jobs:
handle-syncwith:
name: Call Reusable SyncWith Handler
uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1
with:
ci-cd-ref: 'v1'
secrets: inherit

matrix-test:
name: Call Reusable Crypto3 Testing
needs:
- handle-syncwith
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing.yml@v1
with:
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
secrets: inherit
27 changes: 20 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,43 @@ cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}


macro(define_runtime_algebra_test name)
cm_test(NAME algebra_${name}_test SOURCES ${name}.cpp)
set(test_name "algebra_${name}_test")

target_include_directories(algebra_${name}_test PRIVATE
set(additional_args "")
if(ENABLE_JUNIT_TEST_OUTPUT)
set(TEST_RESULTS_DIR "${CMAKE_CURRENT_BINARY_DIR}/junit_results")
set(TEST_LOGS_DIR "${TEST_RESULTS_DIR}/logs")
file(MAKE_DIRECTORY ${TEST_LOGS_DIR})

set(additional_args "--log_format=JUNIT"
"--log_sink=${TEST_LOGS_DIR}/${test_name}.xml")
endif()

cm_test(NAME ${test_name} SOURCES ${name}.cpp ARGS ${additional_args})

target_include_directories(${test_name} PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"

${Boost_INCLUDE_DIRS})

set_target_properties(algebra_${name}_test PROPERTIES CXX_STANDARD 17
set_target_properties(${test_name} PROPERTIES CXX_STANDARD 17
CXX_STANDARD_REQUIRED TRUE)

get_target_property(target_type Boost::unit_test_framework TYPE)
if(target_type STREQUAL "SHARED_LIB")
target_compile_definitions(algebra_${name}_test PRIVATE BOOST_TEST_DYN_LINK)
target_compile_definitions(${test_name} PRIVATE BOOST_TEST_DYN_LINK)
elseif(target_type STREQUAL "STATIC_LIB")

endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(algebra_${name}_test PRIVATE "-fconstexpr-steps=2147483647")
target_compile_options(${test_name} PRIVATE "-fconstexpr-steps=2147483647")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(algebra_${name}_test PRIVATE "-fconstexpr-ops-limit=4294967295")
target_compile_options(${test_name} PRIVATE "-fconstexpr-ops-limit=4294967295")
endif()

target_compile_definitions(${test_name} PRIVATE TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/")
endmacro()

macro(define_compile_time_algebra_test name)
Expand Down Expand Up @@ -72,7 +86,6 @@ set(RUNTIME_TESTS_NAMES
"fields_static"
"pairing"
"hash_to_curve"
"wnaf"
"multiexp"
)

Expand Down
10 changes: 5 additions & 5 deletions test/curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace boost {
} // namespace boost

// if target == check-algebra just data/curves.json
const char *test_data = "../../../../libs/algebra/test/data/curves.json";
std::string test_data = std::string(TEST_DATA_DIR) + R"(curves.json)";

boost::property_tree::ptree string_data(std::string test_name) {
boost::property_tree::ptree string_data;
Expand Down Expand Up @@ -236,11 +236,11 @@ void check_curve_operations(const std::vector<typename CurveGroup::value_type> &
BOOST_CHECK_EQUAL(result, points[p1_minus_p2]);

result = points[p1];
result *= static_cast<cpp_int>(constants[C1]);
result *= static_cast<cpp_int>(constants[C1]);
BOOST_CHECK_EQUAL(result, points[p1_mul_C1]);

result = points[p2];
result *= static_cast<cpp_int>(constants[C1]);
result *= static_cast<cpp_int>(constants[C1]);
result += points[p2] * static_cast<cpp_int>(constants[C2]);
BOOST_CHECK_EQUAL(result, points[p2_mul_C1_plus_p2_mul_C2]);
}
Expand Down Expand Up @@ -278,11 +278,11 @@ void check_curve_operations_twisted_edwards(
BOOST_CHECK_EQUAL(result, points[p1_minus_p2]);

result = points[p1];
result *= static_cast<cpp_int>(constants[C1]);
result *= static_cast<cpp_int>(constants[C1]);
BOOST_CHECK_EQUAL(result, points[p1_mul_C1]);

result = points[p2];
result *= static_cast<cpp_int>(constants[C1]);
result *= static_cast<cpp_int>(constants[C1]);
result += points[p2] * static_cast<cpp_int>(constants[C2]);
BOOST_CHECK_EQUAL(result, points[p2_mul_C1_plus_p2_mul_C2]);
}
Expand Down
Loading
Loading