about summary refs log tree commit diff
path: root/io/test-utime.c
diff options
context:
space:
mode:
Diffstat (limited to 'io/test-utime.c')
-rw-r--r--io/test-utime.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/io/test-utime.c b/io/test-utime.c
index 24c287160b..2f8aa57266 100644
--- a/io/test-utime.c
+++ b/io/test-utime.c
@@ -76,6 +76,12 @@ main (int argc, char *argv[])
       return 1;
     }
 
+  /* The clocks used to set the modification time and that used in the
+     time() call need not be the same.  They need not have the same
+     precision.  Therefore we delay the following operation by one
+     second which makes sure we can compare with second precision.  */
+  sleep (1);
+
   if (utime (file, NULL))
     {
       perror ("utime NULL");
@@ -83,6 +89,8 @@ main (int argc, char *argv[])
       return 1;
     }
 
+  sleep (1);
+
   now2 = time (NULL);
   if (now2 == (time_t)-1)
     {
@@ -112,12 +120,7 @@ main (int argc, char *argv[])
       return 1;
     }
 
-#ifdef _STATBUF_ST_NSEC
-# define CORR (stnow.st_mtim.tv_nsec == 0 ? 0 : 1)
-#else
-# define CORR 0
-#endif
-  if (stnow.st_mtime + CORR < now1 || stnow.st_mtime > now2)
+  if (stnow.st_mtime < now1 || stnow.st_mtime > now2)
     {
       printf ("modtime %ld <%ld >%ld\n", stnow.st_mtime, now1, now2);
       return 1;