From: Mike Crowe <mac@mcrowe.com>
To: libc-alpha@sourceware.org
Cc: Mike Crowe <mac@mcrowe.com>
Subject: [PATCH 3/5] nptl: Use recent additions to libsupport in tst-sem5
Date: Thu, 2 May 2019 21:54:33 +0100 [thread overview]
Message-ID: <6a2761067dfdedc077e90a3e0ca56473a8cd9934.1556830454.git-series.mac@mcrowe.com> (raw)
In-Reply-To: <cover.72079c6b2f406499e2ce64755c03c43050b698b8.1556830454.git-series.mac@mcrowe.com>
* 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 <mac@mcrowe.com>
+ * nptl/tst-sem5.c(do_test): Use xclock_gettime, timespec_add and
+ TEST_TIMESPEC_NOW_OR_AFTER from libsupport.
+
+2019-05-02 Mike Crowe <mac@mcrowe.com>
+
* 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 <unistd.h>
#include <sys/time.h>
#include <support/check.h>
+#include <support/timespec.h>
+#include <support/xtime.h>
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;
}
--
git-series 0.9.1
next prev parent reply other threads:[~2019-05-02 20:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-02 20:54 [PATCH 0/5] Add new helper functions+macros to libsupport and use them in some nptl tests Mike Crowe
2019-05-02 20:54 ` [PATCH 1/5] support: Add xclock_gettime Mike Crowe
2019-05-08 13:46 ` Florian Weimer
2019-05-08 14:22 ` Mike Crowe
2019-05-08 15:00 ` Florian Weimer
2019-05-08 16:17 ` Mike Crowe
2019-05-08 15:11 ` Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 2/5] nptl: Convert tst-cond11.c to use libsupport Mike Crowe
2019-05-09 16:39 ` Adhemerval Zanella
2019-05-09 17:08 ` Florian Weimer
2019-05-09 17:16 ` Adhemerval Zanella
2019-05-09 23:03 ` Joseph Myers
2019-05-10 9:42 ` Adhemerval Zanella
2019-05-10 12:20 ` Adhemerval Zanella
2019-05-10 12:22 ` Florian Weimer
2019-05-02 20:54 ` Mike Crowe [this message]
2019-05-09 16:55 ` [PATCH 3/5] nptl: Use recent additions to libsupport in tst-sem5 Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 4/5] nptl: Convert some rwlock tests to use libsupport Mike Crowe
2019-05-09 17:25 ` Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 5/5] nptl/tst-abstime: Use libsupport Mike Crowe
2019-05-09 17:26 ` Adhemerval Zanella
2019-05-03 20:38 ` [PATCH 0/5] Add new helper functions+macros to libsupport and use them in some nptl tests Mike Crowe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a2761067dfdedc077e90a3e0ca56473a8cd9934.1556830454.git-series.mac@mcrowe.com \
--to=mac@mcrowe.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).