]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: moved child status error checking code in utils.h
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 8 Aug 2016 09:49:04 +0000 (11:49 +0200)
committerGitLab <gitlab@gitlab.com>
Tue, 9 Aug 2016 06:01:35 +0000 (06:01 +0000)
61 files changed:
tests/alpn-server-prec.c
tests/client-fastopen.c
tests/custom-urls-override.c
tests/custom-urls.c
tests/dtls-client-with-seccomp.c
tests/dtls-rehandshake-anon.c
tests/dtls-rehandshake-cert-2.c
tests/dtls-rehandshake-cert-3.c
tests/dtls-rehandshake-cert.c
tests/dtls-with-seccomp.c
tests/fallback-scsv.c
tests/key-material-dtls.c
tests/key-material-set-dtls.c
tests/long-session-id.c
tests/mini-alpn.c
tests/mini-cert-status.c
tests/mini-chain-unsorted.c
tests/mini-dtls-discard.c
tests/mini-dtls-fork.c
tests/mini-dtls-heartbeat.c
tests/mini-dtls-hello-verify-48.c
tests/mini-dtls-hello-verify.c
tests/mini-dtls-large.c
tests/mini-dtls-lowmtu.c
tests/mini-dtls-mtu.c
tests/mini-dtls-pthread.c
tests/mini-dtls-record-asym.c
tests/mini-dtls-record.c
tests/mini-dtls-srtp.c
tests/mini-dtls0-9.c
tests/mini-etm.c
tests/mini-handshake-timeout.c
tests/mini-key-material.c
tests/mini-loss-time.c
tests/mini-overhead.c
tests/mini-record-2.c
tests/mini-record-failure.c
tests/mini-record-range.c
tests/mini-record-retvals.c
tests/mini-record.c
tests/mini-server-name.c
tests/mini-termination.c
tests/mini-tls-nonblock.c
tests/no-signal.c
tests/openpgp-auth.c
tests/openpgp-auth2.c
tests/openpgp-callback.c
tests/prf.c
tests/resume-dtls.c
tests/resume.c
tests/sign-md5-rep.c
tests/srp.c
tests/status-request-missing.c
tests/status-request-ok.c
tests/status-request.c
tests/tls-client-with-seccomp.c
tests/tls-rehandshake-cert-2.c
tests/tls-with-seccomp.c
tests/tlsext-decoding.c
tests/utils.h
tests/x509dn.c

index 45938d73be510b27ee0c28427fb10f560bed0c9b..e8da9ebada312ddc8647f11c0b3a4bdf24714697 100644 (file)
@@ -281,9 +281,7 @@ static void start(const char *p1, const char *p2, const char *cp1, const char *c
 
                server(fd[0], p1, p2, expected);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1], cp1, "unknown/1.4", cp2);
index 863f12a19ee90f33d04e90fd9a0cd028a6d03739..9211c44a7cab120f6a608dda4a477664f28bfa46 100644 (file)
@@ -298,9 +298,7 @@ void doit(void)
                server(fd);
 
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                fd = socket(AF_INET, SOCK_STREAM, 0);
 
index cbf1e7ca1080744731aa4594153ddd1ca64492b0..2209fe8eddc9d0143065e313d1b195fabd4a5f4e 100644 (file)
@@ -265,15 +265,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 41e4bc023409c41bc1bde9c2736bd0de10a6210b..0827d3c2d8156881832cacfdd6ca87854b9a7ec9 100644 (file)
@@ -264,15 +264,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index bc21e90ae95ac93af5e0a093e0077d4bd010d157..45d7f29899d5a2b259c5a60d7d1fcf46f5851aa8 100644 (file)
@@ -293,9 +293,7 @@ void doit(void)
                server(fd[0]);
 
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index 9e4717813ac52041c0ac96628c2eb49bee43485c..bef4f30643e775a7a84bc909cbf00419c644fab0 100644 (file)
@@ -365,9 +365,7 @@ static void start(int server_initiated)
 
                server(fd[0], server_initiated);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1], server_initiated);
index 3ce366f5c06f770819a40fb1da395c86df6d67ae..039b79c178a64a1b1535192709664ad328e71823 100644 (file)
@@ -380,9 +380,7 @@ static void start(int server_initiated)
 
                server(fd[0], server_initiated);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1], server_initiated);
