diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-04-21 13:46:36 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-04-21 15:16:03 +0200 |
commit | c0b518efde7edc63eed68a4f94dc02cdaa6013c7 (patch) | |
tree | 5f7605d8f0921759d19c342c4048336f6678a9e8 | |
parent | 5b02933f0eed96b0bb15be9ad81021f5b27f2a9b (diff) | |
download | gnutls-c0b518efde7edc63eed68a4f94dc02cdaa6013c7.tar.gz |
tests: resume: check for signals
-rw-r--r-- | tests/resume-dtls.c | 12 | ||||
-rw-r--r-- | 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 <unistd.h> #include <gnutls/gnutls.h> #include <gnutls/dtls.h> +#include <sys/wait.h> #include <signal.h> #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 <unistd.h> #include <gnutls/gnutls.h> +#include <sys/wait.h> #include <signal.h> #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); } } |