about summary refs log tree commit diff
path: root/nptl/tst-cancel4.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-04-25 18:56:46 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-05-01 15:41:46 -0300
commitfa66f341a06f07a22737227e45f7ccdc615d4274 (patch)
tree0cd20ca586bc2f03b46b8d68f7370ef49a10b34d /nptl/tst-cancel4.c
parentffd6023885e71d026f18a8aec5b6610582e44150 (diff)
downloadglibc-fa66f341a06f07a22737227e45f7ccdc615d4274.tar.gz
glibc-fa66f341a06f07a22737227e45f7ccdc615d4274.tar.xz
glibc-fa66f341a06f07a22737227e45f7ccdc615d4274.zip
nptl: Using libsupport for tst-cancel4*
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.
Diffstat (limited to 'nptl/tst-cancel4.c')
-rw-r--r--nptl/tst-cancel4.c1077
1 files changed, 185 insertions, 892 deletions
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 590ce0ab5d..e66961f9a8 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -79,7 +79,6 @@ static void *
 tf_read  (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     fd = fds[0];
@@ -88,23 +87,13 @@ 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -114,9 +103,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);
 }
 
 
@@ -124,7 +111,6 @@ static void *
 tf_readv  (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     fd = fds[0];
@@ -133,23 +119,13 @@ 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -160,9 +136,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);
 }
 
 
@@ -170,7 +144,6 @@ static void *
 tf_write  (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     fd = fds[1];
@@ -179,23 +152,13 @@ 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -206,9 +169,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);
 }
 
 
@@ -216,7 +177,6 @@ static void *
 tf_writev  (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     fd = fds[1];
@@ -225,23 +185,13 @@ 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -253,31 +203,17 @@ 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);
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -285,31 +221,17 @@ tf_sleep (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sleep returns\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sleep returns");
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -317,31 +239,17 @@ tf_usleep (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: usleep returns\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("usleep returns");
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -350,9 +258,7 @@ tf_nanosleep (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: nanosleep returns\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("nanosleep returns");
 }
 
 
@@ -360,7 +266,6 @@ static void *
 tf_select (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     fd = fds[0];
@@ -369,23 +274,13 @@ 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 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   fd_set rfs;
   FD_ZERO (&rfs);
@@ -398,10 +293,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);
 }
 
 
@@ -409,7 +301,6 @@ static void *
 tf_pselect (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     fd = fds[0];
@@ -418,23 +309,13 @@ 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 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   fd_set rfs;
   FD_ZERO (&rfs);
@@ -447,10 +328,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);
 }
 
 
@@ -458,7 +336,6 @@ static void *
 tf_poll (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     fd = fds[0];
@@ -467,23 +344,13 @@ 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 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
 
@@ -494,10 +361,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);
 }
 
 