index 4021155b4b29acaaf15dcd7f7d470949f320db62..d1c0399890a9ba79b29395c5dfe6e76a43d43d5f 100644 (file)
@@ -373,9 +373,7 @@ void doit(void)
                server_fd = fd[0];
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index c0b90702e200b9e1a33d10b41502baa2bb2934ce..b12b792669ca2e51d89cbb235fc5651c9cdfb5ea 100644 (file)
@@ -369,9 +369,7 @@ static void start(int server_initiated)
 
                server(fd[0], server_initiated);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1], server_initiated);
index b71c813a8b7c56601202613f40145a5b485ca93d..161e105b32547a9c2f7b3ab160556bcf6086131e 100644 (file)
@@ -293,9 +293,7 @@ void doit(void)
                client(fd[1]);
 
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[1]);
                server(fd[0]);
index 80b918c6b1d403165c66f9792ea4e684c4c64e2c..0774e403c26af1a451d3d016f17d7fc1dcbd7e6c 100644 (file)
@@ -324,14 +324,7 @@ static void start(const char *server_prio, const char *cli_prio, unsigned expect
                close(fd[1]);
                server(fd[0], server_prio, expect_fail);
                waitpid(child, &status, 0);
-               if (WEXITSTATUS(status) != 0 ||
-                   (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-                       if (WIFSIGNALED(status))
-                               fail("Child died with sigsegv\n");
-                       else
-                               fail("Child died with status %d\n",
-                                    WEXITSTATUS(status));
-               }
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1], cli_prio, expect_fail);
index 0d9334d1a16575507fef835b5ba94e0c5116d475..f7660a49e134f802dd208a16aa336ea41bc195f4 100644 (file)
@@ -387,9 +387,7 @@ static void start(void)
 
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index fb568afc61d38a9022e57ff24ef3edef0837085b..5c46a6a127f79d80c194b3aa42e8a3233594d105 100644 (file)
@@ -373,9 +373,7 @@ static void start(void)
 
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index bacb3a18dc7d14ebd9ce824182cdcc2f07524073..b021b6e9df066086d99dacbf63779cc7e8061eb4 100644 (file)
@@ -246,17 +246,7 @@ static void ch_handler(int sig)
 {
        int status, ret = 0;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status)) {
-                       fprintf(stderr, "Child died with sigsegv\n");
-                       ret = 1;
-               } else {
-                       fprintf(stderr, "Child died with status %d\n",
-                            WEXITSTATUS(status));
-               }
-               terminate(ret);
-       }
+       check_wait_status(status);
        return;
 }
 
index 6c74ce843826f28b3ace7b996d6705208b1c6d57..304d0a171c87a5e086c5b61924a0173958f21632 100644 (file)
@@ -283,9 +283,7 @@ static void start(const char *p1, const char *p2)
 
                server(fd[0], p1, p2);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1], "unknown/1.4", p2, p1);
index e8702fffb6a5def40f3d9fd399d4b8ad2772bd74..e6be43f4b79357e8a3599c6fa7e1145ae488802f 100644 (file)
@@ -289,11 +289,7 @@ static void ch_handler(int sig)
        int status = 0;
 
        waitpid(-1, &status, 0);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-       }
+       check_wait_status_for_sig(status);
        return;
 }
 
index f9eb748d34fdba378173f9efa5869a411e065f3d..a16a67376570c27bb9cc4f713317de750ed9140d 100644 (file)
@@ -351,11 +351,7 @@ static void ch_handler(int sig)
        int status = 0;
 
        waitpid(-1, &status, 0);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-       }
+       check_wait_status(status);
        return;
 }
 
index 5ba24d96a6b18f0d6cd6196b7875c73d995e3120..4e5110be16ed65678e104d149bc93d5a5a347656 100644 (file)
@@ -293,9 +293,7 @@ void doit(void)
 
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index ec70f7823119b66e873df6c52fc5d47aa64b11ab..16270de273d16eefe26556a2af360895b0d63aea 100644 (file)
@@ -367,9 +367,7 @@ void run(unsigned do_fork)
                close(fd[1]);
                client(fd[0], do_fork);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                server(fd[1], 1-do_fork);
