[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: coreutils-8.2 misc/ls-time test failure
From: |
Eric Blake |
Subject: |
Re: coreutils-8.2 misc/ls-time test failure |
Date: |
Mon, 21 Dec 2009 07:08:34 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Eric Blake on 12/19/2009 5:34 PM:
> Here's what I'm finally pushing to gnulib, and a followup to coreutils.
And a followup; now that the test requires inequality in ctime, the nap()
function needs to sleep longer when run on ext3 or any other file system
with only one-second resolution.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAksvgWIACgkQ84KuGfSFAYAstgCgieeoBsKJaDHFC/LscLhfz2WA
LtkAoNf0Gk5qG7zvPZMZQhCL4aEY1X3m
=NOm4
-----END PGP SIGNATURE-----
>From c7362ef0beb434d7a3063b5a7ac7b956988dc435 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 21 Dec 2009 07:00:13 -0700
Subject: [PATCH] test-utimens: avoid spurious failure
Fixes a spurious failure on ext3, with one-second resolution,
now that ctime effects are being tested for inequality.
* tests/test-chown.h (nap): Factor...
* tests/nap.h: ...into new file.
* tests/test-lchown.h (nap): Avoid duplication.
* tests/test-utimens-common.h (nap): Use shared implementation,
necessary on file systems with 1-second resolution.
* modules/chown-tests (Files): Include new file.
* modules/fdutimensat-tests (Files): Likewise.
* modules/futimens-tests (Files): Likewise.
* modules/lchown-tests (Files): Likewise.
* modules/openat-tests (Files): Likewise.
* modules/utimens-tests (Files): Likewise.
* modules/utimensat-tests (Files): Likewise.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 16 ++++++++++
modules/chown-tests | 1 +
modules/fdutimensat-tests | 1 +
modules/futimens-tests | 1 +
modules/lchown-tests | 1 +
modules/openat-tests | 1 +
modules/utimens-tests | 1 +
modules/utimensat-tests | 1 +
tests/nap.h | 67 +++++++++++++++++++++++++++++++++++++++++++
tests/test-chown.h | 45 +----------------------------
tests/test-lchown.h | 46 +-----------------------------
tests/test-utimens-common.h | 27 ++---------------
12 files changed, 96 insertions(+), 112 deletions(-)
create mode 100644 tests/nap.h
diff --git a/ChangeLog b/ChangeLog
index eb560d5..5dd41d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2009-12-21 Eric Blake <address@hidden>
+
+ test-utimens: avoid spurious failure
+ * tests/test-chown.h (nap): Factor...
+ * tests/nap.h: ...into new file.
+ * tests/test-lchown.h (nap): Avoid duplication.
+ * tests/test-utimens-common.h (nap): Use shared implementation,
+ necessary on file systems with 1-second resolution.
+ * modules/chown-tests (Files): Include new file.
+ * modules/fdutimensat-tests (Files): Likewise.
+ * modules/futimens-tests (Files): Likewise.
+ * modules/lchown-tests (Files): Likewise.
+ * modules/openat-tests (Files): Likewise.
+ * modules/utimens-tests (Files): Likewise.
+ * modules/utimensat-tests (Files): Likewise.
+
2009-12-19 Eric Blake <address@hidden>
futimens, utimensat: work around Linux bug
diff --git a/modules/chown-tests b/modules/chown-tests
index a5d5c3a..d1add61 100644
--- a/modules/chown-tests
+++ b/modules/chown-tests
@@ -1,4 +1,5 @@
Files:
+tests/nap.h
tests/test-chown.h
tests/test-chown.c
diff --git a/modules/fdutimensat-tests b/modules/fdutimensat-tests
index 75ff374..16cf82c 100644
--- a/modules/fdutimensat-tests
+++ b/modules/fdutimensat-tests
@@ -1,4 +1,5 @@
Files:
+tests/nap.h
tests/test-futimens.h
tests/test-lutimens.h
tests/test-utimens.h
diff --git a/modules/futimens-tests b/modules/futimens-tests
index 2f57c3b..c768c33 100644
--- a/modules/futimens-tests
+++ b/modules/futimens-tests
@@ -1,4 +1,5 @@
Files:
+tests/nap.h
tests/test-futimens.h
tests/test-utimens-common.h
tests/test-futimens.c
diff --git a/modules/lchown-tests b/modules/lchown-tests
index 8b71e75..7e4d502 100644
--- a/modules/lchown-tests
+++ b/modules/lchown-tests
@@ -1,4 +1,5 @@
Files:
+tests/nap.h
tests/test-lchown.h
tests/test-lchown.c
diff --git a/modules/openat-tests b/modules/openat-tests
index e604ca4..7265fd9 100644
--- a/modules/openat-tests
+++ b/modules/openat-tests
@@ -1,4 +1,5 @@
Files:
+tests/nap.h
tests/test-chown.h
tests/test-lchown.h
tests/test-lstat.h
diff --git a/modules/utimens-tests b/modules/utimens-tests
index 6a2d161..5bf14c2 100644
--- a/modules/utimens-tests
+++ b/modules/utimens-tests
@@ -1,4 +1,5 @@
Files:
+tests/nap.h
tests/test-futimens.h
tests/test-lutimens.h
tests/test-utimens.h
diff --git a/modules/utimensat-tests b/modules/utimensat-tests
index ded7f74..a56bb3e 100644
--- a/modules/utimensat-tests
+++ b/modules/utimensat-tests
@@ -1,4 +1,5 @@
Files:
+tests/nap.h
tests/test-lutimens.h
tests/test-utimens.h
tests/test-utimens-common.h
diff --git a/tests/nap.h b/tests/nap.h
new file mode 100644
index 0000000..e8b4f5a
--- /dev/null
+++ b/tests/nap.h
@@ -0,0 +1,67 @@
+/* Assist in file system timestamp tests.
+ Copyright (C) 2009 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 <address@hidden>, 2009. */
+
+#ifndef GLTEST_NAP_H
+# define GLTEST_NAP_H
+
+/* 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. */
+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 (close (creat (BASE "tmp", 0600)) == 0);
+ ASSERT (stat (BASE "tmp", &st1) == 0);
+ ASSERT (unlink (BASE "tmp") == 0);
+ delay = 20000;
+ usleep (delay);
+ ASSERT (close (creat (BASE "tmp", 0600)) == 0);
+ ASSERT (stat (BASE "tmp", &st2) == 0);
+ ASSERT (unlink (BASE "tmp") == 0);
+ if (st1.st_mtime != st2.st_mtime)
+ {
+ /* Seconds differ, give it one more shot. */
+ st1 = st2;
+ usleep (delay);
+ ASSERT (close (creat (BASE "tmp", 0600)) == 0);
+ ASSERT (stat (BASE "tmp", &st2) == 0);
+ ASSERT (unlink (BASE "tmp") == 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);
+}
+
+#endif /* GLTEST_NAP_H */
diff --git a/tests/test-chown.h b/tests/test-chown.h
index c4e652a..62e612e 100644
--- a/tests/test-chown.h
+++ b/tests/test-chown.h
@@ -16,50 +16,7 @@
/* Written by Eric Blake <address@hidden>, 2009. */
-#define TEST_CHOWN_NAP
-/* 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 (close (creat (BASE "tmp", 0600)) == 0);
- ASSERT (stat (BASE "tmp", &st1) == 0);
- ASSERT (unlink (BASE "tmp") == 0);
- delay = 20000;
- usleep (delay);
- ASSERT (close (creat (BASE "tmp", 0600)) == 0);
- ASSERT (stat (BASE "tmp", &st2) == 0);
- ASSERT (unlink (BASE "tmp") == 0);
- if (st1.st_mtime != st2.st_mtime)
- {
- /* Seconds differ, give it one more shot. */
- st1 = st2;
- usleep (delay);
- ASSERT (close (creat (BASE "tmp", 0600)) == 0);
- ASSERT (stat (BASE "tmp", &st2) == 0);
- ASSERT (unlink (BASE "tmp") == 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);
-}
+#include "nap.h"
#if !HAVE_GETEGID
# define getegid() ((gid_t) -1)
diff --git a/tests/test-lchown.h b/tests/test-lchown.h
index 93a657c..26f80f7 100644
--- a/tests/test-lchown.h
+++ b/tests/test-lchown.h
@@ -16,51 +16,7 @@
/* Written by Eric Blake <address@hidden>, 2009. */
-#ifndef TEST_CHOWN_NAP
-/* 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 (close (creat (BASE "tmp", 0600)) == 0);
- ASSERT (stat (BASE "tmp", &st1) == 0);
- ASSERT (unlink (BASE "tmp") == 0);
- delay = 20000;
- usleep (delay);
- ASSERT (close (creat (BASE "tmp", 0600)) == 0);
- ASSERT (stat (BASE "tmp", &st2) == 0);
- ASSERT (unlink (BASE "tmp") == 0);
- if (st1.st_mtime != st2.st_mtime)
- {
- /* Seconds differ, give it one more shot. */
- st1 = st2;
- usleep (delay);
- ASSERT (close (creat (BASE "tmp", 0600)) == 0);
- ASSERT (stat (BASE "tmp", &st2) == 0);
- ASSERT (unlink (BASE "tmp") == 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);
-}
-#endif /* !TEST_CHOWN_NAP */
+#include "nap.h"
#if !HAVE_GETEGID
# define getegid() ((gid_t) -1)
diff --git a/tests/test-utimens-common.h b/tests/test-utimens-common.h
index 707971a..30fd886 100644
--- a/tests/test-utimens-common.h
+++ b/tests/test-utimens-common.h
@@ -24,10 +24,14 @@
# include <string.h>
# include <unistd.h>
+/* Gnulib modules. */
# include "stat-time.h"
# include "timespec.h"
# include "utimecmp.h"
+/* Gnulib test header. */
+# include "nap.h"
+
enum {
BILLION = 1000 * 1000 * 1000,
@@ -44,29 +48,6 @@ enum {
: 0)
};
-/* Sleep long enough to cross a timestamp quantization boundary on
- most known systems with subsecond timestamp resolution. For
- example, ext4 has a quantization of 10 milliseconds, but a
- resolution of 1 nanosecond. Likewise, NTFS has a quantization as
- slow as 15.25 milliseconds, but a resolution of 100 nanoseconds.
- This is necessary on systems where creat or utimens with NULL
- rounds down to the quantization boundary, but where gettime and
- hence utimensat can inject timestamps between quantization
- boundaries. By ensuring we cross a boundary, we are less likely to
- confuse utimecmp for two times that would round to the same
- quantization boundary but are distinct based on resolution. */
-static void
-nap (void)
-{
- /* Systems that lack usleep also lack subsecond timestamps, and have
- a quantization boundary equal to the resolution. Our usage of
- utimecmp allows equality, so no need to waste 980 milliseconds
- if the replacement usleep rounds to 1 second. */
-# if HAVE_USLEEP
- usleep (20 * 1000); /* 20 milliseconds. */
-# endif
-}
-
# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
/* Skip ctime tests on native Windows, since it is either a copy of
mtime or birth time (depending on the file system), rather than a
--
1.6.5.rc1
Re: coreutils-8.2 misc/ls-time test failure, Jim Meyering, 2009/12/16