summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-04-30 23:14:19 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-04-30 23:14:41 -0700
commit5191133e01659a051c21ea16765d9233b6a9fe47 (patch)
treef8532c7c7a50a47ac7a34e32c3578521afb08dd9 /modules
parent4bbfd284981dbc46d8a8c2116242aa7d5694b6af (diff)
downloadgnulib-5191133e01659a051c21ea16765d9233b6a9fe47.tar.gz
utimensat-tests, etc.: try to fix some races
Problem reported by Bernhard Voelker in <http://lists.gnu.org/archive/html/bug-gnulib/2013-04/msg00071.html>. I don't know whether this patch fixes that race condition, but it fixes *some* race conditions, so it should be a win. * modules/chown-tests (Depends-on): * modules/fchownat-tests (Depends-on): * modules/fdutimensat-tests (Depends-on): * modules/futimens-tests (Depends-on): * modules/lchown-tests (Depends-on): * modules/stat-time-tests (Depends-on): * modules/utimens-tests (Depends-on): * modules/utimensat-tests (Depends-on): Depend on nanosleep, not usleep. * modules/chown-tests (test_chown_LDADD): * modules/lchown-tests (test_lchown_LDADD): * modules/stat-time-tests (test_stat_time_LDADD): New macro. * modules/fchownat-tests (test_fchownat_LDADD): * modules/fdutimensat-tests (test_fdutimensat_LDADD): * modules/futimens-tests (test_futimens_LDADD): * modules/utimens-tests (test_utimens_LDADD): * modules/utimensat-tests (test_utimensat_LDADD): Add $(LIB_NANOSLEEP). * modules/stat-time-tests (Files): Add tests/nap.h. * tests/nap.h: Include <limits.h>, for INT_MAX. (lt_mtime): Remove. (diff_timespec): New function. (get_stat): Rename from get_mtime. All callers changed. (nap_works): Determine the needed delay by inspecting the file system's timestamp jumps; this should be more reliable. Look at both mtime and ctime, and take the maximum of the two jumps. (nap_works, guess_delay): Return a nanosecond cound, not a microsecond count. All callers changed. (nap_works, nap): Use nanosleep, not usleep. Check for nanosleep failure. (nap): Multiply the guess by 1.125, to accommodate the case where the file system's clock is a bit slower than nanosleep's clock. * tests/test-stat-time.c (BASE): New macro. Include nap.h. (nap): Remove; nap.h now defines this. This removes a duplicate implementation of 'nap'.
Diffstat (limited to 'modules')
-rw-r--r--modules/chown-tests3
-rw-r--r--modules/fchownat-tests4
-rw-r--r--modules/fdutimensat-tests5
-rw-r--r--modules/futimens-tests4
-rw-r--r--modules/lchown-tests3
-rw-r--r--modules/stat-time-tests4
-rw-r--r--modules/utimens-tests4
-rw-r--r--modules/utimensat-tests4
8 files changed, 18 insertions, 13 deletions
diff --git a/modules/chown-tests b/modules/chown-tests
index 467046de64..58b9656821 100644
--- a/modules/chown-tests
+++ b/modules/chown-tests
@@ -9,7 +9,7 @@ Depends-on:
ignore-value
lstat
mgetgroups
-usleep
+nanosleep
stat-time
stdbool
symlink
@@ -20,3 +20,4 @@ AC_CHECK_FUNCS_ONCE([getegid])
Makefile.am:
TESTS += test-chown
check_PROGRAMS += test-chown
+test_chown_LDADD = $(LDADD) $(LIB_NANOSLEEP)
diff --git a/modules/fchownat-tests b/modules/fchownat-tests
index 1b79d47f55..7b9991e6c6 100644
--- a/modules/fchownat-tests
+++ b/modules/fchownat-tests
@@ -9,9 +9,9 @@ tests/macros.h
Depends-on:
ignore-value
mgetgroups
+nanosleep
openat-h
progname
-usleep
stat-time
symlink
@@ -21,4 +21,4 @@ AC_CHECK_FUNCS_ONCE([getegid])
Makefile.am:
TESTS += test-fchownat
check_PROGRAMS += test-fchownat
-test_fchownat_LDADD = $(LDADD) @LIBINTL@
+test_fchownat_LDADD = $(LDADD) $(LIB_NANOSLEEP) @LIBINTL@
diff --git a/modules/fdutimensat-tests b/modules/fdutimensat-tests
index 9e3e77979a..a77ada4f06 100644
--- a/modules/fdutimensat-tests
+++ b/modules/fdutimensat-tests
@@ -10,10 +10,10 @@ tests/macros.h
Depends-on:
fcntl-h
ignore-value
+nanosleep
openat
timespec
dup
-usleep
utimecmp
configure.ac:
@@ -21,4 +21,5 @@ configure.ac:
Makefile.am:
TESTS += test-fdutimensat
check_PROGRAMS += test-fdutimensat
-test_fdutimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) @LIBINTL@
+test_fdutimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) \
+ $(LIB_NANOSLEEP) @LIBINTL@
diff --git a/modules/futimens-tests b/modules/futimens-tests
index a0bfb0b215..a1948eb2bb 100644
--- a/modules/futimens-tests
+++ b/modules/futimens-tests
@@ -10,9 +10,9 @@ Depends-on:
gettext
fcntl-h
ignore-value
+nanosleep
timespec
dup
-usleep
utimecmp
configure.ac:
@@ -20,4 +20,4 @@ configure.ac:
Makefile.am:
TESTS += test-futimens
check_PROGRAMS += test-futimens
-test_futimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) @LIBINTL@
+test_futimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@
diff --git a/modules/lchown-tests b/modules/lchown-tests
index 47aec96f6e..d7288fea6c 100644
--- a/modules/lchown-tests
+++ b/modules/lchown-tests
@@ -8,7 +8,7 @@ tests/macros.h
Depends-on:
ignore-value
mgetgroups
-usleep
+nanosleep
stat-time
stdbool
symlink
@@ -19,3 +19,4 @@ AC_CHECK_FUNCS_ONCE([getegid])
Makefile.am:
TESTS += test-lchown
check_PROGRAMS += test-lchown
+test_lchown_LDADD = $(LDADD) $(LIB_NANOSLEEP)
diff --git a/modules/stat-time-tests b/modules/stat-time-tests
index 2e72444b29..18843de5a6 100644
--- a/modules/stat-time-tests
+++ b/modules/stat-time-tests
@@ -1,13 +1,15 @@
Files:
tests/test-stat-time.c
tests/macros.h
+tests/nap.h
Depends-on:
+nanosleep
time
-usleep
configure.ac:
Makefile.am:
TESTS += test-stat-time
check_PROGRAMS += test-stat-time
+test_stat_time_LDADD = $(LDADD) $(LIB_NANOSLEEP)
diff --git a/modules/utimens-tests b/modules/utimens-tests
index 8c9160b020..76dad1b93b 100644
--- a/modules/utimens-tests
+++ b/modules/utimens-tests
@@ -11,9 +11,9 @@ Depends-on:
dup
gettext
ignore-value
+nanosleep
symlink
timespec
-usleep
utimecmp
configure.ac:
@@ -21,4 +21,4 @@ configure.ac:
Makefile.am:
TESTS += test-utimens
check_PROGRAMS += test-utimens
-test_utimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) @LIBINTL@
+test_utimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@
diff --git a/modules/utimensat-tests b/modules/utimensat-tests
index 6acfe89ad6..09e5cb15bf 100644
--- a/modules/utimensat-tests
+++ b/modules/utimensat-tests
@@ -9,8 +9,8 @@ tests/macros.h
Depends-on:
ignore-value
+nanosleep
timespec
-usleep
utimecmp
configure.ac:
@@ -18,4 +18,4 @@ configure.ac:
Makefile.am:
TESTS += test-utimensat
check_PROGRAMS += test-utimensat
-test_utimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) @LIBINTL@
+test_utimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@