[2/4] nptl: Using libsupport for tst-cancel4*

Message ID 1493328657-8172-2-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series
  • [1/4] posix: Using libsupport for p{write,read}v tests
Related show

Commit Message

Adhemerval Zanella April 27, 2017, 9:30 p.m.
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

Comments

Wainer dos Santos Moschetta May 1, 2017, 3:31 p.m. | #1
On 27/04/2017 18:30, Adhemerval Zanella wrote:
> 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(-)

>

> 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 <support/test-driver.c>

> 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 <pthread.h>

>   

> +#include <support/check.h>

> +

>   /* 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");


Perhaps use...

FAIL_EXIT1 ("mkstemp failed: %m");

... like in many occurrences above. Or perhaps use:

FAIL_EXIT1 ("mkstemp: %m");

Unless the error string isn't important.

>         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");


Likewise.

>         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");


Likewise.

>         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");


really want to exit here?

>   

>         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");

> +


Wondering if wouldn't better replace above block with TEST_VERIFY_EXIT.  
Many occurrences throughout this patch have such as pattern though.

>     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");


Likewise, etc..

>   

>     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[] =
Adhemerval Zanella May 1, 2017, 4:34 p.m. | #2
On 01/05/2017 12:31, Wainer dos Santos Moschetta wrote:
>> -      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");

> 

> Perhaps use...

> 

> FAIL_EXIT1 ("mkstemp failed: %m");

> 

> ... like in many occurrences above. Or perhaps use:

> 

> FAIL_EXIT1 ("mkstemp: %m");

> 

> Unless the error string isn't important.


Ack, I will use the first definition for consistency.


>> @@ -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");

> 

> really want to exit here?


We need some fallback mechanism for the very unlikely case of having all the
files with the template name used on mkstemp already used to avoid an infinite
loop.  Usually 10 times should be suffice, since it should success on first
try.

>>   -  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");

>> +

> 

> Wondering if wouldn't better replace above block with TEST_VERIFY_EXIT.  Many occurrences throughout this patch have such as pattern though.


It really depends of what kind of error failure information we want to
inform.  FAIL_EXIT1 allows a variadic argument to allow more informative
strings, where TEST_VERIFY_EXIT just prints the 'stringification' of the
test passed as argument.  I think for mmap we may use, although for
open I prefer to still printing the resulting errno information (thorough
%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");

> 

> Likewise, etc..
Florian Weimer May 1, 2017, 5:18 p.m. | #3
On 04/27/2017 11:30 PM, Adhemerval Zanella wrote:
>         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");

>       }


Just a quick comment that we already have xpthread_barrier_wait and 
xmmap, so you could use them for error checking.  There are also strdup 
calls which should be xstrdup.

Thanks,
Florian
Adhemerval Zanella May 1, 2017, 5:41 p.m. | #4
On 01/05/2017 14:18, Florian Weimer wrote:
> On 04/27/2017 11:30 PM, Adhemerval Zanella wrote:

>>         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");

>>       }

> 

> Just a quick comment that we already have xpthread_barrier_wait and xmmap, so you could use them for error checking.  There are also strdup calls which should be xstrdup.


Right, I will change to use them.

Patch hide | download patch | download mbox

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 <support/test-driver.c>
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 <pthread.h>
 
+#include <support/check.h>
+
 /* 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[] =