From patchwork Thu Mar 28 18:31:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Crowe X-Patchwork-Id: 1068572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-100971-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mcrowe.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="DpGQQhfm"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44VYPQ5Qxcz9sPC for ; Fri, 29 Mar 2019 05:32:10 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; q=dns; s=default; b=Ce4tEfy9 sDAOgP3xj5hnZVZaur+I3+aVk5D0TiDe3leWt4esoduk+CIfbpAbCJfvfcTBAfza ORWwBzx9Vl9MoNzIBNAyGaVRUL+A1uIzS85sOsZeeFm44D4reXMx9x6CC/5ZkLGt 54Q/kSatGO+FuVDMIZlZPK0fHWgN6AvbahU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; s=default; bh=lOIXH9ZMy8puNo 8218KEokebi8s=; b=DpGQQhfmgoTAVHeT1iAqQHcO/jI7vfDv5UiAGRNm8K3eSq NKI8hML3MxXoKYqJeRPOzSteDgmz8fRRHQhcNbuhMF11WikTKTZqB3mk6A51fSq0 BGBeC8l98mOgKv/oJOodBz5I1lfAFnV5D2NKDxWzmJEQShy8UY7HWJu0eLKLA= Received: (qmail 63541 invoked by alias); 28 Mar 2019 18:31:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 63422 invoked by uid 89); 28 Mar 2019 18:31:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=sem X-HELO: avasout02.plus.net X-CM-Score: 0.00 From: Mike Crowe To: libc-alpha@sourceware.org Cc: Mike Crowe Subject: [PATCH 6/6] nptl/tst-abstime: Use libsupport Date: Thu, 28 Mar 2019 18:31:12 +0000 Message-Id: <2321a48f07ac0f4822b2fb14e86ff34f89c1007e.1553797867.git-series.mac@mcrowe.com> In-Reply-To: References: In-Reply-To: References: * nptl/tst-abstime.c: Use libsupport. Reviewed-by: Adhemerval Zanella --- ChangeLog | 4 +++- nptl/tst-abstime.c | 57 +++++++++-------------------------------------- 2 files changed, 16 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a03d42..f558bbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2019-03-28 Mike Crowe + * nptl/tst-abstime.c: Use libsupport. + +2019-03-28 Mike Crowe + * support/check.h: Introduce FAIL_THREAD_EXIT1 and FAIL_PRINT macros. diff --git a/nptl/tst-abstime.c b/nptl/tst-abstime.c index 71610f8..7d55fe3 100644 --- a/nptl/tst-abstime.c +++ b/nptl/tst-abstime.c @@ -20,6 +20,7 @@ #include #include #include +#include static pthread_cond_t c = PTHREAD_COND_INITIALIZER; static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER; @@ -31,67 +32,33 @@ static sem_t sem; static void * th (void *arg) { - long int res = 0; - int r; struct timespec t = { -2, 0 }; - r = pthread_mutex_timedlock (&m1, &t); - if (r != ETIMEDOUT) - { - puts ("pthread_mutex_timedlock did not return ETIMEDOUT"); - res = 1; - } - r = pthread_rwlock_timedrdlock (&rw1, &t); - if (r != ETIMEDOUT) - { - puts ("pthread_rwlock_timedrdlock did not return ETIMEDOUT"); - res = 1; - } - r = pthread_rwlock_timedwrlock (&rw2, &t); - if (r != ETIMEDOUT) - { - puts ("pthread_rwlock_timedwrlock did not return ETIMEDOUT"); - res = 1; - } - return (void *) res; + TEST_COMPARE (pthread_mutex_timedlock (&m1, &t), ETIMEDOUT); + TEST_COMPARE (pthread_rwlock_timedrdlock (&rw1, &t), ETIMEDOUT); + TEST_COMPARE (pthread_rwlock_timedwrlock (&rw2, &t), ETIMEDOUT); + return NULL; } static int do_test (void) { - int res = 0; - int r; struct timespec t = { -2, 0 }; pthread_t pth; sem_init (&sem, 0, 0); - r = sem_timedwait (&sem, &t); - if (r != -1 || errno != ETIMEDOUT) - { - puts ("sem_timedwait did not fail with ETIMEDOUT"); - res = 1; - } + TEST_COMPARE (sem_timedwait (&sem, &t), -1); + TEST_COMPARE (errno, ETIMEDOUT); pthread_mutex_lock (&m1); pthread_rwlock_wrlock (&rw1); pthread_rwlock_rdlock (&rw2); pthread_mutex_lock (&m2); if (pthread_create (&pth, 0, th, 0) != 0) - { - puts ("cannot create thread"); - return 1; - } - r = pthread_cond_timedwait (&c, &m2, &t); - if (r != ETIMEDOUT) - { - puts ("pthread_cond_timedwait did not return ETIMEDOUT"); - res = 1; - } - void *thres; - pthread_join (pth, &thres); - return res | (thres != NULL); + FAIL_RET ("cannot create thread"); + TEST_COMPARE (pthread_cond_timedwait (&c, &m2, &t), ETIMEDOUT); + pthread_join (pth, NULL); + return 0; } - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include