@@ -505,7 +369,6 @@ static void *
 tf_ppoll (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     fd = fds[0];
@@ -514,23 +377,13 @@ 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 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
 
@@ -541,10 +394,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 +403,7 @@ tf_wait (void *arg)
 {
   pid_t pid = fork ();
   if (pid == -1)
-    {
-      puts ("fork failed");
-      exit (1);
-    }
+    FAIL_EXIT1 ("fork: %m");
 
   if (pid == 0)
     {
@@ -566,27 +413,16 @@ tf_wait (void *arg)
       exit (0);
     }
 
-  int r;
   if (arg != NULL)
     {
       struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
       while (nanosleep (&ts, &ts) != 0)
 	continue;
 
-      r = pthread_barrier_wait (&b2);
-      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   int s;
   pthread_cleanup_push (cl, NULL);
@@ -595,23 +431,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)
     {
@@ -621,39 +450,25 @@ tf_waitpid (void *arg)
       exit (0);
     }
 
-  int r;
   if (arg != NULL)
     {
       struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
       while (nanosleep (&ts, &ts) != 0)
 	continue;
 
-      r = pthread_barrier_wait (&b2);
-      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   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 +477,7 @@ tf_waitid (void *arg)
 {
   pid_t pid = fork ();
   if (pid == -1)
-    {
-      puts ("fork failed");
-      exit (1);
-    }
+    FAIL_EXIT1 ("fork: %m");
 
   if (pid == 0)
     {
@@ -675,27 +487,16 @@ tf_waitid (void *arg)
       exit (0);
     }
 
-  int r;
   if (arg != NULL)
     {
       struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
       while (nanosleep (&ts, &ts) != 0)
 	continue;
 
-      r = pthread_barrier_wait (&b2);
-      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   int s;
   pthread_cleanup_push (cl, NULL);
@@ -708,32 +509,17 @@ 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 %d: %m", s);
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -741,31 +527,17 @@ tf_sigpause (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sigpause returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sigpause returned");
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -776,41 +548,23 @@ tf_sigsuspend (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sigsuspend returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sigsuspend returned");
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   /* Block SIGUSR1.  */
   sigset_t mask;
   sigemptyset (&mask);
   sigaddset (&mask, SIGUSR1);
-  if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
-    {
-      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
-      exit (1);
-    }
+  TEST_VERIFY_EXIT (pthread_sigmask (SIG_BLOCK, &mask, NULL) == 0);
 
   int sig;
   pthread_cleanup_push (cl, NULL);
@@ -820,41 +574,23 @@ 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);
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   /* Block SIGUSR1.  */
   sigset_t mask;
   sigemptyset (&mask);
   sigaddset (&mask, SIGUSR1);
-  if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
-    {
-      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
-      exit (1);
-    }
+  TEST_VERIFY_EXIT (pthread_sigmask (SIG_BLOCK, &mask, NULL) == 0);
 
   siginfo_t info;
   pthread_cleanup_push (cl, NULL);
@@ -864,42 +600,23 @@ 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);
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   /* Block SIGUSR1.  */
   sigset_t mask;
   sigemptyset (&mask);
   sigaddset (&mask, SIGUSR1);
-  if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
-    {
-      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
-      exit (1);
-    }
+  TEST_VERIFY_EXIT (pthread_sigmask (SIG_BLOCK, &mask, NULL) == 0);
 
   /* Wait for SIGUSR1.  */
   siginfo_t info;
@@ -910,32 +627,17 @@ 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);
 }
 
 
 static void *
 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -943,9 +645,7 @@ tf_pause (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: pause returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("pause returned");
 }
 
 
@@ -959,25 +659,16 @@ 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__);
-	}
+      TEST_VERIFY_EXIT (tries++ < 10);
 
       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);
-	}
+      TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
 
       sun.sun_family = AF_UNIX;
     }
@@ -991,22 +682,10 @@ tf_accept (void *arg)
 
   socklen_t len = sizeof (sun);
 
-  int r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1014,9 +693,7 @@ tf_accept (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: accept returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("accept returned");
 }
 
 
@@ -1027,25 +704,15 @@ 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__);
-	}
+      TEST_VERIFY_EXIT (tries++ < 10);
 
       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);
-	}
+      TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
 
       sun.sun_family = AF_UNIX;
     }
@@ -1057,35 +724,17 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1096,9 +745,7 @@ tf_send (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: send returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("send returned");
 }
 
 
@@ -1109,25 +756,15 @@ 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__);
-	}
+      TEST_VERIFY_EXIT (tries++ < 10);
 
       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);
-	}
+      TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
 
       sun.sun_family = AF_UNIX;
     }
@@ -1139,35 +776,17 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1177,9 +796,7 @@ tf_recv (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: recv returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("recv returned");
 }
 
 
@@ -1190,25 +807,15 @@ 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__);
-	}
+      TEST_VERIFY_EXIT (tries++ < 10);
 
       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);
-	}
+      TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
 
       sun.sun_family = AF_UNIX;
     }
@@ -1220,27 +827,12 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1252,9 +844,7 @@ tf_recvfrom (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: recvfrom returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("recvfrom returned");
 }
 
 
@@ -1265,25 +855,15 @@ 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__);
-	}
+      TEST_VERIFY_EXIT (tries++ < 10);
 
       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);
-	}
+      TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
 
       sun.sun_family = AF_UNIX;
     }
