test-stat-time, test-utimens: improve portability
authorEric Blake <ebb9@byu.net>
Mon, 12 Oct 2009 16:42:35 +0000 (10:42 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 16 Oct 2009 14:21:24 +0000 (08:21 -0600)
commit4d8f229535aef794199fa6dd0eb29e852c35d73d
treec77ab524f57e8693d32a0e080d77d671d51d0b69
parent8cb4edaac4154d3b4455b9d132599bf73c0100ee
test-stat-time, test-utimens: improve portability

ext4 on an alpha system has a quantization of about 10 ms but
a resolution of 1ns; utimecmp does not know about quantization,
so tests were failing when comparing timestamps that fall
within the same quantization window.  Add strategic usleeps
throughout to minimize this issue, whether or not we later
improve utimecmp to account for quantization.

Windows (and hence cygwin) is documented as having a default
clock quantization of 15.25 milliseconds (although it can be
reduced to 1 millisecond); file timestamps are quantized to this
boundary even though more accurate timing can be obtained.
However, this means that 15 milliseconds is too short for any
test that wants to guarantee crossing a file timestamp boundary.
Cygwin, however, still has bugs where clock_gettime can lag
behind file timestamps, which is not fixed by this patch.

Solaris 9 with NFS exposed the same problem for futimes that was
previously fixed for utimes on Solaris 8, where futimens(f,NULL)
uses a different time source than futimes(,{,UTIME_NOW}).

* tests/test-stat-time.c (nap): Lengthen delay to 20ms, for
ext4 on alpha, and for cygwin.
* tests/test-utimens-common.h: New file.
(nap): Factor delays into single function.
* tests/test-lutimens.h (test_lutimens): Use new header.
* tests/test-futimens.h (test_futimens): Likewise.
* tests/test-utimens.h (test_utimens): Likewise.  Also, force NFS
timestamps to occur from same machine, as was done previously for
test_utimens.
* modules/utimens-tests (Files): Ship new file.
* modules/futimens-tests (Files): Likewise.
Reported in part by Jim Meyering.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
modules/futimens-tests
modules/utimens-tests
tests/test-futimens.h
tests/test-lutimens.h
tests/test-stat-time.c
tests/test-utimens-common.h [new file with mode: 0644]
tests/test-utimens.h