Mercurial > hg > octave-lojdl > gnulib-hg
changeset 12165:c5a8a8e67e6f
utimens-tests: port to NFS file systems
Testing on Solaris 8 with NFS: creat() and utimens(,NULL) seem to
set timestamps according to the current time on the server, while
utimens(,{,UTIME_NOW}) sets timestamps according to the current
time on the client. If two machines are not perfectly
synchronized in time, then this makes time appear to move
backwards. Avoid spurious test failures caused by a mtime
comparison across machines, by instead doing 2 mtime comparisons,
each known to be from timestamps tied to a single machine.
* tests/test-utimens.h (test_utimens): Add a utimens call prior to
grabbing stat buffer.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Mon, 12 Oct 2009 10:42:35 -0600 |
parents | 0f120c1de4c5 |
children | d943ffe46edc |
files | ChangeLog tests/test-utimens.h |
diffstat | 2 files changed, 28 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-10-12 Eric Blake <ebb9@byu.net> + + utimens-tests: port to NFS file systems + * tests/test-utimens.h (test_utimens): Refactor utimecmp + comparisons to avoid spurious failures from timestamp drift + between NFS machines. + 2009-10-12 Eric Blake <ebb9@byu.net> stat-time-tests: minor cleanups
--- a/tests/test-utimens.h +++ b/tests/test-utimens.h @@ -56,10 +56,28 @@ ASSERT (close (creat (BASE "file", 0600)) == 0); /* If utimens truncates to less resolution than the file system - supports, then time can appear to go backwards between now and - the follow-up utimens(file,NULL). Use UTIMECMP_TRUNCATE_SOURCE - to compensate, with st1 as the source. */ + supports, then time can appear to go backwards between now and a + follow-up utimens with UTIME_NOW or a NULL timespec. Use + UTIMECMP_TRUNCATE_SOURCE to compensate, with st1 as the + source. */ ASSERT (stat (BASE "file", &st1) == 0); + ASSERT (func (BASE "file", NULL) == 0); + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (0 <= utimecmp (BASE "file", &st2, &st1, UTIMECMP_TRUNCATE_SOURCE)); + { + /* On some NFS systems, the 'now' timestamp of creat or a NULL + timespec is determined by the server, but the 'now' timestamp + determined by gettime() (as is done when using UTIME_OMIT) is + determined by the client; since the two machines are not + necessarily on the same clock, this is another case where time + can appear to go backwards. The rest of this test cares about + client time, so manually use gettime() to set both times. */ + struct timespec ts[2]; + gettime (&ts[0]); + ts[1] = ts[0]; + ASSERT (func (BASE "file", ts) == 0); + ASSERT (stat (BASE "file", &st1) == 0); + } /* Invalid arguments. */ errno = 0;