From patchwork Thu May 2 20:54:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Crowe X-Patchwork-Id: 1094554 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-101716-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="e4o2JF6m"; 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 44w6wM5l1Vz9s9y for ; Fri, 3 May 2019 06:55:15 +1000 (AEST) 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:mime-version:content-transfer-encoding; q=dns; s= default; b=y4X0eUXGIQ9BuEhHGj7Qi3EckkTZqvOAvGbKEFKG9YpXlhf3cWCM/ fjXQZe8uTLKgel7ktvQFVJ72vqDWCpHdSHyMIiYF0/r9mqG0NmuUFtvsXkpO0eDQ fEfwlWsUwU5k70kWuuwVnXib6GmrkYAzAb7TARzDnfPgPEHAhRDvBU= 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:mime-version:content-transfer-encoding; s=default; bh=hM3SLpal0iVZGeZaKePBBxIQSHg=; b=e4o2JF6mFpKOjpdldi6dRfw5eCdZ TQlL984XFoqXMqs7jqwZ62HFVMulSLYLWGfyXiyWd5DvCqbCSP5WEL5G5VtoAbxR bohPsEygZmB5TyxnId6JmldjJBtGYeKc52ZLjwxaWiMGThc9CaH81WQPIfCs8iO4 pmhJtOHI8ShGpCU= Received: (qmail 121379 invoked by alias); 2 May 2019 20:54:56 -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 121345 invoked by uid 89); 2 May 2019 20:54:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 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=2931, H*r:smtp, HContent-Transfer-Encoding:8bit X-HELO: avasout02.plus.net X-CM-Score: 0.00 From: Mike Crowe To: libc-alpha@sourceware.org Cc: Mike Crowe Subject: [PATCH 3/5] nptl: Use recent additions to libsupport in tst-sem5 Date: Thu, 2 May 2019 21:54:33 +0100 Message-Id: <6a2761067dfdedc077e90a3e0ca56473a8cd9934.1556830454.git-series.mac@mcrowe.com> In-Reply-To: References: MIME-Version: 1.0 * 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 | 21 +++++---------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd0ef83..088076d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2019-05-02 Mike Crowe + * nptl/tst-sem5.c(do_test): Use xclock_gettime, timespec_add and + TEST_TIMESPEC_NOW_OR_AFTER from libsupport. + +2019-05-02 Mike Crowe + * support/timespec.h: New file. Provide timespec helper functions along with macros in the style of those in check.h. diff --git a/nptl/tst-sem5.c b/nptl/tst-sem5.c index 50ab6f9..396222b 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,18 @@ 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; }