+ ASSERT (0 <= utimecmp (BASE "file", &st3, &st1, UTIMECMP_TRUNCATE_SOURCE));
+ if (check_ctime)
+ ASSERT (st2.st_ctime < st3.st_ctime
+ || (st2.st_ctime == st3.st_ctime
+ && get_stat_ctime_ns (&st2) < get_stat_ctime_ns (&st3)));
+ nap ();
+ ts[0].tv_nsec = 0;
+ ts[1].tv_nsec = UTIME_OMIT;
+ ASSERT (func (BASE "file", ts) == 0);
+ ASSERT (stat (BASE "file", &st2) == 0);
+ ASSERT (st2.st_atime == BILLION);
+ ASSERT (get_stat_atime_ns (&st2) == 0);
+ ASSERT (st3.st_mtime == st2.st_mtime);
+ ASSERT (get_stat_mtime_ns (&st3) == get_stat_mtime_ns (&st2));
+ if (check_ctime)
+ ASSERT (st3.st_ctime < st2.st_ctime
+ || (st3.st_ctime == st2.st_ctime
+ && get_stat_ctime_ns (&st3) < get_stat_ctime_ns (&st2)));
+ }
+
+ /* Make sure this dereferences symlinks. */
+ if (symlink (BASE "file", BASE "link"))
+ {
+ ASSERT (unlink (BASE "file") == 0);
+ if (print)
+ fputs ("skipping test: symlinks not supported on this file system\n",
+ stderr);
+ return 77;
+ }
+ ASSERT (lstat (BASE "link", &st1) == 0);
+ ASSERT (st1.st_mtime != Y2K);
+ errno = 0;
+ ASSERT (func (BASE "link/", NULL) == -1);
+ ASSERT (errno == ENOTDIR);
+ {
+ struct timespec ts[2] = { { Y2K, 0 }, { Y2K, 0 } };
+ ASSERT (func (BASE "link", ts) == 0);
+ ASSERT (lstat (BASE "link", &st2) == 0);
+ /* Can't compare atimes, since lstat() changes symlink atime on cygwin. */
+ ASSERT (st1.st_mtime == st2.st_mtime);
+ ASSERT (stat (BASE "link", &st2) == 0);
+ ASSERT (st2.st_mtime == Y2K);
+ ASSERT (get_stat_mtime_ns (&st2) == 0);