From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 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 dcvr.yhbt.net (Postfix) with ESMTPS id 1AB431F45F for ; Thu, 9 May 2019 17:26:40 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=ezFv7F5k3LL0Q+LJ sAaW1bk5424wQf1JDszMhH61OlZkrFeYGq4lgXYUr7wu/8Lci7rL/x9T0gw+B/Rh 0DQ1CWhXmj4lWMySR3DBCPUUmMwTHshCWuDw4uaFyNCD9nuFuc0L6yh2Zvro6NvW +HMLPkvi7SiodQvfcjMUGr17faE= 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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=pBOcz02rk+lKaylnY2hgnp +0xok=; b=V9vDY0LGZ01IGZYnOiArH0ypqvRXdr2Kd584vOaDOZFCN9r7PDFJzO 5vLKow1MTawywYIFnnNYS4w+4yVCndMNYFTGszgT5BpzWy6EOqtvmWg4a1SrJkqd fkGXvH67fCqOY2GMO9Xxfdttwj9ca+Y9p7bvhCGA3+ZzZ3US1y5TQ= Received: (qmail 9361 invoked by alias); 9 May 2019 17:26:37 -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 Received: (qmail 9350 invoked by uid 89); 9 May 2019 17:26:37 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-vs1-f67.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=89XJmzE1yoGzbvwdmsjw7Lex/IpCbigy07Yfyk9tbXQ=; b=wFDlw7X8RVXyNevwRcchLThJRVtxm6KAnC1Ihgc//rEp6IdcbpxbR1nV1DPtr77Pys +ms3f1+CR8FpWPGg7NXcVc0+kZIYm2hqVPE74sjIC0kd3s7XBI++9DHuKVm13tG3b164 CMN/ehaJgR5Y0a/xXtV6RJjFS4bmZ3LpoEQQbDscC6frhcCu8wjMb2v02C56u5Kx+zS/ CLbQgbKU0bqja8CfFjY2dDfsDFXJKXANqZ/zRuT3+OX3QyR2mHdg3B/AznqSmyYJPOXK zbo69k4FPlSy6dVGjRazvttHrerip5S8AVg4d92fok+uy6L2BV++/QbtG0giojuajLUa kRRg== Subject: Re: [PATCH 5/5] nptl/tst-abstime: Use libsupport To: libc-alpha@sourceware.org References: From: Adhemerval Zanella Openpgp: preference=signencrypt Message-ID: Date: Thu, 9 May 2019 14:26:32 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 02/05/2019 17:54, Mike Crowe wrote: > * nptl/tst-abstime.c: Use libsupport. LGTM, I will push it for you. Reviewed-by: Adhemerval Zanella > --- > ChangeLog | 4 +++- > nptl/tst-abstime.c | 70 ++++++++++++----------------------------------- > 2 files changed, 22 insertions(+), 52 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index 3b73b4a..12736f5 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,5 +1,9 @@ > 2019-05-02 Mike Crowe > > + * nptl/tst-abstime.c: Use libsupport. > + > +2019-05-02 Mike Crowe > + > * nptl/tst-rwlock6.c: Use libsupport. This also happens to fix a > small bug where only tv.tv_usec was checked which could cause an > erroneous pass if pthread_rwlock_timedrdlock incorrectly took more > diff --git a/nptl/tst-abstime.c b/nptl/tst-abstime.c > index 71610f8..56fb8a5 100644 > --- a/nptl/tst-abstime.c > +++ b/nptl/tst-abstime.c > @@ -20,6 +20,8 @@ > #include > #include > #include > +#include > +#include > > static pthread_cond_t c = PTHREAD_COND_INITIALIZER; > static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER; > @@ -31,67 +33,31 @@ 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; > - } > - > - 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); > + TEST_COMPARE (sem_timedwait (&sem, &t), -1); > + TEST_COMPARE (errno, ETIMEDOUT); > + > + xpthread_mutex_lock (&m1); > + xpthread_rwlock_wrlock (&rw1); > + xpthread_rwlock_rdlock (&rw2); > + xpthread_mutex_lock (&m2); > + pthread_t pth = xpthread_create (0, th, 0); > + TEST_COMPARE (pthread_cond_timedwait (&c, &m2, &t), ETIMEDOUT); > + xpthread_join (pth); > + return 0; > } > > - > -#define TEST_FUNCTION do_test () > -#include "../test-skeleton.c" > +#include >