-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 10/9/2009 12:06 PM: > Multiple calls to sleep(2) add up fast! I've especially noticed it while > working on my utimensat series, where repeatedly running 'make check' stalls > on > this test. Unless you are insane enough to run on FAT, or unlucky enough to > be > on mingw (since I didn't want to drag in a dependency on xnanosleep just for > this test), this patch gives an order-of-magnitude speedup to test-stat-time.
And in testing it, I came across spurious failures on at least Darwin's NFS client, where mtime is rather bogus until a sync(). I'm pushing this: - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----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/ iEYEARECAAYFAkrQAw8ACgkQ84KuGfSFAYAFWQCgpHBmL9ctcYWnHR3ghhK1qvxW 0pAAnRHqZEpfX7q4oqUXX2K58VOwXq4A =oYbS -----END PGP SIGNATURE-----
>From 9b77fe9ec434d890feccddf665540e4a53aa6972 Mon Sep 17 00:00:00 2001 From: Eric Blake <e...@byu.net> Date: Fri, 9 Oct 2009 21:09:38 -0600 Subject: [PATCH] test-stat-time: port to buggy NFS clients On darwin, the NFS client reports mtime with st_sec==-1 and st_nsec monotonically increasing per transaction until the next sync(); but sync() is expensive, so it is easier to just skip this part of the test if mtime is nowhere near ctime. * tests/test-stat-time.c (main) [W32]: Reduce ifdefs. (test_ctime): Also skip test if mtime and ctime are skewed. Signed-off-by: Eric Blake <e...@byu.net> --- ChangeLog | 4 ++++ tests/test-stat-time.c | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5ec7c3..49ac4cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-10-09 Eric Blake <e...@byu.net> + test-stat-time: port to buggy NFS clients + * tests/test-stat-time.c (main) [W32]: Reduce ifdefs. + (test_ctime): Also skip test if mtime and ctime are skewed. + futimens: new module * modules/futimens: New file. * lib/futimens.c (futimens): Likewise. diff --git a/tests/test-stat-time.c b/tests/test-stat-time.c index 77b99a4..3759024 100644 --- a/tests/test-stat-time.c +++ b/tests/test-stat-time.c @@ -186,10 +186,21 @@ test_mtime (const struct stat *statinfo, struct timespec *modtimes) } } -#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) +#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ +/* Skip the ctime tests on native Windows platforms, because their + st_ctime is either the same as st_mtime (plus or minus an offset) + or set to the file _creation_ time, and is not influenced by rename + or chmod. */ +# define test_ctime ((void) 0) +#else static void test_ctime (const struct stat *statinfo) { + /* On some buggy NFS clients, mtime and ctime are disproportionately + skewed from one another. Skip this test in that case. */ + if (statinfo[0].st_mtime != statinfo[0].st_ctime) + return; + /* mtime(stamp2) < ctime(renamed) */ ASSERT (statinfo[2].st_mtime < statinfo[1].st_ctime || (statinfo[2].st_mtime == statinfo[1].st_ctime @@ -246,12 +257,7 @@ main () cleanup (0); prepare_test (statinfo, modtimes); test_mtime (statinfo, modtimes); - /* Skip the ctime tests on native Windows platforms, because there st_ctime - is either the same as st_mtime (plus or minus an offset) or set to the - file _creation_ time, and is not influenced by rename or chmod. */ -#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) test_ctime (statinfo); -#endif test_birthtime (statinfo, modtimes, birthtimes); cleanup (0); -- 1.6.5.rc1