From c0b518efde7edc63eed68a4f94dc02cdaa6013c7 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Tue, 21 Apr 2015 13:46:36 +0200 Subject: tests: resume: check for signals --- tests/resume-dtls.c | 12 +++++------- tests/resume.c | 15 ++++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tests/resume-dtls.c b/tests/resume-dtls.c index 871b9c79a8..8f80b12256 100644 --- a/tests/resume-dtls.c +++ b/tests/resume-dtls.c @@ -48,6 +48,7 @@ int main(int argc, char **argv) #include #include #include +#include #include #include "utils.h" @@ -390,6 +391,7 @@ void doit(void) { int i; + signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); for (i = 0; resume_tests[i].desc; i++) { @@ -420,26 +422,22 @@ void doit(void) } if (child) { - int status; + int status = 0; /* parent */ for (j = 0; j < SESSIONS; j++) close(client_sds[j]); server(server_sds, &resume_tests[i]); wait(&status); - if (WEXITSTATUS(status) > 0) - error_count++; + if (WEXITSTATUS(status) != 0 || (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) + exit(1); global_stop(); - if (error_count) - exit(1); } else { for (j = 0; j < SESSIONS; j++) close(server_sds[j]); client(client_sds, &resume_tests[i]); gnutls_global_deinit(); - if (error_count) - exit(1); exit(0); } } diff --git a/tests/resume.c b/tests/resume.c index 55cd92bf0a..b009445618 100644 --- a/tests/resume.c +++ b/tests/resume.c @@ -48,6 +48,7 @@ int main(int argc, char **argv) #endif #include #include +#include #include #include "utils.h" @@ -104,7 +105,7 @@ static void client(int sds[], struct params_res *params) /* variables used in session resuming */ int t; - gnutls_datum_t session_data; + gnutls_datum_t session_data = {NULL, 0}; if (debug) { gnutls_global_set_log_function(tls_log_func); @@ -395,6 +396,7 @@ void doit(void) { int i; + signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); for (i = 0; resume_tests[i].desc; i++) { @@ -425,22 +427,21 @@ void doit(void) } if (child) { - int status; + int status = 0; /* parent */ for (j = 0; j < SESSIONS; j++) close(client_sds[j]); server(server_sds, &resume_tests[i]); - wait(&status); - if (WEXITSTATUS(status) > 0) - error_count++; + + waitpid(child, &status, 0); + if (WEXITSTATUS(status) != 0 || (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) + exit(1); global_stop(); } else { for (j = 0; j < SESSIONS; j++) close(server_sds[j]); client(client_sds, &resume_tests[i]); gnutls_global_deinit(); - if (error_count) - exit(1); exit(0); } } -- cgit v1.2.1