From patchwork Fri Sep 30 12:19:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-Chien Peter Lin X-Patchwork-Id: 58211 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D74D03854810 for ; Fri, 30 Sep 2022 12:20:41 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from Atcsqr.andestech.com (60-248-80-70.hinet-ip.hinet.net [60.248.80.70]) by sourceware.org (Postfix) with ESMTPS id 82BCB3858CDB for ; Fri, 30 Sep 2022 12:20:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 82BCB3858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=andestech.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andestech.com Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 28UCKLDg080051; Fri, 30 Sep 2022 20:20:21 +0800 (+08) (envelope-from peterlin@andestech.com) Received: from atcfdc88.andestech.com (10.0.15.120) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Fri, 30 Sep 2022 20:20:20 +0800 From: Yu Chien Peter Lin To: Subject: [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver Date: Fri, 30 Sep 2022 20:19:51 +0800 Message-ID: <20220930121951.30671-2-peterlin@andestech.com> X-Mailer: git-send-email 2.34.1.390.g2ae0a9cb82 In-Reply-To: <20220930121951.30671-1-peterlin@andestech.com> References: <20220930121951.30671-1-peterlin@andestech.com> MIME-Version: 1.0 X-Originating-IP: [10.0.15.120] X-DNSRBL: X-MAIL: Atcsqr.andestech.com 28UCKLDg080051 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fw@deneb.enyo.de, ycliang@andestech.com, dylan@andestech.com, alankao@andestech.com, Yu Chien Peter Lin Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Use and replace pthread calls to its xpthread equivalents. Signed-off-by: Yu Chien Peter Lin Reviewed-by: Adhemerval Zanella --- 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