diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 85753d1e..cc230d07 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -115,6 +115,7 @@ if(CRYPTO_BACKEND STREQUAL "mbedTLS" OR NOT CRYPTO_BACKEND) endif() set(TESTS + warmup hostkey hostkey_hash password_auth_succeeds_with_correct_credentials @@ -165,7 +166,11 @@ target_include_directories(runner PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") foreach(test ${TESTS}) add_executable(test_${test} test_${test}.c) - target_link_libraries(test_${test} libssh2 runner ${LIBRARIES}) + if(TESTS STREQUAL "warmup") + target_link_libraries(test_${test} libssh2 ${LIBRARIES}) + else() + target_link_libraries(test_${test} libssh2 runner ${LIBRARIES}) + endif() target_include_directories(test_${test} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") list(APPEND TEST_TARGETS test_${test}) add_definitions(-DFIXTURE_WORKDIR="${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/tests/Makefile.am b/tests/Makefile.am index fb8c6329..e321dfc8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,6 +12,7 @@ check_PROGRAMS += ssh2 endif INTEGRATION_TESTS = \ + test_warmup \ test_agent_forward_succeeds \ test_hostkey \ test_hostkey_hash \ diff --git a/tests/test_warmup.c b/tests/test_warmup.c new file mode 100644 index 00000000..dfbf6fa3 --- /dev/null +++ b/tests/test_warmup.c @@ -0,0 +1,27 @@ +/* Warm-up test. Always return 0. + Workaround for CI/docker/etc flakiness on the first run. */ + +#include "session_fixture.h" +#include "runner.h" + +#include + +#include + +int main(void) +{ + LIBSSH2_SESSION *session = start_session_fixture(); + if(session != NULL) { + size_t len = 0; + int type = 0; + const char *hostkey = libssh2_session_hostkey(session, &len, &type); + + (void)hostkey; + + fprintf(stdout, + "libssh2_session_hostkey returned len, type: %d, %d\n", + (int)len, type); + } + stop_session_fixture(); + return 0; +}