index 1fea6b65dfed2348084c2e43dd3ba001b3d2c6cc..927708593b67a4c9931876a25e88f62b2d8d5ed7 100644 (file)
@@ -331,9 +331,7 @@ static void start(int server_initiated)
 
                server(fd[0], server_initiated);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1], server_initiated);
index ef4a876ed2a4ee6eddb9985ec8164dc7f9458d7c..10516395df04f757318feba32426f911712ae4ba 100644 (file)
@@ -300,9 +300,7 @@ void doit(void)
 
                client(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Server died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                server(fd[1]);
index c5e3d96993ed19c9639fb0742e88221677a66a77..180e26c9068378ea67af96a3a4011b4265d01487 100644 (file)
@@ -337,9 +337,7 @@ void doit(void)
 
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index 9ce749e0669d3464fa7c66f9ca75be79854c6999..da32f4e8abf826642f4b3b50181d1d7096e56d61 100644 (file)
@@ -337,9 +337,7 @@ static void start(void)
 
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index 9077d30e01b48ed87a385fa242fb4730ab4cd827..93a645f6f536a9b9866025fa7b8e83777c38d2f1 100644 (file)
@@ -325,15 +325,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 6f52e336b856d31ed14ae269180cf1a6be5958b9..dda02a1d449dff51a664b11ea1ced789adf367d5 100644 (file)
@@ -309,9 +309,7 @@ void doit(void)
                close(fd[0]);
                server(fd[1]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[1]);
                client(fd[0]);
index 64cbba50f58c69ada7036448eefbaaa8ad90463f..77012553bcb87a9bb8367c66b944d63f6ac6e48d 100644 (file)
@@ -376,9 +376,7 @@ void run(unsigned do_thread)
                close(fd[1]);
                client(fd[0], do_thread);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                server(fd[1], 1-do_thread);
index 9087dc529977b7a903bc58afca783cbfc1b7ce66..9ace1a533af985541d21608d31130494a3eb6c91 100644 (file)
@@ -336,9 +336,7 @@ void run(unsigned cache)
                close(fd[1]);
                client(fd[0], cache);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                server(fd[1], cache);
index 60c0fed6acb07b5e49219dddee75e8477b7a64a7..1b5a0551e83af909f42ff2aa78e94707b475d5f6 100644 (file)
@@ -387,9 +387,7 @@ static void start(void)
                close(fd[1]);
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index 07e624e2af37b40452f74056a70ccb5c3106480d..93c06820f8104538ce6245cfb97f92eccad4fb81 100644 (file)
@@ -323,9 +323,7 @@ static void start(int profile)
 
                server(fd[0], profile);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1], profile);