@@ -1295,27 +875,12 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1336,9 +901,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 +911,14 @@ 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);
-	}
+      xpthread_barrier_wait (&b2);
     }
 
-  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);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl_fifo, NULL);
 
@@ -1376,9 +926,7 @@ tf_open (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: open returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("open returned");
 }
 
 
@@ -1393,25 +941,12 @@ 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 failed: %m");
   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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1419,9 +954,7 @@ tf_close (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: close returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("close returned");
 }
 
 
@@ -1435,24 +968,11 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1461,9 +981,7 @@ tf_pread (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: pread returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("pread returned");
 }
 
 
@@ -1478,25 +996,12 @@ 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 failed: %m");
   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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1505,16 +1010,13 @@ tf_pwrite (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: pwrite returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("pwrite returned");
 }
 
 static void *
 tf_preadv (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     /* XXX If somebody can provide a portable test case in which preadv
@@ -1524,22 +1026,12 @@ 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 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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -1550,16 +1042,13 @@ 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 *
 tf_pwritev (void *arg)
 {
   int fd;
-  int r;
 
   if (arg == NULL)
     /* XXX If somebody can provide a portable test case in which pwritev
@@ -1569,22 +1058,12 @@ 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 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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -1596,9 +1075,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 +1088,11 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1636,9 +1100,7 @@ tf_fsync (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: fsync returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("fsync returned");
 }
 
 
@@ -1652,24 +1114,11 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1677,9 +1126,7 @@ tf_fdatasync (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: fdatasync returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("fdatasync returned");
 }
 
 
@@ -1693,30 +1140,13 @@ tf_msync (void *arg)
 
   tempfd = open ("Makefile", O_RDONLY);
   if (tempfd == -1)
-    {
-      printf ("%s: cannot open Makefile\n", __FUNCTION__);
-      exit (1);
-    }
-  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 ("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);
-    }
+  void *p = xmmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
+
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1724,9 +1154,7 @@ tf_msync (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: msync returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("msync returned");
 }
 
 
@@ -1742,25 +1170,15 @@ 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__);
-	}
+      TEST_VERIFY_EXIT (tries++ < 10);
 
       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);
-	}
+      TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
 
       sun.sun_family = AF_UNIX;
     }
@@ -1771,24 +1189,11 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1800,9 +1205,7 @@ tf_sendto (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sendto returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sendto returned");
 }
 
 
@@ -1818,25 +1221,15 @@ 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__);
-	}
+      TEST_VERIFY_EXIT (tries++ < 10);
 
       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);
-	}
+      TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
 
       sun.sun_family = AF_UNIX;
     }
@@ -1847,24 +1240,11 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1886,9 +1266,7 @@ tf_sendmsg (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sendmsg returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sendmsg returned");
 }
 
 
@@ -1900,19 +1278,9 @@ tf_creat (void *arg)
     // blocks we can enable this test to run in both rounds.
     abort ();
 
-  int r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1920,9 +1288,7 @@ tf_creat (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: creat returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("creat returned");
 }
 
 
@@ -1938,25 +1304,15 @@ 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__);
-	}
+      TEST_VERIFY_EXIT (tries++ < 10);
 
       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);
-	}
+      TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
 
       sun.sun_family = AF_UNIX;
     }
@@ -1969,27 +1325,12 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1997,9 +1338,7 @@ tf_connect (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: connect returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("connect returned");
 }
 
 
@@ -2011,22 +1350,10 @@ tf_tcdrain (void *arg)
     // blocks we can enable this test to run in both rounds.
     abort ();
 
-  int r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -2036,9 +1363,7 @@ tf_tcdrain (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: tcdrain returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("tcdrain returned");
 }
 
 
@@ -2047,27 +1372,12 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
   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);
-	}
-    }
+    xpthread_barrier_wait (&b2);
 
   ssize_t s;
 
@@ -2092,11 +1402,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 +1418,11 @@ 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);
-    }
+  xpthread_barrier_wait (&b2);
 
-  r = pthread_barrier_wait (&b2);
-  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+  xpthread_barrier_wait (&b2);
 
   pthread_cleanup_push (cl, NULL);
 
@@ -2144,11 +1439,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");
 }