+ ASSERT (fstat (fd, &st2) == 0);
+ /* If utimens truncates to less resolution than the file system
+ 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 (0 <= utimecmp (BASE "file", &st2, &st1, UTIMECMP_TRUNCATE_SOURCE));
+ if (check_ctime)
+ ASSERT (st1.st_ctime < st2.st_ctime
+ || (st1.st_ctime == st2.st_ctime
+ && get_stat_ctime_ns (&st1) < get_stat_ctime_ns (&st2)));
+ {
+ /* 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_NOW) 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 (fd, ts) == 0);
+ ASSERT (fstat (fd, &st1) == 0);
+ nap ();
+ }