diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f9aa83a5..c4ad13ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,10 +39,6 @@ if (CLIENT_TESTING) # create shared test library set(TORTURE_SHARED_LIBRARY torture_shared) - if (MINGW) - set(USE_ATTRIBUTE_WEAK "-DUSE_ATTRIBUTE_WEAK") - endif () - # Create a list of symbols that should be wrapped for override test set(WRAP_SYMBOLS "") list(APPEND WRAP_SYMBOLS @@ -73,7 +69,7 @@ if (CLIENT_TESTING) ) target_compile_options(${TORTURE_SHARED_LIBRARY} PRIVATE -DSSH_PING_EXECUTABLE="${CMAKE_CURRENT_BINARY_DIR}/ssh_ping" - ${USE_ATTRIBUTE_WEAK} + -DTORTURE_SHARED ) endif () diff --git a/tests/torture.c b/tests/torture.c index 99e9a3d9..f5a6bcc7 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -1629,12 +1629,14 @@ void torture_reset_config(ssh_session session) memset(session->opts.options_seen, 0, sizeof(session->opts.options_seen)); } -#if ((defined _WIN32) || (defined _WIN64)) && (defined USE_ATTRIBUTE_WEAK) +#if defined(HAVE_WEAK_ATTRIBUTE) && defined(TORTURE_SHARED) __attribute__((weak)) int torture_run_tests(void) { - fail(); + fail_msg("torture_run_tests from shared library called"); + + return -1; } -#endif +#endif /* defined(HAVE_WEAK_ATTRIBUTE) && defined(TORTURE_SHARED) */ int main(int argc, char **argv) { struct argument_s arguments; diff --git a/tests/torture.h b/tests/torture.h index 58feb21e..67c249a3 100644 --- a/tests/torture.h +++ b/tests/torture.h @@ -141,12 +141,12 @@ void torture_setup_create_libssh_config(void **state); void torture_setup_libssh_server(void **state, const char *server_path); +#if defined(HAVE_WEAK_ATTRIBUTE) && defined(TORTURE_SHARED) +__attribute__((weak)) int torture_run_tests(void); +#else /* * This function must be defined in every unit test file. */ -#if ((defined _WIN32) || (defined _WIN64)) && (defined USE_ATTRIBUTE_WEAK) -__attribute__((weak)) int torture_run_tests(void); -#else int torture_run_tests(void); #endif