annotate tests/nap.h @ 17427:afd09cd62311

tests/nap.h: use an adaptive delay to avoid ctime update issues The recent change in nap.h (5191133e) decreased the probability of lost races to about a third, however such problems could still be observed in virtual machines and openSUSE's OBS. Instead of calulating the nap() time once and using it (together with a small correction multiplier), avoid the race alltogether by verifying on a reference file whether a timestamp difference has happened. Before, nap() detected the needed time once empirically and then used that delay (together with a small correction multiplier) in further calls. This problem has been reported and discussed several times, including guesses about possible kernel issues: https://lists.gnu.org/archive/html/bug-gnulib/2013-04/msg00071.html http://lists.gnu.org/archive/html/coreutils/2012-03/msg00088.html https://lists.gnu.org/archive/html/bug-gnulib/2011-11/msg00226.html http://bugs.gnu.org/12820 https://lists.gnu.org/archive/html/bug-gnulib/2010-11/msg00113.html https://lists.gnu.org/archive/html/bug-gnulib/2009-11/msg00007.html Now, nap() avoids the race alltogether by verifying on a reference file whether a timestamp difference has happened. * tests/nap.h (nap_fd): Define file descriptor variable for the witness file. (nap_works): Change return value to bool. Change passing the old file's status by value instead of by reference as this function does no longer update that timestamp; rename the function argument from st to old_st. Remove the local variables cdiff and mdiff because that function now returns true/false instead of the precise delay. (guess_delay): Remove function. (clear_tmp_file): Add new function to close and unlink the witness file. (nap): Instead of re-using the delay which has been calculated during the first call, avoid the race by actually verifying that a timestamp difference can be observed on the current file system. Use an adaptive approach for the delay to minimize execution time. Assert that the maximum delay is <= ~2 seconds, more precisely sum(2^n) from 0 to 30 = 2^31 - 1 = 2.1s. Use atexit to call clear_tmp_file when the process terminates.
author Bernhard Voelker <mail@bernhard-voelker.de>
date Wed, 05 Jun 2013 09:20:15 +0200
parents 3c592b4deb04
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12469
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
1 /* Assist in file system timestamp tests.
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 17155
diff changeset
2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
12469
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
3
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
7 (at your option) any later version.
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
8
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
12 GNU General Public License for more details.
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
13
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
16
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
17 /* Written by Eric Blake <ebb9@byu.net>, 2009. */
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
18
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
19 #ifndef GLTEST_NAP_H
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
20 # define GLTEST_NAP_H
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
21
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
22 # include <limits.h>
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
23 # include <stdbool.h>
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
24
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
25 /* File descriptor used for the witness file. */
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
26 static int nap_fd = -1;
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
27
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
28 /* Return A - B, in ns.
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
29 Return 0 if the true result would be negative.
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
30 Return INT_MAX if the true result would be greater than INT_MAX. */
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
31 static int
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
32 diff_timespec (struct timespec a, struct timespec b)
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
33 {
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
34 time_t as = a.tv_sec;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
35 time_t bs = b.tv_sec;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
36 int ans = a.tv_nsec;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
37 int bns = b.tv_nsec;
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
38
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
39 if (! (bs < as || (bs == as && bns < ans)))
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
40 return 0;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
41 if (as - bs <= INT_MAX / 1000000000)
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
42 {
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
43 int sdiff = (as - bs) * 1000000000;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
44 int usdiff = ans - bns;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
45 if (usdiff < INT_MAX - sdiff)
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
46 return sdiff + usdiff;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
47 }
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
48 return INT_MAX;
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
49 }
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
50
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
51 static void
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
52 get_stat (int fd, struct stat *st, int do_write)
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
53 {
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
54 if (do_write)
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
55 ASSERT (write (fd, "\n", 1) == 1);
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
56 ASSERT (fstat (fd, st) == 0);
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
57 }
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
58
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
59 /* Given a file whose descriptor is FD, see whether delaying by DELAY
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
60 nanoseconds causes a change in a file's ctime and mtime.
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
61 OLD_ST is the file's status, recently gotten. */
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
62 static bool
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
63 nap_works (int fd, int delay, struct stat old_st)
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
64 {
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
65 struct stat st;
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
66 struct timespec delay_spec;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
67 delay_spec.tv_sec = delay / 1000000000;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
68 delay_spec.tv_nsec = delay % 1000000000;
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
69 ASSERT (nanosleep (&delay_spec, 0) == 0);
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
70 get_stat (fd, &st, 1);
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
71
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
72 if ( diff_timespec (get_stat_ctime (&st), get_stat_ctime (&old_st))
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
73 && diff_timespec (get_stat_mtime (&st), get_stat_mtime (&old_st)))
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
74 return true;
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
75
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
76 return false;
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
77 }
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
78
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
79 #define TEMPFILE BASE "nap.tmp"
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
80
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
81 static void
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
82 clear_temp_file (void)
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
83 {
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
84 if (0 <= nap_fd)
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
85 {
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
86 ASSERT (close (nap_fd) != -1);
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
87 ASSERT (unlink (TEMPFILE) != -1);
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
88 }
17151
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
89 }
d20cbb4d40be test-utimens: speed up by taking shorter naps
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
90
12469
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
91 /* Sleep long enough to notice a timestamp difference on the file
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
92 system in the current directory. Use an adaptive approach, trying
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
93 to find the smallest delay which works on the current file system
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
94 to make the timestamp difference appear. Assert a maximum delay of
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
95 ~2 seconds, more precisely sum(2^n) from 0 to 30 = 2^31 - 1 = 2.1s.
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
96 Assumes that BASE is defined, and requires that the test module
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
97 depends on nanosleep. */
12469
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
98 static void
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
99 nap (void)
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
100 {
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
101 struct stat old_st;
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
102 static int delay = 1;
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
103
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
104 if (-1 == nap_fd)
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
105 {
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
106 atexit (clear_temp_file);
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
107 ASSERT ((nap_fd = creat (TEMPFILE, 0600)) != -1);
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
108 get_stat (nap_fd, &old_st, 0);
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
109 }
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
110 else
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
111 {
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
112 ASSERT (0 <= nap_fd);
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
113 get_stat (nap_fd, &old_st, 1);
17388
3c592b4deb04 utimensat-tests, etc.: try to fix some races
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
114 }
17427
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
115
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
116 if (1 < delay)
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
117 delay = delay / 2; /* Try half of the previous delay. */
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
118 ASSERT (0 < delay);
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
119
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
120 for ( ; delay <= 2147483647; delay = delay * 2)
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
121 if (nap_works (nap_fd, delay, old_st))
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
122 return;
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
123
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
124 /* Bummer: even the highest nap delay didn't work. */
afd09cd62311 tests/nap.h: use an adaptive delay to avoid ctime update issues
Bernhard Voelker <mail@bernhard-voelker.de>
parents: 17388
diff changeset
125 ASSERT (0);
12469
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
126 }
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
127
8b48f88c47f1 test-utimens: avoid spurious failure
Eric Blake <ebb9@byu.net>
parents:
diff changeset
128 #endif /* GLTEST_NAP_H */