diff --git a/CMakeLists.txt b/CMakeLists.txt index dddb4e1c91..19fa7e9800 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -412,6 +412,41 @@ add_subdirectory(pkgconfig) # to define the test executables. # if(ENABLE_TESTING OR ENABLE_PROGRAMS) + file(GLOB MBEDTLS_TEST_FILES + ${MBEDTLS_FRAMEWORK_DIR}/tests/src/*.c + ${MBEDTLS_FRAMEWORK_DIR}/tests/src/drivers/*.c) + add_library(mbedtls_test OBJECT ${MBEDTLS_TEST_FILES}) + set_base_compile_options(mbedtls_test) + if(GEN_FILES) + add_custom_command( + OUTPUT + ${MBEDTLS_FRAMEWORK_DIR}/tests/src/test_keys.h + COMMAND + "${MBEDTLS_PYTHON_EXECUTABLE}" + "${MBEDTLS_FRAMEWORK_DIR}/scripts/generate_test_keys.py" + "--output" + "${MBEDTLS_FRAMEWORK_DIR}/tests/src/test_keys.h" + DEPENDS + ${MBEDTLS_FRAMEWORK_DIR}/scripts/generate_test_keys.py + ) + add_custom_target(mbedtls_test_keys_header + DEPENDS ${MBEDTLS_FRAMEWORK_DIR}/tests/src/test_keys.h) + add_dependencies(mbedtls_test mbedtls_test_keys_header) + endif() + target_include_directories(mbedtls_test + PRIVATE ${MBEDTLS_FRAMEWORK_DIR}/tests/include + PRIVATE tests/include + PRIVATE include + PRIVATE tf-psa-crypto/include + PRIVATE tf-psa-crypto/drivers/builtin/include + PRIVATE tf-psa-crypto/drivers/everest/include + PRIVATE library + PRIVATE tf-psa-crypto/core + PRIVATE tf-psa-crypto/drivers/builtin/src) + # Request C11, needed for memory poisoning tests + set_target_properties(mbedtls_test PROPERTIES C_STANDARD 11) + set_config_files_compile_definitions(mbedtls_test) + file(GLOB MBEDTLS_TEST_HELPER_FILES tests/src/*.c tests/src/test_helpers/*.c) add_library(mbedtls_test_helpers OBJECT ${MBEDTLS_TEST_HELPER_FILES}) diff --git a/programs/aes/CMakeLists.txt b/programs/aes/CMakeLists.txt index 08bf095088..c5128b1b4d 100644 --- a/programs/aes/CMakeLists.txt +++ b/programs/aes/CMakeLists.txt @@ -4,7 +4,7 @@ set(executables add_dependencies(${programs_target} ${executables}) foreach(exe IN LISTS executables) - add_executable(${exe} ${exe}.c $) + add_executable(${exe} ${exe}.c $) set_base_compile_options(${exe}) target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include) diff --git a/programs/cipher/CMakeLists.txt b/programs/cipher/CMakeLists.txt index 3bc1a9e51c..d6483011a0 100644 --- a/programs/cipher/CMakeLists.txt +++ b/programs/cipher/CMakeLists.txt @@ -4,7 +4,7 @@ set(executables add_dependencies(${programs_target} ${executables}) foreach(exe IN LISTS executables) - add_executable(${exe} ${exe}.c $) + add_executable(${exe} ${exe}.c $) set_base_compile_options(${exe}) target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include) diff --git a/programs/fuzz/CMakeLists.txt b/programs/fuzz/CMakeLists.txt index 57cfeee510..8f463178b8 100644 --- a/programs/fuzz/CMakeLists.txt +++ b/programs/fuzz/CMakeLists.txt @@ -31,7 +31,7 @@ foreach(exe IN LISTS executables_no_common_c executables_with_common_c) set(exe_sources ${exe}.c $ - $) + $) if(NOT FUZZINGENGINE_LIB) list(APPEND exe_sources onefile.c) endif() diff --git a/programs/hash/CMakeLists.txt b/programs/hash/CMakeLists.txt index 3eabb97d31..d23db0443e 100644 --- a/programs/hash/CMakeLists.txt +++ b/programs/hash/CMakeLists.txt @@ -6,7 +6,7 @@ set(executables add_dependencies(${programs_target} ${executables}) foreach(exe IN LISTS executables) - add_executable(${exe} ${exe}.c $) + add_executable(${exe} ${exe}.c $) set_base_compile_options(${exe}) target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include) diff --git a/programs/pkey/CMakeLists.txt b/programs/pkey/CMakeLists.txt index 34987c3f52..c782ad4655 100644 --- a/programs/pkey/CMakeLists.txt +++ b/programs/pkey/CMakeLists.txt @@ -5,7 +5,7 @@ set(executables_mbedtls add_dependencies(${programs_target} ${executables_mbedtls}) foreach(exe IN LISTS executables_mbedtls) - add_executable(${exe} ${exe}.c $) + add_executable(${exe} ${exe}.c $) set_base_compile_options(${exe}) target_link_libraries(${exe} ${mbedtls_target} ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include) @@ -34,7 +34,7 @@ set(executables_mbedcrypto add_dependencies(${programs_target} ${executables_mbedcrypto}) foreach(exe IN LISTS executables_mbedcrypto) - add_executable(${exe} ${exe}.c $) + add_executable(${exe} ${exe}.c $) set_base_compile_options(${exe}) target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include) diff --git a/programs/random/CMakeLists.txt b/programs/random/CMakeLists.txt index d7c0782428..76cb8407af 100644 --- a/programs/random/CMakeLists.txt +++ b/programs/random/CMakeLists.txt @@ -5,7 +5,7 @@ set(executables add_dependencies(${programs_target} ${executables}) foreach(exe IN LISTS executables) - add_executable(${exe} ${exe}.c $) + add_executable(${exe} ${exe}.c $) set_base_compile_options(${exe}) target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include) diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt index 513c866d5b..a27c6262b5 100644 --- a/programs/ssl/CMakeLists.txt +++ b/programs/ssl/CMakeLists.txt @@ -40,8 +40,8 @@ foreach(exe IN LISTS executables) endif() add_executable(${exe} ${exe}.c + $ $ - $ ${extra_sources}) set_base_compile_options(${exe}) target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT}) @@ -59,8 +59,8 @@ endforeach() if(THREADS_FOUND) add_executable(ssl_pthread_server ssl_pthread_server.c - $ - $) + $ + $) set_base_compile_options(ssl_pthread_server) target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 285da13afb..dec1e8c28a 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -82,7 +82,7 @@ foreach(exe IN LISTS executables_libs executables_mbedcrypto) ${CMAKE_CURRENT_SOURCE_DIR}/query_config.h ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) endif() - add_executable(${exe} ${exe}.c $ + add_executable(${exe} ${exe}.c $ ${extra_sources}) set_base_compile_options(${exe}) target_include_directories(${exe} diff --git a/programs/util/CMakeLists.txt b/programs/util/CMakeLists.txt index ae1b467049..c1b6b75866 100644 --- a/programs/util/CMakeLists.txt +++ b/programs/util/CMakeLists.txt @@ -10,7 +10,7 @@ set(executables add_dependencies(${programs_target} ${executables}) foreach(exe IN LISTS executables) - add_executable(${exe} ${exe}.c $) + add_executable(${exe} ${exe}.c $) set_base_compile_options(${exe}) target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include) diff --git a/programs/x509/CMakeLists.txt b/programs/x509/CMakeLists.txt index c3ee3480ff..9e63bf1530 100644 --- a/programs/x509/CMakeLists.txt +++ b/programs/x509/CMakeLists.txt @@ -13,7 +13,7 @@ set(executables add_dependencies(${programs_target} ${executables}) foreach(exe IN LISTS executables) - add_executable(${exe} ${exe}.c $) + add_executable(${exe} ${exe}.c $) set_base_compile_options(${exe}) target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 402b8cb2ea..950c365973 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -154,7 +154,7 @@ function(add_test_suite suite_name) ) add_executable(test_suite_${data_name} test_suite_${data_name}.c - $ + $ $) set_base_compile_options(test_suite_${data_name}) target_compile_options(test_suite_${data_name} PRIVATE ${TEST_C_FLAGS})