Skip to content

Commit

Permalink
make parallel-crypto3 tests compile and run
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyMlashkin committed Nov 29, 2024
1 parent 9604115 commit 0abcc7c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 39 deletions.
5 changes: 4 additions & 1 deletion parallel-crypto3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ in stdenv.mkDerivation {
(if sanitize then "-DSANITIZE=ON" else "-DSANITIZE=OFF")
(if benchmarkTests then "-DENABLE_BENCHMARKS=ON" else "-DENABLE_BENCHMARKS=OFF")
"-DPARALLEL_CRYPTO3_ENABLE=TRUE"
"-G Ninja"
];

cmakeBuildType = if enableDebug then "Debug" else "Release";
Expand All @@ -45,11 +46,13 @@ in stdenv.mkDerivation {
# JUNIT file without explicit file name is generated after the name of the master test suite inside `CMAKE_CURRENT_SOURCE_DIR`
export BOOST_TEST_LOGGER=JUNIT:HRF
cd parallel-crypto3
ctest --verbose --output-on-failure -R
# remove || true after all tests are fixed under clang-sanitizers check:
ctest --verbose --output-on-failure -R > test_errors.txt || true
cd ..
mkdir -p ${placeholder "out"}/test-logs
find .. -type f -name '*_test.xml' -exec cp {} ${placeholder "out"}/test-logs \;
find .. -type f -name '*_benchmark.xml' -exec cp {} ${placeholder "out"}/test-logs \;
cp crypto3/test_errors.txt ${placeholder "out"}/test-logs \
'';

shellHook = ''
Expand Down
3 changes: 3 additions & 0 deletions parallel-crypto3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ add_subdirectory(libs/parallelization-utils)
add_subdirectory(libs/parallel-containers)
add_subdirectory(libs/parallel-math)
add_subdirectory(libs/parallel-zk)
if(ENABLE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()

add_library(${PROJECT_NAME}_all INTERFACE)
add_library(${PROJECT_NAME}::all ALIAS ${PROJECT_NAME}_all)
Expand Down
55 changes: 55 additions & 0 deletions parallel-crypto3/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#---------------------------------------------------------------------------#
# Copyright (c) 2018-2020 Mikhail Komarov <[email protected]>
#
# Distributed under the Boost Software License, Version 1.0
# See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
#---------------------------------------------------------------------------#

include(CMTest)

find_package(Boost REQUIRED COMPONENTS
timer
unit_test_framework
)

macro(define_bench_test name)
set(test_name "parallel_crypto3_${name}_bench")

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(${test_name} PROPERTIES CXX_STANDARD 17)

endmacro()

cm_test_link_libraries(
crypto3::algebra
crypto3::math
crypto3::multiprecision
crypto3::random
${Boost_LIBRARIES}
)

set(TESTS_NAMES
"polynomial_dfs_benchmark"
)

foreach(TEST_NAME ${TESTS_NAMES})
define_bench_test(${TEST_NAME})
endforeach()
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// SOFTWARE.
//---------------------------------------------------------------------------//

#define BOOST_TEST_MODULE polynomial_dfs_benchmark_test
#define BOOST_TEST_MODULE polynomial_dfs_benchmark

#include <algorithm>
#include <cctype>
Expand Down
4 changes: 0 additions & 4 deletions parallel-crypto3/libs/parallel-math/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,3 @@ set(TESTS_NAMES
foreach(TEST_NAME ${TESTS_NAMES})
define_math_test(${TEST_NAME})
endforeach()

if(ENABLE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
33 changes: 0 additions & 33 deletions parallel-crypto3/libs/parallel-math/test/benchmarks/CMakeLists.txt

This file was deleted.

0 comments on commit 0abcc7c

Please sign in to comment.