mirror of
https://github.com/libssh2/libssh2.git
synced 2025-10-29 00:54:50 +03:00
tests: add FIXTURE_TRACE_ALL_CONNECT option
Works like the `FIXTURE_TRACE_ALL` envvar, but enables full trace for the connection phase only. Also fix a possible NULL deref with `FIXTURE_TRACE_ALL` and a failed `libssh2_session_init_ex()`. Tested in #979
This commit is contained in:
@@ -141,14 +141,20 @@ LIBSSH2_SESSION *start_session_fixture(int *skipped)
|
||||
}
|
||||
|
||||
connected_session = libssh2_session_init_ex(NULL, NULL, NULL, NULL);
|
||||
if(getenv("FIXTURE_TRACE_ALL")) {
|
||||
libssh2_trace(connected_session, ~0);
|
||||
}
|
||||
if(!connected_session) {
|
||||
fprintf(stderr, "libssh2_session_init_ex failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(getenv("FIXTURE_TRACE_ALL_CONNECT")) {
|
||||
libssh2_trace(connected_session, ~0);
|
||||
fprintf(stdout, "Trace all enabled for connect_to_server.\n");
|
||||
}
|
||||
else if(getenv("FIXTURE_TRACE_ALL")) {
|
||||
libssh2_trace(connected_session, ~0);
|
||||
fprintf(stdout, "Trace all enabled.\n");
|
||||
}
|
||||
|
||||
/* Override crypt algorithm for the test */
|
||||
if(crypt) {
|
||||
if(libssh2_session_method_pref(connected_session,
|
||||
@@ -180,6 +186,10 @@ LIBSSH2_SESSION *start_session_fixture(int *skipped)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(getenv("FIXTURE_TRACE_ALL_CONNECT")) {
|
||||
libssh2_trace(connected_session, 0);
|
||||
}
|
||||
|
||||
return connected_session;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user