From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 4C84E3858C2C; Mon, 3 Oct 2022 14:33:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C84E3858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664807594; bh=nA1voRSbQ+Z3gd61ArpgaX/ohYA9PBBOoLhFxeu3kBk=; h=From:To:Subject:Date:From; b=p54S3E0bilLdGEq0SxXA0J8z9dJfH9akYgaffc3Lyt9vQtlAcM8dmblddu38ewlJT ersQn/Dhn3klvP2yZQ7DYGz7mVGyH5f2Z0eOOaZl2jKPdgsn4RFsokf3CVXcaarteK Q+ZhKtT0NkOqy+fxS+OVB5KHB35zyhIRUEOBLgMA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] nptl: Convert tst-setuid2 to test-driver X-Act-Checkin: glibc X-Git-Author: Yu Chien Peter Lin X-Git-Refname: refs/heads/master X-Git-Oldrev: 3bea50ccbc925d4fc5f85ec402b6154cbe770b71 X-Git-Newrev: 365b3af67ecaf176b2e2678afe903bebce598fd7 Message-Id: <20221003143314.4C84E3858C2C@sourceware.org> Date: Mon, 3 Oct 2022 14:33:14 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=365b3af67ecaf176b2e2678afe903bebce598fd7 commit 365b3af67ecaf176b2e2678afe903bebce598fd7 Author: Yu Chien Peter Lin Date: Fri Sep 30 20:19:51 2022 +0800 nptl: Convert tst-setuid2 to test-driver Use and replace pthread calls to its xpthread equivalents. Signed-off-by: Yu Chien Peter Lin Reviewed-by: Adhemerval Zanella Diff: --- 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 #include #include +#include #include #include @@ -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