diff options
author | Bruno Haible <bruno@clisp.org> | 2022-09-04 13:26:19 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2022-09-04 13:36:18 +0200 |
commit | bfcd9671696d17f980113eae2c6b2ebbe77115e6 (patch) | |
tree | 0d8617a3f965d2262717d92294ad8c93cce8dd70 /tests/test-nanosleep.c | |
parent | 73ea8982c33a42876b8cf66bb5a7bb0167451a50 (diff) | |
download | gnulib-bfcd9671696d17f980113eae2c6b2ebbe77115e6.tar.gz |
nanosleep: Work around bug on newer 32-bit mingw.
* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Test for 32-bit mingw bug.
* tests/test-nanosleep.c (main): Add another test.
* doc/posix-functions/nanosleep.texi: Mention the mingw bug.
Diffstat (limited to 'tests/test-nanosleep.c')
-rw-r--r-- | tests/test-nanosleep.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test-nanosleep.c b/tests/test-nanosleep.c index e7edeffc0e..c208161559 100644 --- a/tests/test-nanosleep.c +++ b/tests/test-nanosleep.c @@ -43,16 +43,27 @@ main (void) { struct timespec ts; + /* Check that negative nanosecond values cause failure. */ + ts.tv_sec = 1; + ts.tv_nsec = -1; + errno = 0; + ASSERT (nanosleep (&ts, NULL) == -1); + ASSERT (errno == EINVAL); + ts.tv_sec = 1000; ts.tv_nsec = -1; errno = 0; ASSERT (nanosleep (&ts, NULL) == -1); ASSERT (errno == EINVAL); + + /* Check that too large nanosecond values cause failure. */ + ts.tv_sec = 1000; ts.tv_nsec = 1000000000; errno = 0; ASSERT (nanosleep (&ts, NULL) == -1); ASSERT (errno == EINVAL); + /* Check successful call. */ ts.tv_sec = 0; ts.tv_nsec = 1; ASSERT (nanosleep (&ts, &ts) == 0); |