From patchwork Thu Apr 27 21:30:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 98297 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp299268qgf; Thu, 27 Apr 2017 14:31:44 -0700 (PDT) X-Received: by 10.99.5.146 with SMTP id 140mr8147372pgf.8.1493328704688; Thu, 27 Apr 2017 14:31:44 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b67si3825786pgc.84.2017.04.27.14.31.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Apr 2017 14:31:44 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-78921-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-78921-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-78921-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=CbYqZdPFit42Btp5fcZ9QaY8YJXpfrq +wOqCEM0hwFKIMP6sVqfXxt/h/ru00Xhsh6RQ3nVY6Sfx9WiW2XTZQf4DBVdpI/b H5w8rsI5l8gxtH9xjjumr6yh9zYdMC1vukIdW00MoUFdhkwdQ2isOtuHFzMqhchY 2ATuPn9SoIGY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=WGlfxTOrPbm1hzG0J5j1lo8PWUQ=; b=e/uPq uHBghogurhMKj9cOGJWV1YhyBZE9lUeuUpLVQsp8ejQTjjjqHPvRaGPKLHAc8W5+ RUDvEjn1T952yIFN0HI7FjsdFeL9b5Pk0kWbxdQJJot7B4xhn2VcqIOEAzGT/Kjr qkzluXoQyGIcZCfno5Rn0yoXvOA91cNIHzdKw8= Received: (qmail 12636 invoked by alias); 27 Apr 2017 21:31:14 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 12539 invoked by uid 89); 27 Apr 2017 21:31:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=1609, 73, 24, 7324, 5827 X-HELO: mail-qt0-f171.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=7e5eylq+g8VF2T9Rbl9Fmh3puS80tsiAdYS+ohdphVI=; b=NvlMenUbnd2dppkOdr8zvrWeN3h1Y36UvmQiq7f6t479k0PcLkOsa8q9xAVwXImPEj n/xQPhY4xLOgu9PzCUsxrGyJ+/t1Maqe9I+V1ORW3Cmcr9g43WpYIlYCsrVNp76PIwcx R+Dl39rZoEkm5DwqAmFPq/J6JHawfEs4m3+w/9I34eBjMtlJb8px2Vn/3YFH38jXS+GF tIHMQLnn2WzhN7/Snb9F3SU0sWb8xrxILNd5iwY1+oHUtsGyYvn9+zY/6j5XxfPkcZ2b e3VbQpnqxnDmXLumX4b0k7dIyKiHHK+MifbzVBW+sgf4quqzWI7R1Bvki2jmw2DIdM+I B7JA== X-Gm-Message-State: AN3rC/5MgNsztoZ2hwciTL0TxdqkhhQjXnASCK6xKs8wUkg7LszO5a/4 cETdCtgFZecknk7VxenfZQ== X-Received: by 10.237.62.150 with SMTP id n22mr7039456qtf.70.1493328663622; Thu, 27 Apr 2017 14:31:03 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Date: Thu, 27 Apr 2017 18:30:55 -0300 Message-Id: <1493328657-8172-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1493328657-8172-1-git-send-email-adhemerval.zanella@linaro.org> References: <1493328657-8172-1-git-send-email-adhemerval.zanella@linaro.org> Checked on x86_64-linux-gnu. * nptl/tst-cancel4-common.c: Use libsupport. * nptl/tst-cancel4-common.h: Likewise. * nptl/tst-cancel4.c (tf_read): Likewise. (tf_readv): Likewise. (tf_write): Likewise. (tf_writev): Likewise. (tf_sleep): Likewise. (tf_usleep): Likewise. (tf_nanosleep): Likewise. (tf_select): Likewise. (tf_pselect): Likewise. (tf_poll): Likewise. (tf_ppoll): Likewise. (tf_wait): Likewise. (tf_waitpid): Likewise. (tf_waitid): Likewise. (tf_sigpause): Likewise. (tf_sigsuspend): Likewise. (tf_sigwait): Likewise. (tf_sigwaitinfo): Likewise. (tf_sigtimedwait): Likewise. (tf_pause): Likewise. (tf_accept): Likewise. (tf_send): Likewise. (tf_recv): Likewise. (tf_recvfrom): Likewise. (tf_recvmsg): Likewise. (tf_open): Likewise. (tf_close): Likewise. (tf_pread): Likewise. (tf_pwrite): Likewise. (tf_preadv): Likewise. (tf_pwritev): Likewise. (tf_fsync): Likewise. (tf_fdatasync): Likewise. (tf_msync): Likewise. (tf_sendto): Likewise. (tf_sendmsg): Likewise. (tf_creat): Likewise. (tf_connect): Likewise. (tf_tcdrain): Likewise. (tf_msgrcv): Likewise. (tf_msgsnd): Likewise. * nptl/tst-cancel4_1.c (tf_sendmmsg): Likewise. * nptl/tst-cancel4_2.c (tf_recvmmsg): Likewise. --- ChangeLog | 46 +++ nptl/tst-cancel4-common.c | 3 +- nptl/tst-cancel4-common.h | 2 + nptl/tst-cancel4.c | 845 ++++++++++------------------------------------ nptl/tst-cancel4_1.c | 33 +- nptl/tst-cancel4_2.c | 33 +- 6 files changed, 248 insertions(+), 714 deletions(-) -- 2.7.4 diff --git a/nptl/tst-cancel4-common.c b/nptl/tst-cancel4-common.c index 3c57c99..eb32117 100644 --- a/nptl/tst-cancel4-common.c +++ b/nptl/tst-cancel4-common.c @@ -259,5 +259,4 @@ do_test (void) } #define TIMEOUT 60 -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include diff --git a/nptl/tst-cancel4-common.h b/nptl/tst-cancel4-common.h index 1964564..ffec6c8 100644 --- a/nptl/tst-cancel4-common.h +++ b/nptl/tst-cancel4-common.h @@ -19,6 +19,8 @@ #include +#include + /* Pipe descriptors. */ static int fds[2]; diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index 590ce0a..693c93f 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -88,23 +88,17 @@ tf_read (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp failed: %m"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); ssize_t s; pthread_cleanup_push (cl, NULL); @@ -114,9 +108,7 @@ tf_read (void *arg) pthread_cleanup_pop (0); - printf ("%s: read returns with %zd\n", __FUNCTION__, s); - - exit (1); + FAIL_EXIT1 ("read returns with %zd", s); } @@ -133,23 +125,17 @@ tf_readv (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp failed: %m"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); ssize_t s; pthread_cleanup_push (cl, NULL); @@ -160,9 +146,7 @@ tf_readv (void *arg) pthread_cleanup_pop (0); - printf ("%s: readv returns with %zd\n", __FUNCTION__, s); - - exit (1); + FAIL_EXIT1 ("readv returns with %zd", s); } @@ -179,23 +163,17 @@ tf_write (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp failed: %m"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); ssize_t s; pthread_cleanup_push (cl, NULL); @@ -206,9 +184,7 @@ tf_write (void *arg) pthread_cleanup_pop (0); - printf ("%s: write returns with %zd\n", __FUNCTION__, s); - - exit (1); + FAIL_EXIT1 ("write returns with %zd", s); } @@ -225,23 +201,17 @@ tf_writev (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp failed: %m"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); ssize_t s; pthread_cleanup_push (cl, NULL); @@ -253,9 +223,7 @@ tf_writev (void *arg) pthread_cleanup_pop (0); - printf ("%s: writev returns with %zd\n", __FUNCTION__, s); - - exit (1); + FAIL_EXIT1 ("writev returns with %zd", s); } @@ -264,19 +232,13 @@ tf_sleep (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -285,9 +247,7 @@ tf_sleep (void *arg) pthread_cleanup_pop (0); - printf ("%s: sleep returns\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("sleep returns"); } @@ -296,19 +256,13 @@ tf_usleep (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -317,9 +271,7 @@ tf_usleep (void *arg) pthread_cleanup_pop (0); - printf ("%s: usleep returns\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("usleep returns"); } @@ -328,19 +280,13 @@ tf_nanosleep (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -350,9 +296,7 @@ tf_nanosleep (void *arg) pthread_cleanup_pop (0); - printf ("%s: nanosleep returns\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("nanosleep returns"); } @@ -369,23 +313,17 @@ tf_select (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); fd_set rfs; FD_ZERO (&rfs); @@ -398,10 +336,7 @@ tf_select (void *arg) pthread_cleanup_pop (0); - printf ("%s: select returns with %d (%s)\n", __FUNCTION__, s, - strerror (errno)); - - exit (1); + FAIL_EXIT1 ("select returns with %d: %m", s); } @@ -418,23 +353,17 @@ tf_pselect (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); fd_set rfs; FD_ZERO (&rfs); @@ -447,10 +376,7 @@ tf_pselect (void *arg) pthread_cleanup_pop (0); - printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__, s, - strerror (errno)); - - exit (1); + FAIL_EXIT1 ("pselect returns with %d: %m", s); } @@ -467,23 +393,17 @@ tf_poll (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } }; @@ -494,10 +414,7 @@ tf_poll (void *arg) pthread_cleanup_pop (0); - printf ("%s: poll returns with %d (%s)\n", __FUNCTION__, s, - strerror (errno)); - - exit (1); + FAIL_EXIT1 ("poll returns with %d: %m", s); } @@ -514,23 +431,17 @@ tf_ppoll (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } }; @@ -541,10 +452,7 @@ tf_ppoll (void *arg) pthread_cleanup_pop (0); - printf ("%s: ppoll returns with %d (%s)\n", __FUNCTION__, s, - strerror (errno)); - - exit (1); + FAIL_EXIT1 ("ppoll returns with %d: %m", s); } @@ -553,10 +461,7 @@ tf_wait (void *arg) { pid_t pid = fork (); if (pid == -1) - { - puts ("fork failed"); - exit (1); - } + FAIL_EXIT1 ("fork: %m"); if (pid == 0) { @@ -575,18 +480,12 @@ tf_wait (void *arg) r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); int s; pthread_cleanup_push (cl, NULL); @@ -595,23 +494,16 @@ tf_wait (void *arg) pthread_cleanup_pop (0); - printf ("%s: wait returns with %d (%s)\n", __FUNCTION__, s, - strerror (errno)); - - exit (1); + FAIL_EXIT1 ("wait returns with %d: %m", s); } static void * tf_waitpid (void *arg) { - pid_t pid = fork (); if (pid == -1) - { - puts ("fork failed"); - exit (1); - } + FAIL_EXIT1 ("fork: %m"); if (pid == 0) { @@ -630,30 +522,21 @@ tf_waitpid (void *arg) r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); int s; - pthread_cleanup_push (cl, NULL); + pthread_cleanup_push (cl, NULL); s = waitpid (-1, NULL, 0); pthread_cleanup_pop (0); - printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__, s, - strerror (errno)); - - exit (1); + FAIL_EXIT1 ("waitpid returns with %d: %m", s); } @@ -662,10 +545,7 @@ tf_waitid (void *arg) { pid_t pid = fork (); if (pid == -1) - { - puts ("fork failed"); - exit (1); - } + FAIL_EXIT1 ("fork: %m"); if (pid == 0) { @@ -684,18 +564,12 @@ tf_waitid (void *arg) r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); int s; pthread_cleanup_push (cl, NULL); @@ -708,10 +582,7 @@ tf_waitid (void *arg) pthread_cleanup_pop (0); - printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__, s, - strerror (errno)); - - exit (1); + FAIL_EXIT1 ("waitid returns with %di: %m", s); } @@ -720,19 +591,13 @@ tf_sigpause (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -741,9 +606,7 @@ tf_sigpause (void *arg) pthread_cleanup_pop (0); - printf ("%s: sigpause returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("sigpause returned"); } @@ -752,19 +615,13 @@ tf_sigsuspend (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -776,9 +633,7 @@ tf_sigsuspend (void *arg) pthread_cleanup_pop (0); - printf ("%s: sigsuspend returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("sigsuspend returned"); } @@ -787,19 +642,13 @@ tf_sigwait (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } /* Block SIGUSR1. */ @@ -807,10 +656,7 @@ tf_sigwait (void *arg) sigemptyset (&mask); sigaddset (&mask, SIGUSR1); if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0) - { - printf ("%s: pthread_sigmask failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_sigmask"); int sig; pthread_cleanup_push (cl, NULL); @@ -820,9 +666,7 @@ tf_sigwait (void *arg) pthread_cleanup_pop (0); - printf ("%s: sigwait returned with signal %d\n", __FUNCTION__, sig); - - exit (1); + FAIL_EXIT1 ("sigwait returned with signal %d", sig); } @@ -831,19 +675,13 @@ tf_sigwaitinfo (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } /* Block SIGUSR1. */ @@ -851,10 +689,7 @@ tf_sigwaitinfo (void *arg) sigemptyset (&mask); sigaddset (&mask, SIGUSR1); if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0) - { - printf ("%s: pthread_sigmask failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_sigmask"); siginfo_t info; pthread_cleanup_push (cl, NULL); @@ -864,10 +699,7 @@ tf_sigwaitinfo (void *arg) pthread_cleanup_pop (0); - printf ("%s: sigwaitinfo returned with signal %d\n", __FUNCTION__, - info.si_signo); - - exit (1); + FAIL_EXIT1 ("sigwaitinfo returned with signal %d", info.si_signo); } @@ -876,19 +708,13 @@ tf_sigtimedwait (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } /* Block SIGUSR1. */ @@ -896,10 +722,7 @@ tf_sigtimedwait (void *arg) sigemptyset (&mask); sigaddset (&mask, SIGUSR1); if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0) - { - printf ("%s: pthread_sigmask failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_sigmask"); /* Wait for SIGUSR1. */ siginfo_t info; @@ -910,10 +733,7 @@ tf_sigtimedwait (void *arg) pthread_cleanup_pop (0); - printf ("%s: sigtimedwait returned with signal %d\n", __FUNCTION__, - info.si_signo); - - exit (1); + FAIL_EXIT1 ("sigtimedwait returned with signal %d", info.si_signo); } @@ -922,19 +742,13 @@ tf_pause (void *arg) { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -943,9 +757,7 @@ tf_pause (void *arg) pthread_cleanup_pop (0); - printf ("%s: pause returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("pause returned"); } @@ -959,25 +771,18 @@ tf_accept (void *arg) tempfd = socket (AF_UNIX, pf, 0); if (tempfd == -1) - { - printf ("%s: socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, %s, 0): %m", arg == NULL ? "SOCK_STREAM" + : "SOCK_DGRAM"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-1-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -993,19 +798,13 @@ tf_accept (void *arg) int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -1014,9 +813,7 @@ tf_accept (void *arg) pthread_cleanup_pop (0); - printf ("%s: accept returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("accept returned"); } @@ -1027,25 +824,17 @@ tf_send (void *arg) tempfd = socket (AF_UNIX, SOCK_STREAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -1057,34 +846,22 @@ tf_send (void *arg) tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m"); if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0) - { - printf ("%s: connect failed\n", __FUNCTION__); - exit(1); - } + FAIL_EXIT1 ("connect: %m"); unlink (sun.sun_path); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -1096,9 +873,7 @@ tf_send (void *arg) pthread_cleanup_pop (0); - printf ("%s: send returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("send returned"); } @@ -1109,25 +884,17 @@ tf_recv (void *arg) tempfd = socket (AF_UNIX, SOCK_STREAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-3-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -1139,34 +906,22 @@ tf_recv (void *arg) tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m"); if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0) - { - printf ("%s: connect failed\n", __FUNCTION__); - exit(1); - } + FAIL_EXIT1 ("connect: %m"); unlink (sun.sun_path); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -1177,9 +932,7 @@ tf_recv (void *arg) pthread_cleanup_pop (0); - printf ("%s: recv returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("recv returned"); } @@ -1190,25 +943,17 @@ tf_recvfrom (void *arg) tempfd = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-4-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -1220,26 +965,17 @@ tf_recvfrom (void *arg) tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -1252,9 +988,7 @@ tf_recvfrom (void *arg) pthread_cleanup_pop (0); - printf ("%s: recvfrom returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("recvfrom returned"); } @@ -1265,25 +999,17 @@ tf_recvmsg (void *arg) tempfd = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -1295,26 +1021,17 @@ tf_recvmsg (void *arg) tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -1336,9 +1053,7 @@ tf_recvmsg (void *arg) pthread_cleanup_pop (0); - printf ("%s: recvmsg returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("recvmsg returned"); } static void * @@ -1348,27 +1063,18 @@ tf_open (void *arg) { fifofd = mkfifo (fifoname, S_IWUSR | S_IRUSR); if (fifofd == -1) - { - printf ("%s: mkfifo failed: %m\n", __func__); - exit (1); - } + FAIL_EXIT1 ("mkfifo: %m"); } else { int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed: %m\n", __func__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed: %m\n", __func__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl_fifo, NULL); @@ -1376,9 +1082,7 @@ tf_open (void *arg) pthread_cleanup_pop (0); - printf ("%s: open returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("open returned"); } @@ -1393,25 +1097,16 @@ tf_close (void *arg) char fname[] = "/tmp/tst-cancel-fd-XXXXXX"; tempfd = mkstemp (fname); if (tempfd == -1) - { - printf ("%s: mkstemp failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("mkstemp"); unlink (fname); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1419,9 +1114,7 @@ tf_close (void *arg) pthread_cleanup_pop (0); - printf ("%s: close returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("close returned"); } @@ -1435,24 +1128,15 @@ tf_pread (void *arg) tempfd = open ("Makefile", O_RDONLY); if (tempfd == -1) - { - printf ("%s: cannot open Makefile\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1461,9 +1145,7 @@ tf_pread (void *arg) pthread_cleanup_pop (0); - printf ("%s: pread returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("pread returned"); } @@ -1478,25 +1160,16 @@ tf_pwrite (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = mkstemp (fname); if (tempfd == -1) - { - printf ("%s: mkstemp failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("mkstemp"); unlink (fname); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1505,9 +1178,7 @@ tf_pwrite (void *arg) pthread_cleanup_pop (0); - printf ("%s: pwrite returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("pwrite returned"); } static void * @@ -1524,22 +1195,16 @@ tf_preadv (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); ssize_t s; pthread_cleanup_push (cl, NULL); @@ -1550,9 +1215,7 @@ tf_preadv (void *arg) pthread_cleanup_pop (0); - printf ("%s: preadv returns with %zd\n", __FUNCTION__, s); - - exit (1); + FAIL_EXIT1 ("preadv returns with %zd", s); } static void * @@ -1569,22 +1232,16 @@ tf_pwritev (void *arg) char fname[] = "/tmp/tst-cancel4-fd-XXXXXX"; tempfd = fd = mkstemp (fname); if (fd == -1) - printf ("%s: mkstemp failed\n", __FUNCTION__); + FAIL_EXIT1 ("mkstemp"); unlink (fname); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); ssize_t s; pthread_cleanup_push (cl, NULL); @@ -1596,9 +1253,7 @@ tf_pwritev (void *arg) pthread_cleanup_pop (0); - printf ("%s: pwritev returns with %zd\n", __FUNCTION__, s); - - exit (1); + FAIL_EXIT1 ("pwritev returns with %zd", s); } static void * @@ -1611,24 +1266,15 @@ tf_fsync (void *arg) tempfd = open ("Makefile", O_RDONLY); if (tempfd == -1) - { - printf ("%s: cannot open Makefile\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1636,9 +1282,7 @@ tf_fsync (void *arg) pthread_cleanup_pop (0); - printf ("%s: fsync returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("fsync returned"); } @@ -1652,24 +1296,15 @@ tf_fdatasync (void *arg) tempfd = open ("Makefile", O_RDONLY); if (tempfd == -1) - { - printf ("%s: cannot open Makefile\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1677,9 +1312,7 @@ tf_fdatasync (void *arg) pthread_cleanup_pop (0); - printf ("%s: fdatasync returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("fdatasync returned"); } @@ -1693,30 +1326,19 @@ tf_msync (void *arg) tempfd = open ("Makefile", O_RDONLY); if (tempfd == -1) - { - printf ("%s: cannot open Makefile\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m"); + void *p = mmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd, 0); if (p == MAP_FAILED) - { - printf ("%s: mmap failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("mmap (NULL, 10, PROT_READ, MAP_SHARED, ...): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1724,9 +1346,7 @@ tf_msync (void *arg) pthread_cleanup_pop (0); - printf ("%s: msync returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("msync returned"); } @@ -1742,25 +1362,17 @@ tf_sendto (void *arg) tempfd = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-6-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -1771,24 +1383,15 @@ tf_sendto (void *arg) tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1800,9 +1403,7 @@ tf_sendto (void *arg) pthread_cleanup_pop (0); - printf ("%s: sendto returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("sendto returned"); } @@ -1818,25 +1419,17 @@ tf_sendmsg (void *arg) tempfd = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -1847,24 +1440,15 @@ tf_sendmsg (void *arg) tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1886,9 +1470,7 @@ tf_sendmsg (void *arg) pthread_cleanup_pop (0); - printf ("%s: sendmsg returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("sendmsg returned"); } @@ -1902,17 +1484,11 @@ tf_creat (void *arg) int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -1920,9 +1496,7 @@ tf_creat (void *arg) pthread_cleanup_pop (0); - printf ("%s: creat returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("creat returned"); } @@ -1938,25 +1512,17 @@ tf_connect (void *arg) tempfd = socket (AF_UNIX, SOCK_STREAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -1969,26 +1535,17 @@ tf_connect (void *arg) tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -1997,9 +1554,7 @@ tf_connect (void *arg) pthread_cleanup_pop (0); - printf ("%s: connect returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("connect returned"); } @@ -2013,19 +1568,13 @@ tf_tcdrain (void *arg) int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -2036,9 +1585,7 @@ tf_tcdrain (void *arg) pthread_cleanup_pop (0); - printf ("%s: tcdrain returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("tcdrain returned"); } @@ -2047,26 +1594,17 @@ tf_msgrcv (void *arg) { tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT); if (tempmsg == -1) - { - printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno)); - exit (1); - } + FAIL_EXIT1 ("msgget (IPC_PRIVATE, 0666 | IPC_CREAT): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } ssize_t s; @@ -2092,11 +1630,9 @@ tf_msgrcv (void *arg) pthread_cleanup_pop (0); - printf ("%s: msgrcv returned %zd with errno = %m\n", __FUNCTION__, s); - msgctl (tempmsg, IPC_RMID, NULL); - exit (1); + FAIL_EXIT1 ("msgrcv returned %zd", s); } @@ -2110,24 +1646,15 @@ tf_msgsnd (void *arg) tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT); if (tempmsg == -1) - { - printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno)); - exit (1); - } + FAIL_EXIT1 ("msgget (IPC_PRIVATE, 0666 | IPC_CREAT): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -2144,11 +1671,9 @@ tf_msgsnd (void *arg) pthread_cleanup_pop (0); - printf ("%s: msgsnd returned\n", __FUNCTION__); - msgctl (tempmsg, IPC_RMID, NULL); - exit (1); + FAIL_EXIT1 ("msgsnd returned"); } diff --git a/nptl/tst-cancel4_1.c b/nptl/tst-cancel4_1.c index 05b5f7b..0f41965 100644 --- a/nptl/tst-cancel4_1.c +++ b/nptl/tst-cancel4_1.c @@ -44,25 +44,17 @@ tf_sendmmsg (void *arg) tempfd = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -73,24 +65,15 @@ tf_sendmmsg (void *arg) tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); pthread_cleanup_push (cl, NULL); @@ -114,9 +97,7 @@ tf_sendmmsg (void *arg) pthread_cleanup_pop (0); - printf ("%s: sendmmsg returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("sendmmsg returned"); } struct cancel_tests tests[] = diff --git a/nptl/tst-cancel4_2.c b/nptl/tst-cancel4_2.c index f7a8797..1158609 100644 --- a/nptl/tst-cancel4_2.c +++ b/nptl/tst-cancel4_2.c @@ -39,25 +39,17 @@ tf_recvmmsg (void *arg) tempfd = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd == -1) - { - printf ("%s: first socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int tries = 0; do { if (++tries > 10) - { - printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); - } + FAIL_EXIT1 ("too many unsuccessful bind calls"); strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX"); if (mktemp (sun.sun_path) == NULL) - { - printf ("%s: cannot generate temp file name\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("cannot generate temp file name"); sun.sun_family = AF_UNIX; } @@ -69,26 +61,17 @@ tf_recvmmsg (void *arg) tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0); if (tempfd2 == -1) - { - printf ("%s: second socket call failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m"); int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); if (arg != NULL) { r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } + FAIL_EXIT1 ("pthread_barrier_wait"); } pthread_cleanup_push (cl, NULL); @@ -112,9 +95,7 @@ tf_recvmmsg (void *arg) pthread_cleanup_pop (0); - printf ("%s: recvmmsg returned\n", __FUNCTION__); - - exit (1); + FAIL_EXIT1 ("recvmmsg returned"); } struct cancel_tests tests[] =