index 11f98e2ed3b42f07da4e4f493b1eaf62a8bbfbd5..852d03ff6b692111f45a09444cd1fbec8e3215d4 100644 (file)
@@ -305,9 +305,7 @@ static void run(int proto, int cipher, int mac)
                close(fd[1]);
                server(fd[0], proto, cipher, mac);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
                close(fd[0]);
        } else {
                close(fd[0]);
index 72051cd08f2d8dd87ba655a783968fcaad150a1f..daccb826c88c822bdbf12c9ee2188dc120efe6ff 100644 (file)
@@ -369,15 +369,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 488867417b666ce5a82735a1571511e16fde101e..d3a1233888c26ddf3e103445317953e2f394e839 100644 (file)
@@ -215,8 +215,7 @@ static void ch_handler(int sig)
 {
        int status = 0;
        wait(&status);
-       if (WEXITSTATUS(status) != 0)
-               fail("Child died with status %d\n", WEXITSTATUS(status));
+       check_wait_status(status);
        return;
 }
 
index ddd64de8fd45bcd9d1a99640b0b8967ce066269b..15c79f0ef67eb308d68234c350334f87a7b4e8f0 100644 (file)
@@ -395,9 +395,7 @@ static void start(void)
 
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index 2c106b4273fa7a6fc7a01fa97058deaf726e75a3..4883b69bcddb3155f9710fd45173c4434633df3e 100644 (file)
@@ -283,8 +283,7 @@ static void ch_handler(int sig)
 {
        int status = 0;
        wait(&status);
-       if (WEXITSTATUS(status) != 0)
-               fail("Child died with status %d\n", WEXITSTATUS(status));
+       check_wait_status(status);
        return;
 }
 
index 43073d976ab6773cf5c3f254e5f1a39ae6d842c6..3887caeb1a15516e7da2d89021a9af7e915726d3 100644 (file)
@@ -311,15 +311,7 @@ static void ch_handler(int sig)
        int status = 0;
 
        waitpid(-1, &status, 0);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index e36b2121a6ea6882307a8103a2262c416d76930e..c6abe0951e32c0ed416ad1e4b89d1fa2d588e41b 100644 (file)
@@ -432,15 +432,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 02ce34629526c49733815fc161fbf79d0dbf10d3..9f70ce30555bdc86a1c6649338fdabc08c7d2b4c 100644 (file)
@@ -366,15 +366,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index f1d56e8e0fc27e1a3f862c7e727b9544d6dc8bf9..638e0b722bdfffa13a2f4e268ceb09c4283080ba 100644 (file)
@@ -364,15 +364,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 9ae8c3f3ea2a17fd9a71333e5a9ff6b0cc43dc14..6355de0e494a2a4cadc7b74da579a3ab70a17399 100644 (file)
@@ -438,15 +438,7 @@ static void ch_handler(int sig)
 {
        int status = 0;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 13883e000007069e2887d6ab7e25bbb52c6753d1..dcf8dfc7e47b796e7d697ca9899661ac472a1a7b 100644 (file)
@@ -399,15 +399,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 42927d0130601c54fa910b5c55014d17b009e66b..bfd46d5e629935072557ccc1966d6824f88a344c 100644 (file)
@@ -328,15 +328,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index fdce76f9f140187f11cda328c4c2523e0f6c0059..f5a884c25c261d894e1be5a4a8127e8d1abe1ea4 100644 (file)
@@ -316,15 +316,7 @@ static void ch_handler(int sig)
        int status = 0;
 
        waitpid(-1, &status, 0);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 2d47c27d6845668361c31fe93f1ae94c3126110a..01cc8db12f77602f43055f0e90cffa9361c94b05 100644 (file)
@@ -328,15 +328,7 @@ static void ch_handler(int sig)
        int status = 0;
 
        waitpid(-1, &status, 0);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 2fe2927368f6cfeea419b02a923853075091b5d1..0894632c8d96602e1a164cab6eb1d2158d013c44 100644 (file)
@@ -228,8 +228,7 @@ static void ch_handler(int sig)
 {
        int status = 0;
        wait(&status);
-       if (WEXITSTATUS(status) != 0)
-               fail("Child died with status %d\n", WEXITSTATUS(status));
+       check_wait_status(status);
        return;
 }
 
index bc79c223f265a600b24950df57f28a33c2a6d0ef..1836f0777cf8a950745ed4f4322d5ed8bef9a4f8 100644 (file)
@@ -350,14 +350,7 @@ void doit(void)
                        if (done != child)
                                fail("who's that?! %d\n", done);
 
-                       if (WIFEXITED(status)) {
-                               if (WEXITSTATUS(status) != 0)
-                                       fail("child exited with status %d\n", WEXITSTATUS(status));
-                       } else if (WIFSIGNALED(status))
-                               fail("child stopped by signal %d\n",
-                                    WTERMSIG(status));
-                       else
-                               fail("child failed: %d\n", status);
+                       check_wait_status(status);
                }
        }
 
index 11fb6d578bcdd9461fc5c426ac0f3c3509bd14c4..5cfcac6b7e37c73ce2a4ba24e5429be857fc92a5 100644 (file)
@@ -254,15 +254,7 @@ void doit(void)
                if (done != child)
                        fail("who's that?! %d\n", done);
 
-               if (WIFEXITED(status)) {
-                       if (WEXITSTATUS(status) != 0)
-                               fail("child exited with status %d\n",
-                                    WEXITSTATUS(status));
-               } else if (WIFSIGNALED(status))
-                       fail("child stopped by signal %d\n",
-                            WTERMSIG(status));
-               else
-                       fail("child failed: %d\n", status);
+               check_wait_status(status);
        }
 
        gnutls_global_deinit();
index d93c283d3da06fe53c71b81eec8b7bbb75e28d03..c3f2c4cb17c92a3dc80291ad08fcb6a4790a0c67 100644 (file)
@@ -467,20 +467,7 @@ void doit(void)
                /* parent */
                client(sockets[0]);
                wait(&status);
