diff --git a/lib/staging/tls/tests/CMakeLists.txt b/lib/staging/tls/tests/CMakeLists.txt index 18ec13b90..36c2ca2a0 100644 --- a/lib/staging/tls/tests/CMakeLists.txt +++ b/lib/staging/tls/tests/CMakeLists.txt @@ -1,7 +1,27 @@ find_package(OpenSSL 3) +set(TLS_TEST_FILES + alt_openssl-pki.conf + iso_pkey.asn1 + openssl-pki.conf + ocsp_response.der + pki.sh +) + +add_custom_command( + OUTPUT ${TLS_TEST_FILES} + COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/pki + COMMAND cd pki && cp ${TLS_TEST_FILES} ${CMAKE_CURRENT_BINARY_DIR}/ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_custom_target(tls_test_files_target + DEPENDS ${TLS_TEST_FILES} +) + set(TLS_GTEST_NAME tls_test) add_executable(${TLS_GTEST_NAME}) +add_dependencies(${TLS_GTEST_NAME} tls_test_files_target) target_include_directories(${TLS_GTEST_NAME} PRIVATE . .. ../../util @@ -35,6 +55,7 @@ target_link_libraries(${TLS_GTEST_NAME} PRIVATE set(TLS_MAIN_NAME tls_server) add_executable(${TLS_MAIN_NAME}) +add_dependencies(${TLS_MAIN_NAME} tls_test_files_target) target_include_directories(${TLS_MAIN_NAME} PRIVATE . .. ../../util @@ -60,6 +81,7 @@ target_link_libraries(${TLS_MAIN_NAME} PRIVATE set(TLS_CLIENT_NAME tls_client) add_executable(${TLS_CLIENT_NAME}) +add_dependencies(${TLS_CLIENT_NAME} tls_test_files_target) target_include_directories(${TLS_CLIENT_NAME} PRIVATE . .. ../../util @@ -79,13 +101,13 @@ target_sources(${TLS_CLIENT_NAME} PRIVATE ) target_link_libraries(${TLS_CLIENT_NAME} PRIVATE - GTest::gtest OpenSSL::SSL OpenSSL::Crypto ) set(TLS_PATCH_NAME patched_test) add_executable(${TLS_PATCH_NAME}) +add_dependencies(${TLS_PATCH_NAME} tls_test_files_target) target_include_directories(${TLS_PATCH_NAME} PRIVATE . .. ../../util @@ -110,21 +132,4 @@ target_link_libraries(${TLS_PATCH_NAME} PRIVATE OpenSSL::Crypto ) -install( - FILES - pki/alt_openssl-pki.conf - pki/iso_pkey.asn1 - pki/openssl-pki.conf - pki/ocsp_response.der - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" -) - -install( - PROGRAMS - pki/pki.sh - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" -) - -# tests don't run successfully in CI pipeline -# pki.sh not installed or run from wrong directory add_test(${TLS_GTEST_NAME} ${TLS_GTEST_NAME}) diff --git a/lib/staging/tls/tests/tls_client_main.cpp b/lib/staging/tls/tests/tls_client_main.cpp index 46fdcd0a5..729093e13 100644 --- a/lib/staging/tls/tests/tls_client_main.cpp +++ b/lib/staging/tls/tests/tls_client_main.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright 2024 Pionix GmbH and Contributors to EVerest -#include "tls_connection_test.hpp" #include #include @@ -57,7 +56,7 @@ int main(int argc, char** argv) { parse_options(argc, argv); // used test client for extra output - ClientTest client; + tls::Client client; tls::Client::config_t config; if (use_tls1_3) { diff --git a/modules/EvseV2G/tests/CMakeLists.txt b/modules/EvseV2G/tests/CMakeLists.txt index 383370df4..5b5adf32b 100644 --- a/modules/EvseV2G/tests/CMakeLists.txt +++ b/modules/EvseV2G/tests/CMakeLists.txt @@ -1,8 +1,28 @@ get_target_property(GENERATED_INCLUDE_DIR generate_cpp_files EVEREST_GENERATED_INCLUDE_DIR) find_package(libevent) +set(TLS_TEST_FILES + alt_openssl-pki.conf + iso_pkey.asn1 + openssl-pki.conf + ocsp_response.der + pki.sh +) + +add_custom_command( + OUTPUT ${TLS_TEST_FILES} + COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/pki + COMMAND cd pki && cp ${TLS_TEST_FILES} ${CMAKE_CURRENT_BINARY_DIR}/ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}../../../../lib/staging/tls/tests/ +) + +add_custom_target(v2g_test_files_target + DEPENDS ${TLS_TEST_FILES} +) + set(TLS_GTEST_NAME v2g_openssl_test) add_executable(${TLS_GTEST_NAME}) +add_dependencies(${TLS_GTEST_NAME} v2g_test_files_target) add_dependencies(${TLS_GTEST_NAME} generate_cpp_files) @@ -70,20 +90,5 @@ target_link_libraries(${V2G_MAIN_NAME} PRIVATE -levent -lpthread -levent_pthreads ) -install( - FILES - ../../../lib/staging/tls/tests/pki/iso_pkey.asn1 - ../../../lib/staging/tls/tests/pki/openssl-pki.conf - ../../../lib/staging/tls/tests/pki/alt_openssl-pki.conf - ../../../lib/staging/tls/tests/pki/ocsp_response.der - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" -) - -install( - PROGRAMS - ../../../lib/staging/tls/tests/pki/pki.sh - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" -) - # runs fine locally, fails in CI add_test(${TLS_GTEST_NAME} ${TLS_GTEST_NAME})