Skip to content

Commit

Permalink
fix: attempt to fix getting required files to the right place for uni…
Browse files Browse the repository at this point in the history
…t tests

Signed-off-by: James Chapman <[email protected]>
  • Loading branch information
james-ctc committed Aug 12, 2024
1 parent 1d97a40 commit bc649ea
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 35 deletions.
41 changes: 23 additions & 18 deletions lib/staging/tls/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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})
3 changes: 1 addition & 2 deletions lib/staging/tls/tests/tls_client_main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Pionix GmbH and Contributors to EVerest

#include "tls_connection_test.hpp"
#include <openssl_util.hpp>
#include <tls.hpp>

Expand Down Expand Up @@ -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) {
Expand Down
35 changes: 20 additions & 15 deletions modules/EvseV2G/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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})

0 comments on commit bc649ea

Please sign in to comment.