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

Test build env #16

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add test_env() to test_prover
  • Loading branch information
nixw committed Mar 12, 2024
commit c69a98af63535a700612457f2d3a83a6da16ad9b
24 changes: 14 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,36 +122,40 @@ target_link_libraries(verifier rapidsnarkStatic)

add_library(rapidsnark SHARED ${LIB_SOURCES})

add_executable(test_prover test_prover.cpp)
target_link_libraries(test_prover rapidsnarkStatic)

enable_testing()
add_executable(test_public_size test_public_size.c)
target_link_libraries(test_public_size rapidsnarkStaticFrFq)
add_test(NAME test_public_size COMMAND test_public_size circuit_final.zkey 86
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testdata)


if(USE_LOGGER OR NOT USE_OPENMP)
target_link_libraries(prover pthread)
target_link_libraries(verifier pthread)
target_link_libraries(test_public_size pthread)
target_link_libraries(test_prover pthread)
endif()

if(USE_SODIUM)
target_link_libraries(prover sodium)
endif()


enable_testing()
add_executable(test_public_size test_public_size.c)
target_link_libraries(test_public_size rapidsnarkStaticFrFq)
add_test(NAME test_public_size COMMAND test_public_size circuit_final.zkey 86
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testdata)

if(OpenMP_CXX_FOUND)

if(TARGET_PLATFORM MATCHES "android")
target_link_libraries(prover -static-openmp -fopenmp)
target_link_libraries(verifier -static-openmp -fopenmp)
target_link_libraries(rapidsnark -static-openmp -fopenmp)
target_link_libraries(test_prover -static-openmp -fopenmp)

elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(prover OpenMP::OpenMP_CXX)
target_link_libraries(verifier OpenMP::OpenMP_CXX)
target_link_libraries(test_public_size OpenMP::OpenMP_CXX)
target_link_libraries(test_prover OpenMP::OpenMP_CXX)
endif()

endif()


add_executable(test_prover test_prover.cpp)
25 changes: 25 additions & 0 deletions src/test_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "fr.hpp"
#include "fq.hpp"

#ifdef USE_OPENMP
#include <omp.h>
#endif

int tests_run = 0;
int tests_failed = 0;

Expand Down Expand Up @@ -10928,8 +10932,29 @@ void print_results()
std::cout << "Results: " << std::dec << tests_run << " tests were run, " << tests_failed << " failed." << std::endl;
}

void test_env()
{
#ifdef USE_ASM
#if defined(ARCH_X86_64)
std::cout << "ASM: x86_64" << std::endl;
#elif defined(ARCH_ARM64)
std::cout << "ASM: arm64" << std::endl;
#endif
#else
std::cout << "ASM is disabled" << std::endl;
#endif

#ifdef USE_OPENMP
std::cout << "OpenMP max threads: " << omp_get_max_threads() << std::endl;
#else
std::cout << "OpenMP is disabled" << std::endl;
#endif
}

int main()
{
test_env();

Fr_Rw_add_unit_test();
Fr_Rw_sub_unit_test();
Fr_Rw_copy_unit_test();
Expand Down