aboutsummaryrefslogtreecommitdiff
path: root/tests/torture.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2018-11-26 13:48:37 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-01-09 10:14:56 +0100
commitb3ae5e06ee625ab69cb8541548a7fda1ba807b07 (patch)
treef07693363a1c77756ce1c9fc7fcae874eb58ef36 /tests/torture.c
parentd4e5644e217f2a21376adb1ccf6457a1a7e7b44e (diff)
downloadlibssh-b3ae5e06ee625ab69cb8541548a7fda1ba807b07.tar.gz
libssh-b3ae5e06ee625ab69cb8541548a7fda1ba807b07.tar.xz
libssh-b3ae5e06ee625ab69cb8541548a7fda1ba807b07.zip
tests: Allow to generate unencrypted PCAP files from testsuite
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Daiki Ueno <dueno@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests/torture.c')
-rw-r--r--tests/torture.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/tests/torture.c b/tests/torture.c
index 9899a33b..427c8a6a 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -244,7 +244,8 @@ int torture_terminate_process(const char *pidfile)
return 0;
}
-ssh_session torture_ssh_session(const char *host,
+ssh_session torture_ssh_session(struct torture_state *s,
+ const char *host,
const unsigned int *port,
const char *user,
const char *password) {
@@ -261,6 +262,12 @@ ssh_session torture_ssh_session(const char *host,
return NULL;
}
+#ifdef WITH_PCAP
+ if (s != NULL && s->plain_pcap != NULL) {
+ ssh_set_pcap_file(session, s->plain_pcap);
+ }
+#endif /* WITH_PCAP */
+
if (ssh_options_set(session, SSH_OPTIONS_HOST, host) < 0) {
goto failed;
}
@@ -497,11 +504,23 @@ void torture_setup_socket_dir(void **state)
struct torture_state *s;
const char *p;
size_t len;
- char *env = getenv("TORTURE_GENERATE_PCAP");
+ char *env = NULL;
+ int rc;
- s = malloc(sizeof(struct torture_state));
+ s = calloc(1, sizeof(struct torture_state));
assert_non_null(s);
+#ifdef WITH_PCAP
+ env = getenv("TORTURE_PLAIN_PCAP_FILE");
+ if (env != NULL && env[0] != '\0') {
+ s->plain_pcap = ssh_pcap_file_new();
+ assert_non_null(s->plain_pcap);
+
+ rc = ssh_pcap_file_open(s->plain_pcap, env);
+ assert_int_equal(rc, SSH_OK);
+ }
+#endif /* WITH_PCAP */
+
s->socket_dir = torture_make_temp_dir(TORTURE_SOCKET_DIR);
assert_non_null(s->socket_dir);
@@ -533,6 +552,7 @@ void torture_setup_socket_dir(void **state)
setenv("SOCKET_WRAPPER_DIR", p, 1);
setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "170", 1);
+ env = getenv("TORTURE_GENERATE_PCAP");
if (env != NULL && env[0] == '1') {
setenv("SOCKET_WRAPPER_PCAP_FILE", s->pcap_file, 1);
}
@@ -781,6 +801,12 @@ void torture_teardown_socket_dir(void **state)
strerror(errno));
}
}
+#ifdef WITH_PCAP
+ if (s->plain_pcap != NULL) {
+ ssh_pcap_file_free(s->plain_pcap);
+ }
+ s->plain_pcap = NULL;
+#endif /* WITH_PCAP */
free(s->srv_config);
free(s->socket_dir);