1
0
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:
Viktor Szakats
2023-04-19 18:04:11 +00:00
parent 2d0bd5837b
commit 3336b00f72

View File

@@ -141,14 +141,20 @@ LIBSSH2_SESSION *start_session_fixture(int *skipped)
} }
connected_session = libssh2_session_init_ex(NULL, NULL, NULL, NULL); connected_session = libssh2_session_init_ex(NULL, NULL, NULL, NULL);
if(getenv("FIXTURE_TRACE_ALL")) {
libssh2_trace(connected_session, ~0);
}
if(!connected_session) { if(!connected_session) {
fprintf(stderr, "libssh2_session_init_ex failed\n"); fprintf(stderr, "libssh2_session_init_ex failed\n");
return NULL; 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 */ /* Override crypt algorithm for the test */
if(crypt) { if(crypt) {
if(libssh2_session_method_pref(connected_session, if(libssh2_session_method_pref(connected_session,
@@ -180,6 +186,10 @@ LIBSSH2_SESSION *start_session_fixture(int *skipped)
return NULL; return NULL;
} }
if(getenv("FIXTURE_TRACE_ALL_CONNECT")) {
libssh2_trace(connected_session, 0);
}
return connected_session; return connected_session;
} }