From patchwork Sun Apr 7 19:33:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Crowe X-Patchwork-Id: 32180 Received: (qmail 81252 invoked by alias); 7 Apr 2019 19:34:31 -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 81197 invoked by uid 89); 7 Apr 2019 19:34:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=500000000, half X-HELO: avasout03.plus.net X-CM-Score: 0.00 From: Mike Crowe To: libc-alpha@sourceware.org Cc: Mike Crowe Subject: [PATCH v2 4/6] nptl: Use recent additions to libsupport in tst-sem5 Date: Sun, 7 Apr 2019 20:33:53 +0100 Message-Id: <357cccd801fc058ed6524664e6c22fb4246f9409.1554665560.git-series.mac@mcrowe.com> In-Reply-To: References: In-Reply-To: References: * nptl/tst-sem5.c(do_test): Use xclock_gettime, timespec_add and TEST_TIMESPEC_NOW_OR_AFTER from libsupport. --- ChangeLog | 5 +++++ nptl/tst-sem5.c | 23 +++++------------------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5aafd69..c78863e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2019-04-06 Mike Crowe + * nptl/tst-sem5.c(do_test): Use xclock_gettime, timespec_add and + TEST_TIMESPEC_NOW_OR_AFTER from libsupport. + +2019-04-06 Mike Crowe + * nptl/tst-cond11.c: Use libsupport. 2019-04-06 Mike Crowe diff --git a/nptl/tst-sem5.c b/nptl/tst-sem5.c index 50ab6f9..7e722bd 100644 --- a/nptl/tst-sem5.c +++ b/nptl/tst-sem5.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include static int @@ -29,31 +31,16 @@ do_test (void) { sem_t s; struct timespec ts; - struct timeval tv; 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); - - /* We wait for half a second. */ - ts.tv_nsec += 500000000; - if (ts.tv_nsec >= 1000000000) - { - ++ts.tv_sec; - ts.tv_nsec -= 1000000000; - } + xclock_gettime (CLOCK_REALTIME, &ts); + ts = timespec_add (ts, make_timespec (0, TIMESPEC_HZ/2)); errno = 0; TEST_COMPARE (TEMP_FAILURE_RETRY (sem_timedwait (&s, &ts)), -1); TEST_COMPARE (errno, ETIMEDOUT); - - struct timespec ts2; - TEST_COMPARE (clock_gettime (CLOCK_REALTIME, &ts2), 0); - - TEST_VERIFY (ts2.tv_sec > ts.tv_sec - || (ts2.tv_sec == ts.tv_sec && ts2.tv_nsec > ts.tv_nsec)); + TEST_TIMESPEC_NOW_OR_AFTER (CLOCK_REALTIME, ts); return 0; }