-
-#if defined WIFEXITED && defined WEXITSTATUS
-               if (WIFEXITED(status) && WEXITSTATUS(status)) {
-                       fail("server: client failed with exit status %d\n",
-                            WEXITSTATUS(status));
-               }
-#endif
-
-#if defined WIFSIGNALED && defined WTERMSIG
-               if (WIFSIGNALED(status)) {
-                       fail("server: client failed with fatal signal %d\n", WTERMSIG(status));
-               }
-#endif
-
+               check_wait_status(status);
        } else
                server(sockets[1]);
 }
index d93bfaa7371bc0e1589507b83955c7780b6888ca..5be9d420ca923cebc098e6b39eef4cb250b76077 100644 (file)
@@ -442,9 +442,7 @@ static void start(void)
 
                server(fd[0]);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index be70795f260d3e3cb8a86277b6f5a0952e14b1f7..df818ae3dd190879e46397c6beaaccd67fa440fe 100644 (file)
@@ -413,8 +413,7 @@ void doit(void)
                                close(client_sds[j]);
                        server(server_sds, &resume_tests[i]);
                        wait(&status);
-                       if (WEXITSTATUS(status) != 0 || (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
-                               exit(1);
+                       check_wait_status(status);
                } else {
                        for (j = 0; j < SESSIONS; j++)
                                close(server_sds[j]);
index ed4f8aa6d296b7bcc4f14a3194641c31eb3d6f10..21455a4f2dcf2c2dcc8312151cc980789591f083 100644 (file)
@@ -693,8 +693,7 @@ void doit(void)
                        server(server_sds, &resume_tests[i]);
 
                        waitpid(child, &status, 0);
-                       if (WEXITSTATUS(status) != 0 || (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
-                               exit(1);
+                       check_wait_status(status);
                        global_stop();
                } else {
                        for (j = 0; j < SESSIONS; j++)
index c72d8a11a9ab3ba3a12b34e0863ab33ecbf63a81..b14d996d8daf6a176555dc54cb00053607f1dc0f 100644 (file)
@@ -295,15 +295,7 @@ static void ch_handler(int sig)
 {
        int status;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 35b42e0631da5fe6b24bd08cd5e1d70fc73ac200..753e0037e875b712bdfada553a0a7db3d90d7e21 100644 (file)
@@ -289,9 +289,7 @@ static void start(const char *prio)
                /* parent */
                server(fd[0], prio);
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                client(fd[1], prio);
                exit(0);
index 7ae56eda1ed5c31206042cd0e0344bf9aed55a96..f55f3ac4692874d73da04d84ff31f7901488c98e 100644 (file)
@@ -333,15 +333,7 @@ void doit(void)
                close(fd[1]);
                client(fd[0]);
                waitpid(child, &status, 0);
-
-               if (WEXITSTATUS(status) != 0 ||
-                   (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-                       if (WIFSIGNALED(status))
-                               fail("Child died with sigsegv\n");
-                       else
-                               fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               }
+               check_wait_status(status);
        } else {
                close(fd[0]);
                server(fd[1]);
index 293671dd712490ea86901611cda8c6668226d571..50a4a9d4b777f2bbb4901374de321260fd268837 100644 (file)
@@ -324,15 +324,7 @@ void doit(void)
                close(fd[1]);
                client(fd[0]);
                waitpid(child, &status, 0);
-
-               if (WEXITSTATUS(status) != 0 ||
-                   (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-                       if (WIFSIGNALED(status))
-                               fail("Child died with sigsegv\n");
-                       else
-                               fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               }
+               check_wait_status(status);
        } else {
                close(fd[0]);
                server(fd[1]);
index 8a4f2691d44d126f715d1721b096fa0b799df8f0..a9cf79ab28c406097afc423f89b6dff2097b18b6 100644 (file)
@@ -329,14 +329,7 @@ void doit(void)
                close(fd[1]);
                client(fd[0]);
                waitpid(child, &status, 0);
-               if (WEXITSTATUS(status) != 0 ||
-                   (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-                       if (WIFSIGNALED(status))
-                               fail("Child died with sigsegv\n");
-                       else
-                               fail("Child died with status %d\n",
-                                    WEXITSTATUS(status));
-               }
+               check_wait_status(status);
        } else {
                close(fd[0]);
                server(fd[1]);
index 6fe355e8c06c297aa723c96a0c8754bb3a261e44..6a0af66b629a512960c8426dbc4db50d95131963 100644 (file)
@@ -280,9 +280,7 @@ void doit(void)
                server(fd[0]);
 
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[0]);
                client(fd[1]);
index ca298d611f216f896855f68dca4ca2c18cc263bb..c352a11acb2c66cf96710aa66972cb7ed333f940 100644 (file)
@@ -430,15 +430,7 @@ static void ch_handler(int sig)
 {
        int status = 0;
        wait(&status);
-       if (WEXITSTATUS(status) != 0 ||
-           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
-               if (WIFSIGNALED(status))
-                       fail("Child died with sigsegv\n");
-               else
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
-               terminate();
-       }
+       check_wait_status(status);
        return;
 }
 
index 6a2f7c8abc8161b43b3912835573198ee8c3255e..de725e4edd4dbbe342bfcd143bdd446e66a6e5e9 100644 (file)
@@ -281,9 +281,7 @@ void doit(void)
                client(fd[1]);
 
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
        } else {
                close(fd[1]);
                server(fd[0]);
index 66ddb469e9ddbaaacd00f6eae0e43c3857364be5..bbee3d3bae50be70c227df0140cfbd8f99551356 100644 (file)
@@ -266,9 +266,7 @@ static void start(void)
                server(fd[1]);
 
                wait(&status);
-               if (WEXITSTATUS(status) != 0)
-                       fail("Child died with status %d\n",
-                            WEXITSTATUS(status));
+               check_wait_status(status);
                close(fd[1]);
        } else {
                close(fd[1]);
index fbd6b7a16023e07d8eff5537105d7c4026768004..7606a6dbb8a7383815087d2c2bec9be0a913d719 100644 (file)
@@ -72,11 +72,10 @@ void sec_sleep(int sec);
 
 typedef void callback_func(gnutls_session_t, void *priv);
 void test_cli_serv(gnutls_certificate_credentials_t server_cred,
-                   gnutls_certificate_credentials_t client_cred,
-                   const char *prio, const char *host,
-                   void *priv,
-                   callback_func *client_cb,
-                   callback_func *server_cb);
+                  gnutls_certificate_credentials_t client_cred,
+                  const char *prio, const char *host,
+                  void *priv,
+                  callback_func * client_cb, callback_func * server_cb);
 
 #define TMPNAME_SIZE 128
 char *get_tmpname(char s[TMPNAME_SIZE]);
@@ -84,4 +83,31 @@ char *get_tmpname(char s[TMPNAME_SIZE]);
 /* This must be implemented elsewhere. */
 extern void doit(void);
 
+/* calls fail() if status indicates an error  */
+inline static void _check_wait_status(int status, unsigned sigonly)
+{
+#if defined WEXITSTATUS && defined WIFSIGNALED
+       if (WEXITSTATUS(status) != 0 ||
+           (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+               if (WIFSIGNALED(status)) {
+                       fail("Child died with signal %d\n", WTERMSIG(status));
+               } else {
+                       if (!sigonly)
+                               fail("Child died with status %d\n",
+                                    WEXITSTATUS(status));
+               }
+       }
+#endif
+}
+
+inline static void check_wait_status(int status)
+{
+       _check_wait_status(status, 0);
+}
+
+inline static void check_wait_status_for_sig(int status)
+{
+       _check_wait_status(status, 1);
+}
+
 #endif                         /* UTILS_H */
index 3eb1e29cb868e089dbc7347ebb22d35a037f32b6..f9b5a7be6d339f6bf18d8e08b2afc9a11088e473 100644 (file)
@@ -391,20 +391,7 @@ void doit(void)
                close(sockets[1]);
                server(sockets[0]);
                wait(&status);
-
-#if defined WIFEXITED && defined WEXITSTATUS
-               if (WIFEXITED(status) && WEXITSTATUS(status)) {
-                       fail("server: client failed with exit status %d\n",
-                            WEXITSTATUS(status));
-               }
-#endif
-
-#if defined WIFSIGNALED && defined WTERMSIG
-               if (WIFSIGNALED(status)) {
-                       fail("server: client failed with fatal signal %d\n", WTERMSIG(status));
-               }
-#endif
-
+               check_wait_status(status);
        } else {
                close(sockets[0]);
                client(sockets[1]);