tests: Use weak attribute for torture_run_tests() if available
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
parent
23546e354c
commit
7787dad9bd
@ -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 ()
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user