forked from pool/coreutils
3e051dbc3b
- Try to fix nap() races in gnulib-tests. (coreutils-gnulib-tests-fix-nap-race.patch: add upstream patch) (coreutils-gnulib-tests-fix-nap-race-obs.patch: add openSUSE patch for OBS) OBS-URL: https://build.opensuse.org/request/show/176187 OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=186
1072 lines
40 KiB
Diff
1072 lines
40 KiB
Diff
From: Bernhard Voelker <mail@bernhard-voelker.de>
|
|
Date: Mon, 20 May 2013 00:03:20 +0200
|
|
Subject: [PATCH] gnulib-tests: utimensat-tests, etc.: try to fix some races
|
|
|
|
Some nap()-related tests often fail in OBS.
|
|
Cherry-pick the following attempt to avoid some races from
|
|
upstream gnulib:
|
|
http://git.sv.gnu.org/cgit/gnulib.git/commit/?id=5191133e
|
|
To be removed with coreutils-8.22.
|
|
|
|
---
|
|
ChangeLog | 5 +
|
|
Makefile.in | 7 +-
|
|
aclocal.m4 | 1
|
|
configure | 99 ---------------------------------
|
|
gnulib-tests/Makefile.in | 126 ++++++++++++++++++------------------------
|
|
gnulib-tests/gnulib.mk | 33 +++--------
|
|
gnulib-tests/nap.h | 113 ++++++++++++++++++++++++-------------
|
|
gnulib-tests/test-stat-time.c | 45 +--------------
|
|
gnulib-tests/test-usleep.c | 40 -------------
|
|
gnulib-tests/usleep.c | 58 -------------------
|
|
lib/config.hin | 9 ---
|
|
m4/gnulib-comp.m4 | 10 ---
|
|
m4/usleep.m4 | 45 ---------------
|
|
13 files changed, 151 insertions(+), 440 deletions(-)
|
|
delete mode 100644 gnulib-tests/test-usleep.c
|
|
delete mode 100644 gnulib-tests/usleep.c
|
|
delete mode 100644 m4/usleep.m4
|
|
|
|
Index: ChangeLog
|
|
===================================================================
|
|
--- ChangeLog.orig
|
|
+++ ChangeLog
|
|
@@ -1,3 +1,8 @@
|
|
+2013-05-17 Bernhard Voelker <mail@bernhard-voelker.de>
|
|
+
|
|
+ gnulib: cherry-pick gnulib commit 5191133e
|
|
+ utimensat-tests, etc.: try to fix some races
|
|
+
|
|
2013-02-14 Pádraig Brady <P@draigBrady.com>
|
|
|
|
version 8.21
|
|
Index: Makefile.in
|
|
===================================================================
|
|
--- Makefile.in.orig
|
|
+++ Makefile.in
|
|
@@ -346,10 +346,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/0
|
|
$(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkat.m4 \
|
|
$(top_srcdir)/m4/unlinkdir.m4 $(top_srcdir)/m4/unlocked-io.m4 \
|
|
$(top_srcdir)/m4/uptime.m4 $(top_srcdir)/m4/userspec.m4 \
|
|
- $(top_srcdir)/m4/usleep.m4 $(top_srcdir)/m4/utimbuf.m4 \
|
|
- $(top_srcdir)/m4/utimecmp.m4 $(top_srcdir)/m4/utimens.m4 \
|
|
- $(top_srcdir)/m4/utimensat.m4 $(top_srcdir)/m4/utimes.m4 \
|
|
- $(top_srcdir)/m4/vasnprintf.m4 \
|
|
+ $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimecmp.m4 \
|
|
+ $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimensat.m4 \
|
|
+ $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \
|
|
$(top_srcdir)/m4/vasprintf-posix.m4 \
|
|
$(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/version-etc.m4 \
|
|
$(top_srcdir)/m4/vfprintf-posix.m4 \
|
|
Index: aclocal.m4
|
|
===================================================================
|
|
--- aclocal.m4.orig
|
|
+++ aclocal.m4
|
|
@@ -1425,7 +1425,6 @@ m4_include([m4/unlinkdir.m4])
|
|
m4_include([m4/unlocked-io.m4])
|
|
m4_include([m4/uptime.m4])
|
|
m4_include([m4/userspec.m4])
|
|
-m4_include([m4/usleep.m4])
|
|
m4_include([m4/utimbuf.m4])
|
|
m4_include([m4/utimecmp.m4])
|
|
m4_include([m4/utimens.m4])
|
|
Index: configure
|
|
===================================================================
|
|
--- configure.orig
|
|
+++ configure
|
|
@@ -3876,7 +3876,6 @@ as_fn_append ac_func_list " sleep"
|
|
as_fn_append ac_func_list " catgets"
|
|
as_fn_append ac_func_list " symlinkat"
|
|
as_fn_append ac_func_list " shutdown"
|
|
-as_fn_append ac_func_list " usleep"
|
|
as_fn_append ac_func_list " wctob"
|
|
as_fn_append ac_header_list " hurd.h"
|
|
as_fn_append ac_header_list " paths.h"
|
|
@@ -7942,8 +7941,6 @@ $as_echo "$as_me: autobuild timestamp...
|
|
# Code from module useless-if-before-free:
|
|
# Code from module userspec:
|
|
# Code from module userspec-tests:
|
|
- # Code from module usleep:
|
|
- # Code from module usleep-tests:
|
|
# Code from module utimecmp:
|
|
# Code from module utimens:
|
|
# Code from module utimens-tests:
|
|
@@ -58743,102 +58740,6 @@ $as_echo "#define UNLINK_CANNOT_UNLINK_D
|
|
abs_aux_dir=`cd "$ac_aux_dir"; pwd`
|
|
|
|
|
|
-
|
|
-
|
|
-
|
|
- ac_fn_c_check_type "$LINENO" "useconds_t" "ac_cv_type_useconds_t" "$ac_includes_default"
|
|
-if test "x$ac_cv_type_useconds_t" = xyes; then :
|
|
-
|
|
-else
|
|
-
|
|
-$as_echo "#define useconds_t unsigned int" >>confdefs.h
|
|
-
|
|
-fi
|
|
-
|
|
- if test $ac_cv_func_usleep = no; then
|
|
- HAVE_USLEEP=0
|
|
- else
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usleep allows large arguments" >&5
|
|
-$as_echo_n "checking whether usleep allows large arguments... " >&6; }
|
|
-if ${gl_cv_func_usleep_works+:} false; then :
|
|
- $as_echo_n "(cached) " >&6
|
|
-else
|
|
- if test "$cross_compiling" = yes; then :
|
|
- case "$host_os" in
|
|
- # Guess yes on glibc systems.
|
|
- *-gnu*) gl_cv_func_usleep_works="guessing yes" ;;
|
|
- # If we don't know, assume the worst.
|
|
- *) gl_cv_func_usleep_works="guessing no" ;;
|
|
- esac
|
|
-
|
|
-else
|
|
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
-/* end confdefs.h. */
|
|
-
|
|
-#include <unistd.h>
|
|
-
|
|
-int
|
|
-main ()
|
|
-{
|
|
-return !!usleep (1000000);
|
|
- ;
|
|
- return 0;
|
|
-}
|
|
-_ACEOF
|
|
-if ac_fn_c_try_run "$LINENO"; then :
|
|
- gl_cv_func_usleep_works=yes
|
|
-else
|
|
- gl_cv_func_usleep_works=no
|
|
-fi
|
|
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
|
- conftest.$ac_objext conftest.beam conftest.$ac_ext
|
|
-fi
|
|
-
|
|
-fi
|
|
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_usleep_works" >&5
|
|
-$as_echo "$gl_cv_func_usleep_works" >&6; }
|
|
- case "$gl_cv_func_usleep_works" in
|
|
- *yes) ;;
|
|
- *)
|
|
- REPLACE_USLEEP=1
|
|
- ;;
|
|
- esac
|
|
- fi
|
|
-
|
|
- if test $HAVE_USLEEP = 0 || test $REPLACE_USLEEP = 1; then
|
|
-
|
|
-
|
|
-
|
|
-
|
|
-
|
|
-
|
|
-
|
|
-
|
|
- gltests_LIBOBJS="$gltests_LIBOBJS usleep.$ac_objext"
|
|
-
|
|
- fi
|
|
-
|
|
-
|
|
-
|
|
-
|
|
-
|
|
- if test "$GNULIB_USLEEP" != 1; then
|
|
- if test "$GNULIB_USLEEP" = 0; then
|
|
- GNULIB_USLEEP=$gl_module_indicator_condition
|
|
- else
|
|
- GNULIB_USLEEP="($GNULIB_USLEEP || $gl_module_indicator_condition)"
|
|
- fi
|
|
- fi
|
|
-
|
|
-
|
|
-
|
|
-
|
|
-
|
|
-$as_echo "#define GNULIB_TEST_USLEEP 1" >>confdefs.h
|
|
-
|
|
-
|
|
-
|
|
-
|
|
abs_aux_dir=`cd "$ac_aux_dir"; pwd`
|
|
|
|
|
|
Index: gnulib-tests/Makefile.in
|
|
===================================================================
|
|
--- gnulib-tests/Makefile.in.orig
|
|
+++ gnulib-tests/Makefile.in
|
|
@@ -198,19 +198,19 @@ TESTS = test-accept$(EXEEXT) test-file-h
|
|
test-uc_width$(EXEEXT) uniwidth/test-uc_width2.sh \
|
|
test-unlink$(EXEEXT) test-unlinkat$(EXEEXT) \
|
|
test-unsetenv$(EXEEXT) test-update-copyright.sh \
|
|
- test-userspec$(EXEEXT) test-usleep$(EXEEXT) \
|
|
- test-utimens$(EXEEXT) test-utimensat$(EXEEXT) \
|
|
- test-vasnprintf$(EXEEXT) test-vasprintf-posix$(EXEEXT) \
|
|
- test-vasprintf$(EXEEXT) test-vc-list-files-git.sh \
|
|
- test-vc-list-files-cvs.sh test-verify$(EXEEXT) test-verify.sh \
|
|
- test-version-etc.sh test-vfprintf-posix.sh \
|
|
- test-vprintf-posix.sh test-wchar$(EXEEXT) test-wcrtomb.sh \
|
|
- test-wcrtomb-w32-1.sh test-wcrtomb-w32-2.sh \
|
|
- test-wcrtomb-w32-3.sh test-wcrtomb-w32-4.sh \
|
|
- test-wcrtomb-w32-5.sh test-wctype-h$(EXEEXT) \
|
|
- test-wcwidth$(EXEEXT) test-write$(EXEEXT) test-xalloc-die.sh \
|
|
- test-xprintf-posix.sh test-xstrtoimax.sh test-xstrtol.sh \
|
|
- test-xstrtoumax.sh test-xvasprintf$(EXEEXT) test-yesno.sh
|
|
+ test-userspec$(EXEEXT) test-utimens$(EXEEXT) \
|
|
+ test-utimensat$(EXEEXT) test-vasnprintf$(EXEEXT) \
|
|
+ test-vasprintf-posix$(EXEEXT) test-vasprintf$(EXEEXT) \
|
|
+ test-vc-list-files-git.sh test-vc-list-files-cvs.sh \
|
|
+ test-verify$(EXEEXT) test-verify.sh test-version-etc.sh \
|
|
+ test-vfprintf-posix.sh test-vprintf-posix.sh \
|
|
+ test-wchar$(EXEEXT) test-wcrtomb.sh test-wcrtomb-w32-1.sh \
|
|
+ test-wcrtomb-w32-2.sh test-wcrtomb-w32-3.sh \
|
|
+ test-wcrtomb-w32-4.sh test-wcrtomb-w32-5.sh \
|
|
+ test-wctype-h$(EXEEXT) test-wcwidth$(EXEEXT) \
|
|
+ test-write$(EXEEXT) test-xalloc-die.sh test-xprintf-posix.sh \
|
|
+ test-xstrtoimax.sh test-xstrtol.sh test-xstrtoumax.sh \
|
|
+ test-xvasprintf$(EXEEXT) test-yesno.sh
|
|
XFAIL_TESTS =
|
|
noinst_PROGRAMS =
|
|
check_PROGRAMS = test-accept$(EXEEXT) test-file-has-acl$(EXEEXT) \
|
|
@@ -335,19 +335,18 @@ check_PROGRAMS = test-accept$(EXEEXT) te
|
|
test-uc_width$(EXEEXT) test-uc_width2$(EXEEXT) \
|
|
test-unlink$(EXEEXT) test-unlinkat$(EXEEXT) \
|
|
test-unsetenv$(EXEEXT) test-userspec$(EXEEXT) \
|
|
- test-usleep$(EXEEXT) test-utimens$(EXEEXT) \
|
|
- test-utimensat$(EXEEXT) test-vasnprintf$(EXEEXT) \
|
|
- test-vasprintf-posix$(EXEEXT) test-vasprintf$(EXEEXT) \
|
|
- test-verify$(EXEEXT) test-version-etc$(EXEEXT) \
|
|
- test-vfprintf-posix$(EXEEXT) test-vprintf-posix$(EXEEXT) \
|
|
- test-wchar$(EXEEXT) test-wcrtomb$(EXEEXT) \
|
|
- test-wcrtomb-w32$(EXEEXT) test-wctype-h$(EXEEXT) \
|
|
- test-wcwidth$(EXEEXT) test-write$(EXEEXT) \
|
|
- test-xalloc-die$(EXEEXT) test-xfprintf-posix$(EXEEXT) \
|
|
- test-xprintf-posix$(EXEEXT) test-xstrtoimax$(EXEEXT) \
|
|
- test-xstrtol$(EXEEXT) test-xstrtoul$(EXEEXT) \
|
|
- test-xstrtoumax$(EXEEXT) test-xvasprintf$(EXEEXT) \
|
|
- test-yesno$(EXEEXT)
|
|
+ test-utimens$(EXEEXT) test-utimensat$(EXEEXT) \
|
|
+ test-vasnprintf$(EXEEXT) test-vasprintf-posix$(EXEEXT) \
|
|
+ test-vasprintf$(EXEEXT) test-verify$(EXEEXT) \
|
|
+ test-version-etc$(EXEEXT) test-vfprintf-posix$(EXEEXT) \
|
|
+ test-vprintf-posix$(EXEEXT) test-wchar$(EXEEXT) \
|
|
+ test-wcrtomb$(EXEEXT) test-wcrtomb-w32$(EXEEXT) \
|
|
+ test-wctype-h$(EXEEXT) test-wcwidth$(EXEEXT) \
|
|
+ test-write$(EXEEXT) test-xalloc-die$(EXEEXT) \
|
|
+ test-xfprintf-posix$(EXEEXT) test-xprintf-posix$(EXEEXT) \
|
|
+ test-xstrtoimax$(EXEEXT) test-xstrtol$(EXEEXT) \
|
|
+ test-xstrtoul$(EXEEXT) test-xstrtoumax$(EXEEXT) \
|
|
+ test-xvasprintf$(EXEEXT) test-yesno$(EXEEXT)
|
|
@POSIX_SPAWN_PORTED_TRUE@am__append_1 = test-posix_spawn1 test-posix_spawn2
|
|
@POSIX_SPAWN_PORTED_TRUE@am__append_2 = test-posix_spawn1 test-posix_spawn2
|
|
@POSIX_SPAWN_PORTED_TRUE@am__append_3 = test-posix_spawn1.sh \
|
|
@@ -553,10 +552,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/0
|
|
$(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkat.m4 \
|
|
$(top_srcdir)/m4/unlinkdir.m4 $(top_srcdir)/m4/unlocked-io.m4 \
|
|
$(top_srcdir)/m4/uptime.m4 $(top_srcdir)/m4/userspec.m4 \
|
|
- $(top_srcdir)/m4/usleep.m4 $(top_srcdir)/m4/utimbuf.m4 \
|
|
- $(top_srcdir)/m4/utimecmp.m4 $(top_srcdir)/m4/utimens.m4 \
|
|
- $(top_srcdir)/m4/utimensat.m4 $(top_srcdir)/m4/utimes.m4 \
|
|
- $(top_srcdir)/m4/vasnprintf.m4 \
|
|
+ $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimecmp.m4 \
|
|
+ $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimensat.m4 \
|
|
+ $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \
|
|
$(top_srcdir)/m4/vasprintf-posix.m4 \
|
|
$(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/version-etc.m4 \
|
|
$(top_srcdir)/m4/vfprintf-posix.m4 \
|
|
@@ -693,9 +691,7 @@ test_chdir_DEPENDENCIES = libtests.a ../
|
|
$(am__DEPENDENCIES_1)
|
|
test_chown_SOURCES = test-chown.c
|
|
test_chown_OBJECTS = test-chown.$(OBJEXT)
|
|
-test_chown_LDADD = $(LDADD)
|
|
-test_chown_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \
|
|
- $(am__DEPENDENCIES_1)
|
|
+test_chown_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
|
|
test_cloexec_SOURCES = test-cloexec.c
|
|
test_cloexec_OBJECTS = test-cloexec.$(OBJEXT)
|
|
test_cloexec_LDADD = $(LDADD)
|
|
@@ -784,7 +780,8 @@ test_fchmodat_OBJECTS = test-fchmodat.$(
|
|
test_fchmodat_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
|
test_fchownat_SOURCES = test-fchownat.c
|
|
test_fchownat_OBJECTS = test-fchownat.$(OBJEXT)
|
|
-test_fchownat_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
|
+test_fchownat_DEPENDENCIES = $(am__DEPENDENCIES_2) \
|
|
+ $(am__DEPENDENCIES_1)
|
|
test_fclose_SOURCES = test-fclose.c
|
|
test_fclose_OBJECTS = test-fclose.$(OBJEXT)
|
|
test_fclose_LDADD = $(LDADD)
|
|
@@ -820,7 +817,7 @@ test_fdopendir_DEPENDENCIES = $(am__DEPE
|
|
test_fdutimensat_SOURCES = test-fdutimensat.c
|
|
test_fdutimensat_OBJECTS = test-fdutimensat.$(OBJEXT)
|
|
test_fdutimensat_DEPENDENCIES = $(am__DEPENDENCIES_2) \
|
|
- $(am__DEPENDENCIES_1)
|
|
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
|
test_fflush_SOURCES = test-fflush.c
|
|
test_fflush_OBJECTS = test-fflush.$(OBJEXT)
|
|
test_fflush_LDADD = $(LDADD)
|
|
@@ -1005,7 +1002,7 @@ test_ftruncate_DEPENDENCIES = libtests.a
|
|
test_futimens_SOURCES = test-futimens.c
|
|
test_futimens_OBJECTS = test-futimens.$(OBJEXT)
|
|
test_futimens_DEPENDENCIES = $(am__DEPENDENCIES_2) \
|
|
- $(am__DEPENDENCIES_1)
|
|
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
|
test_fwrite_SOURCES = test-fwrite.c
|
|
test_fwrite_OBJECTS = test-fwrite.$(OBJEXT)
|
|
test_fwrite_LDADD = $(LDADD)
|
|
@@ -1156,9 +1153,7 @@ test_langinfo_DEPENDENCIES = libtests.a
|
|
libtests.a $(am__DEPENDENCIES_1)
|
|
test_lchown_SOURCES = test-lchown.c
|
|
test_lchown_OBJECTS = test-lchown.$(OBJEXT)
|
|
-test_lchown_LDADD = $(LDADD)
|
|
-test_lchown_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \
|
|
- $(am__DEPENDENCIES_1)
|
|
+test_lchown_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
|
|
test_link_SOURCES = test-link.c
|
|
test_link_OBJECTS = test-link.$(OBJEXT)
|
|
test_link_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
|
@@ -1564,9 +1559,8 @@ test_stat_OBJECTS = test-stat.$(OBJEXT)
|
|
test_stat_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
|
|
test_stat_time_SOURCES = test-stat-time.c
|
|
test_stat_time_OBJECTS = test-stat-time.$(OBJEXT)
|
|
-test_stat_time_LDADD = $(LDADD)
|
|
-test_stat_time_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \
|
|
- libtests.a $(am__DEPENDENCIES_1)
|
|
+test_stat_time_DEPENDENCIES = $(am__DEPENDENCIES_2) \
|
|
+ $(am__DEPENDENCIES_1)
|
|
test_statat_SOURCES = test-statat.c
|
|
test_statat_OBJECTS = test-statat.$(OBJEXT)
|
|
test_statat_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
|
@@ -1787,19 +1781,14 @@ test_unsetenv_DEPENDENCIES = libtests.a
|
|
test_userspec_SOURCES = test-userspec.c
|
|
test_userspec_OBJECTS = test-userspec.$(OBJEXT)
|
|
test_userspec_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
|
-test_usleep_SOURCES = test-usleep.c
|
|
-test_usleep_OBJECTS = test-usleep.$(OBJEXT)
|
|
-test_usleep_LDADD = $(LDADD)
|
|
-test_usleep_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \
|
|
- $(am__DEPENDENCIES_1)
|
|
test_utimens_SOURCES = test-utimens.c
|
|
test_utimens_OBJECTS = test-utimens.$(OBJEXT)
|
|
test_utimens_DEPENDENCIES = $(am__DEPENDENCIES_2) \
|
|
- $(am__DEPENDENCIES_1)
|
|
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
|
test_utimensat_SOURCES = test-utimensat.c
|
|
test_utimensat_OBJECTS = test-utimensat.$(OBJEXT)
|
|
test_utimensat_DEPENDENCIES = $(am__DEPENDENCIES_2) \
|
|
- $(am__DEPENDENCIES_1)
|
|
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
|
test_vasnprintf_SOURCES = test-vasnprintf.c
|
|
test_vasnprintf_OBJECTS = test-vasnprintf.$(OBJEXT)
|
|
test_vasnprintf_LDADD = $(LDADD)
|
|
@@ -1990,7 +1979,7 @@ SOURCES = $(libtests_a_SOURCES) $(EXTRA_
|
|
$(test_u8_mbtoucr_SOURCES) $(test_u8_uctomb_SOURCES) \
|
|
$(test_uc_width_SOURCES) $(test_uc_width2_SOURCES) \
|
|
test-uname.c test-unistd.c test-unlink.c test-unlinkat.c \
|
|
- test-unsetenv.c test-userspec.c test-usleep.c test-utimens.c \
|
|
+ test-unsetenv.c test-userspec.c test-utimens.c \
|
|
test-utimensat.c test-vasnprintf.c test-vasprintf.c \
|
|
test-vasprintf-posix.c test-verify.c test-version-etc.c \
|
|
test-vfprintf-posix.c test-vprintf-posix.c test-wchar.c \
|
|
@@ -2077,7 +2066,7 @@ DIST_SOURCES = $(libtests_a_SOURCES) $(E
|
|
$(test_u8_mbtoucr_SOURCES) $(test_u8_uctomb_SOURCES) \
|
|
$(test_uc_width_SOURCES) $(test_uc_width2_SOURCES) \
|
|
test-uname.c test-unistd.c test-unlink.c test-unlinkat.c \
|
|
- test-unsetenv.c test-userspec.c test-usleep.c test-utimens.c \
|
|
+ test-unsetenv.c test-userspec.c test-utimens.c \
|
|
test-utimensat.c test-vasnprintf.c test-vasprintf.c \
|
|
test-vasprintf-posix.c test-verify.c test-version-etc.c \
|
|
test-vfprintf-posix.c test-vprintf-posix.c test-wchar.c \
|
|
@@ -3725,7 +3714,7 @@ EXTRA_DIST = accept.c w32sock.h test-acc
|
|
test-spawn-pipe.sh test-spawn-pipe-main.c \
|
|
test-spawn-pipe-child.c macros.h test-spawn.c test-stat.h \
|
|
test-stat.c signature.h macros.h test-stat-time.c macros.h \
|
|
- test-statat.c test-stdalign.c macros.h test-stdbool.c \
|
|
+ nap.h test-statat.c test-stdalign.c macros.h test-stdbool.c \
|
|
test-stddef.c test-stdint.c test-stdio.c test-stdlib.c \
|
|
test-sys_wait.h test-strchrnul.c signature.h macros.h \
|
|
test-strerror.c signature.h macros.h strerror_r.c \
|
|
@@ -3753,10 +3742,9 @@ EXTRA_DIST = accept.c w32sock.h test-acc
|
|
test-unlink.c signature.h macros.h test-unlinkat.c \
|
|
test-rmdir.h test-unlink.h signature.h macros.h unlinkdir.h \
|
|
test-unsetenv.c signature.h macros.h test-update-copyright.sh \
|
|
- test-userspec.c usleep.c test-usleep.c signature.h macros.h \
|
|
- nap.h test-futimens.h test-lutimens.h test-utimens.h \
|
|
- test-utimens-common.h test-utimens.c macros.h nap.h \
|
|
- test-lutimens.h test-utimens.h test-utimens-common.h \
|
|
+ test-userspec.c nap.h test-futimens.h test-lutimens.h \
|
|
+ test-utimens.h test-utimens-common.h test-utimens.c macros.h \
|
|
+ nap.h test-lutimens.h test-utimens.h test-utimens-common.h \
|
|
test-utimensat.c signature.h macros.h test-vasnprintf.c \
|
|
macros.h test-vasprintf-posix.c minus-zero.h infinity.h nan.h \
|
|
macros.h test-vasprintf.c signature.h macros.h \
|
|
@@ -3827,8 +3815,8 @@ libtests_a_LIBADD = $(gltests_LIBOBJS)
|
|
libtests_a_DEPENDENCIES = $(gltests_LIBOBJS)
|
|
EXTRA_libtests_a_SOURCES = accept.c bind.c connect.c inet_pton.c \
|
|
ioctl.c listen.c perror.c pipe.c setlocale.c setsockopt.c \
|
|
- sleep.c socket.c strerror_r.c at-func.c symlinkat.c usleep.c \
|
|
- wctob.c wctomb.c
|
|
+ sleep.c socket.c strerror_r.c at-func.c symlinkat.c wctob.c \
|
|
+ wctomb.c
|
|
AM_LIBTOOLFLAGS = --preserve-dup-deps
|
|
test_accept_LDADD = $(LDADD) @LIBSOCKET@
|
|
test_file_has_acl_LDADD = $(LDADD) $(LIB_ACL)
|
|
@@ -3839,6 +3827,7 @@ test_areadlinkat_LDADD = $(LDADD) @LIBIN
|
|
test_argmatch_LDADD = $(LDADD) @LIBINTL@
|
|
test_bind_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
|
|
test_canonicalize_LDADD = $(LDADD) @LIBINTL@
|
|
+test_chown_LDADD = $(LDADD) $(LIB_NANOSLEEP)
|
|
test_closein_LDADD = $(LDADD) @LIBINTL@
|
|
test_connect_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
|
|
# Link with libintl when needed. dirent-safer uses fdopendir if it is present,
|
|
@@ -3849,15 +3838,17 @@ test_exclude_LDADD = $(LDADD) @LIBINTL@
|
|
test_faccessat_LDADD = $(LDADD) $(LIB_EACCESS) @LIBINTL@
|
|
test_fchdir_LDADD = $(LDADD) $(LIBINTL)
|
|
test_fchmodat_LDADD = $(LDADD) @LIBINTL@
|
|
-test_fchownat_LDADD = $(LDADD) @LIBINTL@
|
|
+test_fchownat_LDADD = $(LDADD) $(LIB_NANOSLEEP) @LIBINTL@
|
|
test_fdatasync_LDADD = $(LDADD) $(LIB_FDATASYNC)
|
|
test_fdopendir_LDADD = $(LDADD) @LIBINTL@
|
|
-test_fdutimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) @LIBINTL@
|
|
+test_fdutimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) \
|
|
+ $(LIB_NANOSLEEP) @LIBINTL@
|
|
+
|
|
test_filenamecat_LDADD = $(LDADD) @LIBINTL@
|
|
test_frexp_nolibm_SOURCES = test-frexp.c randomd.c
|
|
test_frexpl_nolibm_SOURCES = test-frexpl.c randoml.c
|
|
test_fstatat_LDADD = $(LDADD) @LIBINTL@
|
|
-test_futimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) @LIBINTL@
|
|
+test_futimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@
|
|
test_getaddrinfo_LDADD = $(LDADD) @GETADDRINFO_LIB@ @LIBINTL@
|
|
test_getcwd_lgpl_LDADD = $(LDADD) $(LIBINTL)
|
|
test_getcwd_LDADD = $(LDADD) @LIBINTL@
|
|
@@ -3867,6 +3858,7 @@ test_getopt_LDADD = $(LDADD) $(LIBINTL)
|
|
test_iconv_LDADD = $(LDADD) @LIBICONV@
|
|
test_inet_ntop_LDADD = $(LDADD) @INET_NTOP_LIB@
|
|
test_inet_pton_LDADD = $(LDADD) @INET_PTON_LIB@
|
|
+test_lchown_LDADD = $(LDADD) $(LIB_NANOSLEEP)
|
|
test_link_LDADD = $(LDADD) @LIBINTL@
|
|
test_linkat_LDADD = $(LDADD) @LIBINTL@
|
|
test_listen_LDADD = $(LDADD) @LIBSOCKET@
|
|
@@ -3902,6 +3894,7 @@ test_spawn_pipe_main_LDADD = $(LDADD) @L
|
|
# Therefore don't link it against any libraries other than -lc.
|
|
test_spawn_pipe_child_LDADD =
|
|
test_stat_LDADD = $(LDADD) $(LIBINTL)
|
|
+test_stat_time_LDADD = $(LDADD) $(LIB_NANOSLEEP)
|
|
test_statat_LDADD = $(LDADD) @LIBINTL@
|
|
test_striconv_LDADD = $(LDADD) @LIBICONV@
|
|
test_strsignal_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
|
|
@@ -3920,8 +3913,8 @@ test_uc_width2_SOURCES = uniwidth/test-u
|
|
test_uc_width2_LDADD = $(LDADD) $(LIBUNISTRING)
|
|
test_unlinkat_LDADD = $(LDADD) @LIBINTL@
|
|
test_userspec_LDADD = $(LDADD) @LIBINTL@
|
|
-test_utimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) @LIBINTL@
|
|
-test_utimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) @LIBINTL@
|
|
+test_utimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@
|
|
+test_utimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@
|
|
test_version_etc_LDADD = $(LDADD) @LIBINTL@
|
|
test_xalloc_die_LDADD = $(LDADD) @LIBINTL@
|
|
test_xfprintf_posix_LDADD = $(LDADD) @LIBINTL@
|
|
@@ -4893,9 +4886,6 @@ test-unsetenv$(EXEEXT): $(test_unsetenv_
|
|
test-userspec$(EXEEXT): $(test_userspec_OBJECTS) $(test_userspec_DEPENDENCIES) $(EXTRA_test_userspec_DEPENDENCIES)
|
|
@rm -f test-userspec$(EXEEXT)
|
|
$(AM_V_CCLD)$(LINK) $(test_userspec_OBJECTS) $(test_userspec_LDADD) $(LIBS)
|
|
-test-usleep$(EXEEXT): $(test_usleep_OBJECTS) $(test_usleep_DEPENDENCIES) $(EXTRA_test_usleep_DEPENDENCIES)
|
|
- @rm -f test-usleep$(EXEEXT)
|
|
- $(AM_V_CCLD)$(LINK) $(test_usleep_OBJECTS) $(test_usleep_LDADD) $(LIBS)
|
|
test-utimens$(EXEEXT): $(test_utimens_OBJECTS) $(test_utimens_DEPENDENCIES) $(EXTRA_test_utimens_DEPENDENCIES)
|
|
@rm -f test-utimens$(EXEEXT)
|
|
$(AM_V_CCLD)$(LINK) $(test_utimens_OBJECTS) $(test_utimens_LDADD) $(LIBS)
|
|
@@ -5252,7 +5242,6 @@ distclean-compile:
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unlinkat.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unsetenv.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-userspec.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-usleep.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-utimens.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-utimensat.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-vasnprintf.Po@am__quote@
|
|
@@ -5280,7 +5269,6 @@ distclean-compile:
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tls-test-tls.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_xvasprintf-test-xvasprintf.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlinkdir.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usleep.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctob.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctomb.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/thread.Po@am__quote@
|
|
@@ -6223,8 +6211,6 @@ test-update-copyright.sh.log: test-updat
|
|
@p='test-update-copyright.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
|
|
test-userspec.log: test-userspec$(EXEEXT)
|
|
@p='test-userspec$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
|
|
-test-usleep.log: test-usleep$(EXEEXT)
|
|
- @p='test-usleep$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
|
|
test-utimens.log: test-utimens$(EXEEXT)
|
|
@p='test-utimens$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
|
|
test-utimensat.log: test-utimensat$(EXEEXT)
|
|
Index: gnulib-tests/gnulib.mk
|
|
===================================================================
|
|
--- gnulib-tests/gnulib.mk.orig
|
|
+++ gnulib-tests/gnulib.mk
|
|
@@ -261,6 +261,7 @@ EXTRA_DIST += test-chdir.c signature.h m
|
|
|
|
TESTS += test-chown
|
|
check_PROGRAMS += test-chown
|
|
+test_chown_LDADD = $(LDADD) $(LIB_NANOSLEEP)
|
|
EXTRA_DIST += nap.h test-chown.h test-chown.c signature.h macros.h
|
|
|
|
## end gnulib module chown-tests
|
|
@@ -459,7 +460,7 @@ EXTRA_DIST += test-fchmodat.c signature.
|
|
|
|
TESTS += test-fchownat
|
|
check_PROGRAMS += test-fchownat
|
|
-test_fchownat_LDADD = $(LDADD) @LIBINTL@
|
|
+test_fchownat_LDADD = $(LDADD) $(LIB_NANOSLEEP) @LIBINTL@
|
|
EXTRA_DIST += nap.h test-chown.h test-lchown.h test-fchownat.c signature.h macros.h
|
|
|
|
## end gnulib module fchownat-tests
|
|
@@ -526,7 +527,8 @@ EXTRA_DIST += test-fdopendir.c signature
|
|
|
|
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@
|
|
EXTRA_DIST += nap.h test-futimens.h test-lutimens.h test-utimens.h test-utimens-common.h test-fdutimensat.c macros.h
|
|
|
|
## end gnulib module fdutimensat-tests
|
|
@@ -780,7 +782,7 @@ EXTRA_DIST += test-ftruncate.c test-ftru
|
|
|
|
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@
|
|
EXTRA_DIST += nap.h test-futimens.h test-utimens-common.h test-futimens.c signature.h macros.h
|
|
|
|
## end gnulib module futimens-tests
|
|
@@ -1104,6 +1106,7 @@ EXTRA_DIST += test-langinfo.c
|
|
|
|
TESTS += test-lchown
|
|
check_PROGRAMS += test-lchown
|
|
+test_lchown_LDADD = $(LDADD) $(LIB_NANOSLEEP)
|
|
EXTRA_DIST += nap.h test-lchown.h test-lchown.c signature.h macros.h
|
|
|
|
## end gnulib module lchown-tests
|
|
@@ -1963,7 +1966,8 @@ EXTRA_DIST += test-stat.h test-stat.c si
|
|
|
|
TESTS += test-stat-time
|
|
check_PROGRAMS += test-stat-time
|
|
-EXTRA_DIST += test-stat-time.c macros.h
|
|
+test_stat_time_LDADD = $(LDADD) $(LIB_NANOSLEEP)
|
|
+EXTRA_DIST += test-stat-time.c macros.h nap.h
|
|
|
|
## end gnulib module stat-time-tests
|
|
|
|
@@ -2419,28 +2423,11 @@ EXTRA_DIST += test-userspec.c
|
|
|
|
## end gnulib module userspec-tests
|
|
|
|
-## begin gnulib module usleep
|
|
-
|
|
-
|
|
-EXTRA_DIST += usleep.c
|
|
-
|
|
-EXTRA_libtests_a_SOURCES += usleep.c
|
|
-
|
|
-## end gnulib module usleep
|
|
-
|
|
-## begin gnulib module usleep-tests
|
|
-
|
|
-TESTS += test-usleep
|
|
-check_PROGRAMS += test-usleep
|
|
-EXTRA_DIST += test-usleep.c signature.h macros.h
|
|
-
|
|
-## end gnulib module usleep-tests
|
|
-
|
|
## begin gnulib module utimens-tests
|
|
|
|
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@
|
|
EXTRA_DIST += nap.h test-futimens.h test-lutimens.h test-utimens.h test-utimens-common.h test-utimens.c macros.h
|
|
|
|
## end gnulib module utimens-tests
|
|
@@ -2449,7 +2436,7 @@ EXTRA_DIST += nap.h test-futimens.h test
|
|
|
|
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@
|
|
EXTRA_DIST += nap.h test-lutimens.h test-utimens.h test-utimens-common.h test-utimensat.c signature.h macros.h
|
|
|
|
## end gnulib module utimensat-tests
|
|
Index: gnulib-tests/nap.h
|
|
===================================================================
|
|
--- gnulib-tests/nap.h.orig
|
|
+++ gnulib-tests/nap.h
|
|
@@ -19,19 +19,33 @@
|
|
#ifndef GLTEST_NAP_H
|
|
# define GLTEST_NAP_H
|
|
|
|
+# include <limits.h>
|
|
+
|
|
+/* Return A - B, in ns.
|
|
+ Return 0 if the true result would be negative.
|
|
+ Return INT_MAX if the true result would be greater than INT_MAX. */
|
|
static int
|
|
-lt_mtime (struct stat const *a, struct stat const *b)
|
|
+diff_timespec (struct timespec a, struct timespec b)
|
|
{
|
|
- time_t as = a->st_mtime;
|
|
- time_t bs = b->st_mtime;
|
|
- int ans = get_stat_mtime_ns (a);
|
|
- int bns = get_stat_mtime_ns (b);
|
|
+ time_t as = a.tv_sec;
|
|
+ time_t bs = b.tv_sec;
|
|
+ int ans = a.tv_nsec;
|
|
+ int bns = b.tv_nsec;
|
|
|
|
- return as < bs || (as == bs && ans < bns);
|
|
+ if (! (bs < as || (bs == as && bns < ans)))
|
|
+ return 0;
|
|
+ if (as - bs <= INT_MAX / 1000000000)
|
|
+ {
|
|
+ int sdiff = (as - bs) * 1000000000;
|
|
+ int usdiff = ans - bns;
|
|
+ if (usdiff < INT_MAX - sdiff)
|
|
+ return sdiff + usdiff;
|
|
+ }
|
|
+ return INT_MAX;
|
|
}
|
|
|
|
static void
|
|
-get_mtime (int fd, struct stat *st, int do_write)
|
|
+get_stat (int fd, struct stat *st, int do_write)
|
|
{
|
|
if (do_write)
|
|
ASSERT (write (fd, "\n", 1) == 1);
|
|
@@ -39,50 +53,61 @@ get_mtime (int fd, struct stat *st, int
|
|
}
|
|
|
|
/* Given a file whose descriptor is FD, see whether delaying by DELAY
|
|
- microseconds causes a change in a file's time stamp. If the time
|
|
- stamps differ, repeat the test one more time, in case we crossed a
|
|
- quantization boundary on a file system with lower resolution. *ST
|
|
- is the file's status, recently gotten. Update *ST to reflect the
|
|
- latest status gotten. */
|
|
+ nanoseconds causes a change in a file's time stamp. *ST is the
|
|
+ file's status, recently gotten. Update *ST to reflect the latest
|
|
+ status gotten. If successful, return the needed delay, in
|
|
+ nanoseconds as determined by the observed time stamps; this may be
|
|
+ greater than DELAY if we crossed a quantization boundary. If
|
|
+ unsuccessful, return 0. */
|
|
static int
|
|
nap_works (int fd, int delay, struct stat *st)
|
|
{
|
|
- struct stat old_st;
|
|
- old_st = *st;
|
|
- usleep (delay);
|
|
- get_mtime (fd, st, 1);
|
|
- if (! lt_mtime (&old_st, st))
|
|
- return 0;
|
|
- old_st = *st;
|
|
- usleep (delay);
|
|
- get_mtime (fd, st, 1);
|
|
- return lt_mtime (&old_st, st);
|
|
+ struct stat old_st = *st;
|
|
+ struct timespec delay_spec;
|
|
+ int cdiff, mdiff;
|
|
+ delay_spec.tv_sec = delay / 1000000000;
|
|
+ delay_spec.tv_nsec = delay % 1000000000;
|
|
+ ASSERT (nanosleep (&delay_spec, 0) == 0);
|
|
+ get_stat (fd, st, 1);
|
|
+
|
|
+ /* Return the greater of the ctime and the mtime differences, or
|
|
+ zero if it cannot be determined, or INT_MAX if either overflows. */
|
|
+ cdiff = diff_timespec (get_stat_ctime (st), get_stat_ctime (&old_st));
|
|
+ if (cdiff != 0)
|
|
+ {
|
|
+ mdiff = diff_timespec (get_stat_mtime (st), get_stat_mtime (&old_st));
|
|
+ if (mdiff != 0)
|
|
+ return cdiff < mdiff ? mdiff : cdiff;
|
|
+ }
|
|
+ return 0;
|
|
}
|
|
|
|
static int
|
|
guess_delay (void)
|
|
{
|
|
- /* Try a 1-microsecond sleep first, for speed. If that doesn't
|
|
- work, try a 1 ms sleep; that should work with ext. If it doesn't
|
|
- work, try a 20 ms sleep. xfs has a quantization of about 10
|
|
+ /* Try a 1-ns sleep first, for speed. If that doesn't work, try 100
|
|
+ ns, 1 microsecond, 1 ms, etc. xfs has a quantization of about 10
|
|
milliseconds, even though it has a granularity of 1 nanosecond,
|
|
and NTFS has a default quantization of 15.25 milliseconds, even
|
|
- though it has a granularity of 100 nanoseconds, so 20 ms is a
|
|
+ though it has a granularity of 100 nanoseconds, so 15.25 ms is a
|
|
good quantization to try. If that doesn't work, try 1 second.
|
|
The worst case is 2 seconds, needed for FAT. */
|
|
- static int const delaytab[] = {1, 1000, 20000, 1000000 };
|
|
+ static int const delaytab[] = {1, 1000, 1000000, 15250000, 1000000000 };
|
|
int fd = creat (BASE "tmp", 0600);
|
|
int i;
|
|
- int delay = 2000000;
|
|
+ int delay = 2000000000;
|
|
struct stat st;
|
|
ASSERT (0 <= fd);
|
|
- get_mtime (fd, &st, 0);
|
|
+ get_stat (fd, &st, 0);
|
|
for (i = 0; i < sizeof delaytab / sizeof delaytab[0]; i++)
|
|
- if (nap_works (fd, delaytab[i], &st))
|
|
- {
|
|
- delay = delaytab[i];
|
|
- break;
|
|
- }
|
|
+ {
|
|
+ int d = nap_works (fd, delaytab[i], &st);
|
|
+ if (d != 0)
|
|
+ {
|
|
+ delay = d;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
ASSERT (close (fd) == 0);
|
|
ASSERT (unlink (BASE "tmp") == 0);
|
|
return delay;
|
|
@@ -90,14 +115,24 @@ guess_delay (void)
|
|
|
|
/* Sleep long enough to notice a timestamp difference on the file
|
|
system in the current directory. Assumes that BASE is defined,
|
|
- and requires that the test module depends on usleep. */
|
|
+ and requires that the test module depends on nanosleep. */
|
|
static void
|
|
nap (void)
|
|
{
|
|
- static int delay;
|
|
- if (!delay)
|
|
- delay = guess_delay ();
|
|
- usleep (delay);
|
|
+ static struct timespec delay;
|
|
+ if (!delay.tv_sec && !delay.tv_nsec)
|
|
+ {
|
|
+ int d = guess_delay ();
|
|
+
|
|
+ /* Multiply by 1.125 (rounding up), to avoid problems if the
|
|
+ file system's clock is a bit slower than nanosleep's.
|
|
+ Ceiling it at INT_MAX, though. */
|
|
+ int delta = (d >> 3) + ((d & 7) != 0);
|
|
+ d = delta < INT_MAX - d ? d + delta : INT_MAX;
|
|
+ delay.tv_sec = d / 1000000000;
|
|
+ delay.tv_nsec = d % 1000000000;
|
|
+ }
|
|
+ ASSERT (nanosleep (&delay, 0) == 0);
|
|
}
|
|
|
|
#endif /* GLTEST_NAP_H */
|
|
Index: gnulib-tests/test-stat-time.c
|
|
===================================================================
|
|
--- gnulib-tests/test-stat-time.c.orig
|
|
+++ gnulib-tests/test-stat-time.c
|
|
@@ -27,6 +27,9 @@
|
|
|
|
#include "macros.h"
|
|
|
|
+#define BASE "test-stat-time.t"
|
|
+#include "nap.h"
|
|
+
|
|
enum { NFILES = 4 };
|
|
|
|
static int
|
|
@@ -79,48 +82,6 @@ do_stat (const char *filename, struct st
|
|
ASSERT (stat (filename, p) == 0);
|
|
}
|
|
|
|
-/* Sleep long enough to notice a timestamp difference on the file
|
|
- system in the current directory. */
|
|
-static void
|
|
-nap (void)
|
|
-{
|
|
- static long delay;
|
|
- if (!delay)
|
|
- {
|
|
- /* Initialize only once, by sleeping for 20 milliseconds (needed
|
|
- since xfs has a quantization of about 10 milliseconds, even
|
|
- though it has a granularity of 1 nanosecond, and since NTFS
|
|
- has a default quantization of 15.25 milliseconds, even though
|
|
- it has a granularity of 100 nanoseconds). If the seconds
|
|
- differ, repeat the test one more time (in case we crossed a
|
|
- quantization boundary on a file system with 1 second
|
|
- resolution). If we can't observe a difference in only the
|
|
- nanoseconds, then fall back to 1 second if the time is odd,
|
|
- and 2 seconds (needed for FAT) if time is even. */
|
|
- struct stat st1;
|
|
- struct stat st2;
|
|
- ASSERT (stat ("t-stt-stamp1", &st1) == 0);
|
|
- ASSERT (force_unlink ("t-stt-stamp1") == 0);
|
|
- delay = 20000;
|
|
- usleep (delay);
|
|
- create_file ("t-stt-stamp1");
|
|
- ASSERT (stat ("t-stt-stamp1", &st2) == 0);
|
|
- if (st1.st_mtime != st2.st_mtime)
|
|
- {
|
|
- /* Seconds differ, give it one more shot. */
|
|
- st1 = st2;
|
|
- ASSERT (force_unlink ("t-stt-stamp1") == 0);
|
|
- usleep (delay);
|
|
- create_file ("t-stt-stamp1");
|
|
- ASSERT (stat ("t-stt-stamp1", &st2) == 0);
|
|
- }
|
|
- if (! (st1.st_mtime == st2.st_mtime
|
|
- && get_stat_mtime_ns (&st1) < get_stat_mtime_ns (&st2)))
|
|
- delay = (st1.st_mtime & 1) ? 1000000 : 2000000;
|
|
- }
|
|
- usleep (delay);
|
|
-}
|
|
-
|
|
static void
|
|
prepare_test (struct stat *statinfo, struct timespec *modtimes)
|
|
{
|
|
Index: gnulib-tests/test-usleep.c
|
|
===================================================================
|
|
--- gnulib-tests/test-usleep.c
|
|
+++ /dev/null
|
|
@@ -1,40 +0,0 @@
|
|
-/* Test of usleep() function.
|
|
- Copyright (C) 2009-2013 Free Software Foundation, Inc.
|
|
-
|
|
- This program is free software: you can redistribute it and/or modify
|
|
- it under the terms of the GNU General Public License as published by
|
|
- the Free Software Foundation; either version 3 of the License, or
|
|
- (at your option) any later version.
|
|
-
|
|
- This program is distributed in the hope that it will be useful,
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
- GNU General Public License for more details.
|
|
-
|
|
- You should have received a copy of the GNU General Public License
|
|
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
-
|
|
-/* Written by Eric Blake <ebb9@byu.net>, 2009. */
|
|
-
|
|
-#include <config.h>
|
|
-
|
|
-#include <unistd.h>
|
|
-
|
|
-#include "signature.h"
|
|
-SIGNATURE_CHECK (usleep, int, (useconds_t));
|
|
-
|
|
-#include <time.h>
|
|
-
|
|
-#include "macros.h"
|
|
-
|
|
-int
|
|
-main (void)
|
|
-{
|
|
- time_t start = time (NULL);
|
|
- ASSERT (usleep (1000000) == 0);
|
|
- ASSERT (start < time (NULL));
|
|
-
|
|
- ASSERT (usleep (0) == 0);
|
|
-
|
|
- return 0;
|
|
-}
|
|
Index: gnulib-tests/usleep.c
|
|
===================================================================
|
|
--- gnulib-tests/usleep.c
|
|
+++ /dev/null
|
|
@@ -1,58 +0,0 @@
|
|
-/* Pausing execution of the current thread.
|
|
- Copyright (C) 2009-2013 Free Software Foundation, Inc.
|
|
- Written by Eric Blake <ebb9@byu.net>, 2009.
|
|
-
|
|
- This program is free software: you can redistribute it and/or modify
|
|
- it under the terms of the GNU General Public License as published by
|
|
- the Free Software Foundation; either version 3 of the License, or
|
|
- (at your option) any later version.
|
|
-
|
|
- This program is distributed in the hope that it will be useful,
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
- GNU General Public License for more details.
|
|
-
|
|
- You should have received a copy of the GNU General Public License
|
|
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
-
|
|
-/* This file is _intentionally_ light-weight. Rather than using
|
|
- select or nanosleep, both of which drag in external libraries on
|
|
- some platforms, this merely rounds up to the nearest second if
|
|
- usleep() does not exist. If sub-second resolution is important,
|
|
- then use a more powerful interface to begin with. */
|
|
-
|
|
-#include <config.h>
|
|
-
|
|
-/* Specification. */
|
|
-#include <unistd.h>
|
|
-
|
|
-#include <errno.h>
|
|
-
|
|
-#ifndef HAVE_USLEEP
|
|
-# define HAVE_USLEEP 0
|
|
-#endif
|
|
-
|
|
-/* Sleep for MICRO microseconds, which can be greater than 1 second.
|
|
- Return -1 and set errno to EINVAL on range error (about 4295
|
|
- seconds), or 0 on success. Interaction with SIGALARM is
|
|
- unspecified. */
|
|
-
|
|
-int
|
|
-usleep (useconds_t micro)
|
|
-{
|
|
- unsigned int seconds = micro / 1000000;
|
|
- if (sizeof seconds < sizeof micro && micro / 1000000 != seconds)
|
|
- {
|
|
- errno = EINVAL;
|
|
- return -1;
|
|
- }
|
|
- if (!HAVE_USLEEP && micro % 1000000)
|
|
- seconds++;
|
|
- while ((seconds = sleep (seconds)) != 0);
|
|
-
|
|
-#undef usleep
|
|
-#if !HAVE_USLEEP
|
|
-# define usleep(x) 0
|
|
-#endif
|
|
- return usleep (micro % 1000000);
|
|
-}
|
|
Index: lib/config.hin
|
|
===================================================================
|
|
--- lib/config.hin.orig
|
|
+++ lib/config.hin
|
|
@@ -735,9 +735,6 @@
|
|
/* Define to 1 when the gnulib module unsetenv should be tested. */
|
|
#undef GNULIB_TEST_UNSETENV
|
|
|
|
-/* Define to 1 when the gnulib module usleep should be tested. */
|
|
-#undef GNULIB_TEST_USLEEP
|
|
-
|
|
/* Define to 1 when the gnulib module utimensat should be tested. */
|
|
#undef GNULIB_TEST_UTIMENSAT
|
|
|
|
@@ -2387,9 +2384,6 @@
|
|
/* Define to 1 if you have the `uselocale' function. */
|
|
#undef HAVE_USELOCALE
|
|
|
|
-/* Define to 1 if you have the `usleep' function. */
|
|
-#undef HAVE_USLEEP
|
|
-
|
|
/* Define to 1 if you have the `utimensat' function. */
|
|
#undef HAVE_UTIMENSAT
|
|
|
|
@@ -3348,9 +3342,6 @@
|
|
#endif
|
|
|
|
|
|
-/* Define to an unsigned 32-bit type if <sys/types.h> lacks this type. */
|
|
-#undef useconds_t
|
|
-
|
|
/* Define as a macro for copying va_list variables. */
|
|
#undef va_copy
|
|
|
|
Index: m4/gnulib-comp.m4
|
|
===================================================================
|
|
--- m4/gnulib-comp.m4.orig
|
|
+++ m4/gnulib-comp.m4
|
|
@@ -741,8 +741,6 @@ AC_DEFUN([gl_EARLY],
|
|
# Code from module useless-if-before-free:
|
|
# Code from module userspec:
|
|
# Code from module userspec-tests:
|
|
- # Code from module usleep:
|
|
- # Code from module usleep-tests:
|
|
# Code from module utimecmp:
|
|
# Code from module utimens:
|
|
# Code from module utimens-tests:
|
|
@@ -2255,11 +2253,6 @@ changequote([, ])dnl
|
|
gl_UNLINKDIR
|
|
abs_aux_dir=`cd "$ac_aux_dir"; pwd`
|
|
AC_SUBST([abs_aux_dir])
|
|
- gl_FUNC_USLEEP
|
|
- if test $HAVE_USLEEP = 0 || test $REPLACE_USLEEP = 1; then
|
|
- AC_LIBOBJ([usleep])
|
|
- fi
|
|
- gl_UNISTD_MODULE_INDICATOR([usleep])
|
|
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
|
|
abs_aux_dir=`cd "$ac_aux_dir"; pwd`
|
|
AC_SUBST([abs_aux_dir])
|
|
@@ -3436,7 +3429,6 @@ AC_DEFUN([gl_FILE_LIST], [
|
|
m4/unlocked-io.m4
|
|
m4/uptime.m4
|
|
m4/userspec.m4
|
|
- m4/usleep.m4
|
|
m4/utimbuf.m4
|
|
m4/utimecmp.m4
|
|
m4/utimens.m4
|
|
@@ -3839,7 +3831,6 @@ AC_DEFUN([gl_FILE_LIST], [
|
|
tests/test-unsetenv.c
|
|
tests/test-update-copyright.sh
|
|
tests/test-userspec.c
|
|
- tests/test-usleep.c
|
|
tests/test-utimens-common.h
|
|
tests/test-utimens.c
|
|
tests/test-utimens.h
|
|
@@ -3913,7 +3904,6 @@ AC_DEFUN([gl_FILE_LIST], [
|
|
tests=lib/symlinkat.c
|
|
tests=lib/unlinkdir.c
|
|
tests=lib/unlinkdir.h
|
|
- tests=lib/usleep.c
|
|
tests=lib/w32sock.h
|
|
tests=lib/wctob.c
|
|
tests=lib/wctomb-impl.h
|
|
Index: m4/usleep.m4
|
|
===================================================================
|
|
--- m4/usleep.m4
|
|
+++ /dev/null
|
|
@@ -1,45 +0,0 @@
|
|
-# usleep.m4 serial 3
|
|
-dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
|
|
-dnl This file is free software; the Free Software Foundation
|
|
-dnl gives unlimited permission to copy and/or distribute it,
|
|
-dnl with or without modifications, as long as this notice is preserved.
|
|
-
|
|
-dnl This macro intentionally does not check for select or nanosleep;
|
|
-dnl both of those modules can require external libraries.
|
|
-AC_DEFUN([gl_FUNC_USLEEP],
|
|
-[
|
|
- AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
|
- dnl usleep was required in POSIX 2001, but dropped as obsolete in
|
|
- dnl POSIX 2008; therefore, it is not always exposed in headers.
|
|
- AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
|
- AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
- AC_CHECK_FUNCS_ONCE([usleep])
|
|
- AC_CHECK_TYPE([useconds_t], [],
|
|
- [AC_DEFINE([useconds_t], [unsigned int], [Define to an unsigned 32-bit
|
|
- type if <sys/types.h> lacks this type.])])
|
|
- if test $ac_cv_func_usleep = no; then
|
|
- HAVE_USLEEP=0
|
|
- else
|
|
- dnl POSIX allows implementations to reject arguments larger than
|
|
- dnl 999999, but GNU guarantees it will work.
|
|
- AC_CACHE_CHECK([whether usleep allows large arguments],
|
|
- [gl_cv_func_usleep_works],
|
|
- [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
|
-#include <unistd.h>
|
|
-]], [[return !!usleep (1000000);]])],
|
|
- [gl_cv_func_usleep_works=yes], [gl_cv_func_usleep_works=no],
|
|
- [case "$host_os" in
|
|
- # Guess yes on glibc systems.
|
|
- *-gnu*) gl_cv_func_usleep_works="guessing yes" ;;
|
|
- # If we don't know, assume the worst.
|
|
- *) gl_cv_func_usleep_works="guessing no" ;;
|
|
- esac
|
|
- ])])
|
|
- case "$gl_cv_func_usleep_works" in
|
|
- *yes) ;;
|
|
- *)
|
|
- REPLACE_USLEEP=1
|
|
- ;;
|
|
- esac
|
|
- fi
|
|
-])
|