From patchwork Sun Mar 10 16:17:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Crowe X-Patchwork-Id: 31806 Received: (qmail 118931 invoked by alias); 10 Mar 2019 16:17:20 -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 118920 invoked by uid 89); 10 Mar 2019 16:17:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 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=1810, mistakes X-HELO: avasout02.plus.net X-CM-Score: 0.00 Date: Sun, 10 Mar 2019 16:17:15 +0000 From: Mike Crowe To: Adhemerval Zanella , libc-alpha@sourceware.org Subject: Re: [PATCH 2/7] nptl: Add POSIX-proposed sem_clockwait Message-ID: <20190310161715.ylqctrab7rqaum55@mcrowe.com> References: <47415e51fea8d960fc993cf0e0b8db6a19511d28.1551291557.git-series.mac@mcrowe.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) On Tuesday 05 March 2019 at 10:31:33 -0300, Adhemerval Zanella wrote: > On 27/02/2019 15:23, Mike Crowe wrote: > > diff --git a/nptl/tst-sem5.c b/nptl/tst-sem5.c > > index 2149ade..7f1031d 100644 > > --- a/nptl/tst-sem5.c > > +++ b/nptl/tst-sem5.c > > @@ -23,13 +23,15 @@ > > #include > > #include > > As for tst-sem13.c, I think it would be good to adapt to libsupport. Something like this (before I make the same mistakes on the others): Subject: [PATCH] nptl: Convert tst-sem5 to use libsupport * nptl/tst-sem5.c: Remove unused headers. Add . (do_test) Use libsupport test macros rather than hand-coded conditionals and error messages. Ensure that sem_init returns zero rather than not -1. Use rather than test-skeleton.c. --- nptl/tst-sem5.c | 53 ++++++++++------------------------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) -- 2.11.0 Thanks. Mike. diff --git a/nptl/tst-sem5.c b/nptl/tst-sem5.c index 2149adeb12..846813243b 100644 --- a/nptl/tst-sem5.c +++ b/nptl/tst-sem5.c @@ -18,11 +18,10 @@ #include #include -#include #include #include #include - +#include static int do_test (void) @@ -31,23 +30,9 @@ do_test (void) struct timespec ts; struct timeval tv; - if (sem_init (&s, 0, 1) == -1) - { - puts ("sem_init failed"); - return 1; - } - - if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1) - { - puts ("sem_wait failed"); - return 1; - } - - if (gettimeofday (&tv, NULL) != 0) - { - puts ("gettimeofday failed"); - return 1; - } + TEST_COMPARE (sem_init (&s, 0, 1), 0); + TEST_COMPARE (TEMP_FAILURE_RETRY (sem_wait (&s)), 0); + TEST_COMPARE (gettimeofday (&tv, NULL), 0); TIMEVAL_TO_TIMESPEC (&tv, &ts); @@ -60,34 +45,16 @@ do_test (void) } errno = 0; - if (TEMP_FAILURE_RETRY (sem_timedwait (&s, &ts)) != -1) - { - puts ("sem_timedwait succeeded"); - return 1; - } - if (errno != ETIMEDOUT) - { - printf ("sem_timedwait return errno = %d instead of ETIMEDOUT\n", - errno); - return 1; - } + TEST_COMPARE (TEMP_FAILURE_RETRY (sem_timedwait (&s, &ts)), -1); + TEST_COMPARE (errno, ETIMEDOUT); struct timespec ts2; - if (clock_gettime (CLOCK_REALTIME, &ts2) != 0) - { - puts ("clock_gettime failed"); - return 1; - } + TEST_COMPARE (clock_gettime (CLOCK_REALTIME, &ts2), 0); - if (ts2.tv_sec < ts.tv_sec - || (ts2.tv_sec == ts.tv_sec && ts2.tv_nsec < ts.tv_nsec)) - { - puts ("timeout too short"); - return 1; - } + TEST_VERIFY (ts2.tv_sec > ts.tv_sec + || (ts2.tv_sec == ts.tv_sec && ts2.tv_nsec > ts.tv_nsec)); return 0; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include