summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2021-01-02 18:57:10 +0100
committerBruno Haible <bruno@clisp.org>2021-01-02 18:57:10 +0100
commit3b123860925185b7ba330e1f24a7a9389a955f9b (patch)
tree9a4866f05c47642188428c4ea1e500d2de939360 /tests
parentb4ef486ff5110e4e0714ab77166b5884922be071 (diff)
downloadgnulib-3b123860925185b7ba330e1f24a7a9389a955f9b.tar.gz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-futimens.h2
-rw-r--r--tests/test-lutimens.h2
-rw-r--r--tests/test-utimens-common.h3
-rw-r--r--tests/test-utimens.h2
4 files changed, 6 insertions, 3 deletions
diff --git a/tests/test-futimens.h b/tests/test-futimens.h
index 6a17013b68..31ff900f3d 100644
--- a/tests/test-futimens.h
+++ b/tests/test-futimens.h
@@ -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);
}
diff --git a/tests/test-lutimens.h b/tests/test-lutimens.h
index f6d5586c20..589c9cfaaa 100644
--- a/tests/test-lutimens.h
+++ b/tests/test-lutimens.h
@@ -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);
}
diff --git a/tests/test-utimens-common.h b/tests/test-utimens-common.h
index 5861667fd4..3d665ef079 100644
--- a/tests/test-utimens-common.h
+++ b/tests/test-utimens-common.h
@@ -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
diff --git a/tests/test-utimens.h b/tests/test-utimens.h
index c3c70297aa..9273fd07e0 100644
--- a/tests/test-utimens.h
+++ b/tests/test-utimens.h
@@ -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);
}