From b478bb6ddbb1f3b7969ad9d6ccfdb0fa6d4843bd Mon Sep 17 00:00:00 2001 From: Jaeden Amero Date: Thu, 7 Mar 2019 16:44:54 +0000 Subject: [PATCH] tests: Add a crypto prefix to submodule tests Prepend ".crypto" to tests that came from the crypto submodule. This allows, when this project is used as a submodule, for tests with names the same between the parent and this project when used as a submodule to both be built and run. --- tests/CMakeLists.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e9cae9a9b..76a4608e1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,17 +40,24 @@ function(add_test_suite suite_name) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py mbedtls ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data ) + set(exe_name test_suite_${data_name}) + # Add a prefix to differentiate these tests from those of the parent + # module, when this project is built as a submodule. + if(USE_CRYPTO_SUBMODULE) + set(exe_name crypto.${exe_name}) + endif() + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - add_executable(test_suite_${data_name} test_suite_${data_name}.c) - target_link_libraries(test_suite_${data_name} ${libs}) - target_include_directories(test_suite_${data_name} + add_executable(${exe_name} test_suite_${data_name}.c) + target_link_libraries(${exe_name} ${libs}) + target_include_directories(${exe_name} PUBLIC ${CMAKE_SOURCE_DIR}/include/ PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/) if(${data_name} MATCHES ${SKIP_TEST_SUITES_REGEX}) message(STATUS "The test suite ${data_name} will not be executed.") else() - add_test(${data_name}-suite test_suite_${data_name} --verbose) + add_test(${data_name}-suite ${exe_name} --verbose) endif() endfunction(add_test_suite)