]> Savannah Git Hosting - gnulib.git/commitdiff
utimens: Avoid test failures on macOS 10.13.
authorBruno Haible <bruno@clisp.org>
Sat, 2 Jan 2021 17:57:10 +0000 (18:57 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 2 Jan 2021 17:57:10 +0000 (18:57 +0100)
Reported by Martin Storsjö <martin@martin.st> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00003.html>.

* tests/test-utimens-common.h (check_ctime): Define to -1 on macOS.
* tests/test-utimens.h (test_utimens): Don't expect a ctime change when
only the atime is requested to change.
* tests/test-futimens.h (test_futimens): Likewise.
* tests/test-lutimens.h (test_lutimens): Likewise.

ChangeLog
tests/test-futimens.h
tests/test-lutimens.h
tests/test-utimens-common.h
tests/test-utimens.h

index 6d95f4990019d9151d4017896a1e023331bd8b3a..73d11397b2dddad35dea907ae1d508b690709629 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2021-01-02  Bruno Haible  <bruno@clisp.org>
+
+       utimens: Avoid test failures on macOS 10.13.
+       Reported by Martin Storsjö <martin@martin.st> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00003.html>.
+       * tests/test-utimens-common.h (check_ctime): Define to -1 on macOS.
+       * tests/test-utimens.h (test_utimens): Don't expect a ctime change when
+       only the atime is requested to change.
+       * tests/test-futimens.h (test_futimens): Likewise.
+       * tests/test-lutimens.h (test_lutimens): Likewise.
+
 2021-01-02  Bruno Haible  <bruno@clisp.org>
 
        renameatu: Fix test failures on macOS.
index 6a17013b68505b2779b8772fe66a848732086028..31ff900f3d136a2c49a8d305dd07a0bda2525006 100644 (file)
@@ -166,7 +166,7 @@ test_futimens (int (*func) (int, struct timespec const *),
     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)
+    if (check_ctime > 0)
       ASSERT (ctime_compare (&st3, &st2) < 0);
   }
 
index f6d5586c20c54f1b0e0a89f7f857b7ccfb43378d..589c9cfaaabfe4a715f245fda5c540629be8f4b1 100644 (file)
@@ -194,7 +194,7 @@ test_lutimens (int (*func) (char const *, struct timespec const *), bool print)
       }
     ASSERT (st3.st_mtime == st2.st_mtime);
     ASSERT (get_stat_mtime_ns (&st3) == get_stat_mtime_ns (&st2));
-    if (check_ctime)
+    if (check_ctime > 0)
       ASSERT (ctime_compare (&st3, &st2) < 0);
   }
 
index 5861667fd45bd7d9e717465b90a5ddbdebeac3f7..3d665ef0795083aaa52a9a9786c5872ac7fd022f 100644 (file)
@@ -55,6 +55,9 @@ enum {
    properly tracked change time.  See
    <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions>.  */
 #  define check_ctime 0
+# elif defined __APPLE__ && defined __MACH__
+/* On macOS, the ctime is not updated when only the st_atime changes.  */
+#  define check_ctime -1
 # else
 #  define check_ctime 1
 # endif
index c3c70297aa5f39ad2457b5a51584a6a445613e27..9273fd07e09cee3a90a1830d899511b42fe037a4 100644 (file)
@@ -145,7 +145,7 @@ test_utimens (int (*func) (char const *, struct timespec const *), bool print)
     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)
+    if (check_ctime > 0)
       ASSERT (ctime_compare (&st3, &st2) < 0);
   }