Skip to content

Commit

Permalink
Link test programs with oqs-internal
Browse files Browse the repository at this point in the history
  • Loading branch information
SWilson4 committed Jan 12, 2024
1 parent 9ca233b commit 12528d1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 43 deletions.
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ add_library(oqs kem/kem.c
add_library(oqs-internal ${INTERNAL_OBJS})

set(COMMON_OBJS ${COMMON_OBJS} PARENT_SCOPE)
set(_ALL_OBJS ${KEM_OBJS} ${SIG_OBJS} ${COMMON_OBJS} $<TARGET_OBJECTS:oqs>)
set(ALL_OBJS ${_ALL_OBJS} PARENT_SCOPE)
if(DEFINED SANITIZER_LD_FLAGS)
target_link_libraries(oqs PUBLIC ${SANITIZER_LD_FLAGS})
target_link_libraries(oqs-internal PUBLIC ${SANITIZER_LD_FLAGS})
Expand Down
74 changes: 33 additions & 41 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,86 +21,78 @@ if(WIN32 AND NOT (MINGW OR MSYS OR CYGWIN))
add_compile_options(/wd4996 /wd4244)
endif()

if(OQS_USE_OPENSSL)
include_directories(${OPENSSL_INCLUDE_DIR})
endif()

if(NOT WIN32)
set(LIBM m)
endif()

# There should in principle be no linking conflict between oqs and oqs-internal.
# Nonetheless, list oqs-internal after oqs to be safe.
set(TEST_DEPS oqs oqs-internal ${LIBM})
if(CMAKE_USE_PTHREADS_INIT)
set(TEST_DEPS ${TEST_DEPS} Threads::Threads)
endif()

if(OQS_USE_OPENSSL)
include_directories(${OPENSSL_INCLUDE_DIR})
set(INTERNAL_TEST_DEPS ${OPENSSL_CRYPTO_LIBRARY} ${LIBM})
else()
set(INTERNAL_TEST_DEPS ${LIBM})
endif()
if(CMAKE_USE_PTHREADS_INIT)
set(INTERNAL_TEST_DEPS ${INTERNAL_TEST_DEPS} Threads::Threads)
endif()
if(DEFINED SANITIZER_LD_FLAGS)
set(INTERNAL_TEST_DEPS ${INTERNAL_TEST_DEPS} ${SANITIZER_LD_FLAGS})
endif()
if(NOT WIN32)
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/scripts/git_commit.sh OUTPUT_VARIABLE GIT_COMMIT)
add_definitions(-DOQS_COMPILE_GIT_COMMIT="${GIT_COMMIT}")

add_executable(test_aes test_aes.c ${COMMON_OBJS})
target_link_libraries(test_aes PRIVATE ${INTERNAL_TEST_DEPS})
add_executable(test_aes test_aes.c)
target_link_libraries(test_aes PRIVATE ${TEST_DEPS})

add_executable(test_hash test_hash.c ${COMMON_OBJS})
target_link_libraries(test_hash PRIVATE ${INTERNAL_TEST_DEPS})
add_executable(test_hash test_hash.c)
target_link_libraries(test_hash PRIVATE ${TEST_DEPS})

add_executable(test_sha3 test_sha3.c ${COMMON_OBJS})
target_link_libraries(test_sha3 PRIVATE ${INTERNAL_TEST_DEPS})
add_executable(test_sha3 test_sha3.c)
target_link_libraries(test_sha3 PRIVATE ${TEST_DEPS})

add_executable(speed_common speed_common.c ${COMMON_OBJS})
target_link_libraries(speed_common PRIVATE ${INTERNAL_TEST_DEPS})
add_executable(speed_common speed_common.c)
target_link_libraries(speed_common PRIVATE ${TEST_DEPS})

set(UNIX_TESTS test_aes test_hash test_sha3)

set(PYTHON3_EXEC python3)
else()
if(OQS_USE_OPENSSL)
include_directories(${OPENSSL_INCLUDE_DIR})
endif()
set(PYTHON3_EXEC python)
endif()

set(API_TEST_DEPS oqs ${LIBM})
if(CMAKE_USE_PTHREADS_INIT)
set(API_TEST_DEPS ${API_TEST_DEPS} Threads::Threads)
endif()

# KEM API tests
add_executable(example_kem example_kem.c)
target_link_libraries(example_kem PRIVATE ${API_TEST_DEPS})
target_link_libraries(example_kem PRIVATE ${TEST_DEPS})

# KAT KEM needs to call the internal SHA3 functions directly, hence the extra dependencies
add_executable(kat_kem kat_kem.c ${ALL_OBJS})
target_link_libraries(kat_kem PRIVATE ${API_TEST_DEPS} ${INTERNAL_TEST_DEPS})
add_executable(kat_kem kat_kem.c)
target_link_libraries(kat_kem PRIVATE ${TEST_DEPS})

add_executable(test_kem test_kem.c)
target_link_libraries(test_kem PRIVATE ${API_TEST_DEPS})
target_link_libraries(test_kem PRIVATE ${TEST_DEPS})

add_executable(test_kem_mem test_kem_mem.c)
target_link_libraries(test_kem_mem PRIVATE ${API_TEST_DEPS})
target_link_libraries(test_kem_mem PRIVATE ${TEST_DEPS})

add_executable(speed_kem speed_kem.c)
target_link_libraries(speed_kem PRIVATE ${API_TEST_DEPS})
target_link_libraries(speed_kem PRIVATE ${TEST_DEPS})

# SIG API tests
add_executable(example_sig example_sig.c)
target_link_libraries(example_sig PRIVATE ${API_TEST_DEPS})
target_link_libraries(example_sig PRIVATE ${TEST_DEPS})

add_executable(kat_sig kat_sig.c)
target_link_libraries(kat_sig PRIVATE ${API_TEST_DEPS})
target_link_libraries(kat_sig PRIVATE ${TEST_DEPS})

add_executable(test_sig test_sig.c)
target_link_libraries(test_sig PRIVATE ${API_TEST_DEPS})
target_link_libraries(test_sig PRIVATE ${TEST_DEPS})

add_executable(test_sig_mem test_sig_mem.c)
target_link_libraries(test_sig_mem PRIVATE ${API_TEST_DEPS})
target_link_libraries(test_sig_mem PRIVATE ${TEST_DEPS})

add_executable(speed_sig speed_sig.c)
target_link_libraries(speed_sig PRIVATE ${API_TEST_DEPS})
target_link_libraries(speed_sig PRIVATE ${TEST_DEPS})

add_executable(dump_alg_info dump_alg_info.c)
target_link_libraries(dump_alg_info PRIVATE ${API_TEST_DEPS})
target_link_libraries(dump_alg_info PRIVATE ${TEST_DEPS})

# Enable Valgrind-based timing side-channel analysis for test_kem and test_sig
if(OQS_ENABLE_TEST_CONSTANT_TIME AND NOT OQS_DEBUG_BUILD)
Expand Down

0 comments on commit 12528d1

Please sign in to comment.