public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Yu Chien Peter Lin <peterlin@andestech.com>, libc-alpha@sourceware.org
Cc: fw@deneb.enyo.de, ycliang@andestech.com, dylan@andestech.com,
	alankao@andestech.com
Subject: Re: [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver
Date: Fri, 30 Sep 2022 11:10:41 -0300	[thread overview]
Message-ID: <ab44d583-e88b-62b9-592e-c62ffce0971c@linaro.org> (raw)
In-Reply-To: <20220930121951.30671-2-peterlin@andestech.com>



On 30/09/22 09:19, Yu Chien Peter Lin wrote:
> Use <support/test-driver.c> and replace pthread calls to its xpthread
> equivalents.
> 
> Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  nptl/tst-setuid2.c | 52 +++++++++++++---------------------------------
>  1 file changed, 15 insertions(+), 37 deletions(-)
> 
> diff --git a/nptl/tst-setuid2.c b/nptl/tst-setuid2.c
> index aff3b1a97d..9b7799991c 100644
> --- a/nptl/tst-setuid2.c
> +++ b/nptl/tst-setuid2.c
> @@ -20,6 +20,7 @@
>  #include <signal.h>
>  #include <stdbool.h>
>  #include <stdio.h>
> +#include <support/xthread.h>
>  #include <sys/syscall.h>
>  #include <unistd.h>
>  
> @@ -36,30 +37,21 @@ static pthread_cond_t cond_recv;
>  static void *
>  thread_func (void *ctx __attribute__ ((unused)))
>  {
> -  int ret = pthread_mutex_lock (&mutex);
> -  if (ret != 0)
> -    FAIL ("pthread_mutex_lock (thread): %d", ret);
> -
> +  xpthread_mutex_lock (&mutex);
>    while (true)
>      {
>        if (func_sent != NULL)
>  	{
>  	  void (*func) (void) = func_sent;
> -	  ret = pthread_mutex_unlock (&mutex);
> -	  if (ret != 0)
> -	    FAIL ("pthread_mutex_unlock (thread): %d", ret);
> +	  xpthread_mutex_unlock (&mutex);
> +
>  	  func ();
> -	  ret = pthread_mutex_lock (&mutex);
> -	  if (ret != 0)
> -	    FAIL ("pthread_mutex_lock (thread): %d", ret);
> +
> +	  xpthread_mutex_lock (&mutex);
>  	  func_sent = NULL;
> -	  ret = pthread_cond_signal (&cond_recv);
> -	  if (ret != 0)
> -	    FAIL ("pthread_cond_signal (recv): %d", ret);
> +	  xpthread_cond_signal (&cond_recv);
>  	}
> -      ret = pthread_cond_wait (&cond_send, &mutex);
> -      if (ret != 0)
> -	FAIL ("pthread_cond_wait (send): %d", ret);
> +      xpthread_cond_wait (&cond_send, &mutex);
>      }
>    return NULL;
>  }
> @@ -67,31 +59,18 @@ thread_func (void *ctx __attribute__ ((unused)))
>  static void
>  run_on_thread (void (*func) (void))
>  {
> -  int ret = pthread_mutex_lock (&mutex);
> -  if (ret != 0)
> -    FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
> +  xpthread_mutex_lock (&mutex);
>    func_sent = func;
> -  ret = pthread_mutex_unlock (&mutex);
> -  if (ret != 0)
> -    FAIL ("pthread_mutex_unlock (%s): %d", __func__, ret);
> +  xpthread_mutex_unlock (&mutex);
>  
> -  ret = pthread_cond_signal (&cond_send);
> -  if (ret != 0)
> -    FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
> -
> -  ret = pthread_mutex_lock (&mutex);
> -  if (ret != 0)
> -    FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
> +  xpthread_cond_signal (&cond_send);
>  
> +  xpthread_mutex_lock (&mutex);
>    while (func_sent != NULL)
>      {
> -      ret = pthread_cond_wait (&cond_recv, &mutex);
> -      if (ret != 0)
> -	FAIL ("pthread_mutex_wait (%s): %d", __func__, ret);
> +      xpthread_cond_wait (&cond_recv, &mutex);
>      }
> -  ret = pthread_mutex_unlock (&mutex);
> -  if (ret != 0)
> -    FAIL ("pthread_mutex_unlock (%s): %d", __func__, ret);
> +  xpthread_mutex_unlock (&mutex);
>  }
>  
>  static void
> @@ -141,5 +120,4 @@ do_test (void)
>    return 0;
>  }
>  
> -#define TEST_FUNCTION do_test ()
> -#include "../test-skeleton.c"
> +#include <support/test-driver.c>

  reply	other threads:[~2022-09-30 14:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 12:19 [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper Yu Chien Peter Lin
2022-09-30 12:19 ` [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver Yu Chien Peter Lin
2022-09-30 14:10   ` Adhemerval Zanella Netto [this message]
2022-09-30 14:09 ` [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab44d583-e88b-62b9-592e-c62ffce0971c@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=alankao@andestech.com \
    --cc=dylan@andestech.com \
    --cc=fw@deneb.enyo.de \
    --cc=libc-alpha@sourceware.org \
    --cc=peterlin@andestech.com \
    --cc=ycliang@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).