From: Bruno Haible Date: Wed, 6 Jan 2021 05:16:22 +0000 (+0100) Subject: utimens, utimensat, fdutimensat: Avoid test failures on AIX 7.2. X-Git-Tag: v1.0~3194 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=05bee3e887988e9dd5e12ffde2334ee152e7c7e0;p=gnulib.git utimens, utimensat, fdutimensat: Avoid test failures on AIX 7.2. * lib/utimecmp.c (utimecmpat): On AIX, declare equality when the two times differ by less than 0.01 seconds. * tests/test-futimens.h (test_futimens): Pass UTIMECMP_TRUNCATE_SOURCE flag. --- diff --git a/ChangeLog b/ChangeLog index b974810650..61d4e7aaef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2021-01-05 Bruno Haible + + utimens, utimensat, fdutimensat: Avoid test failures on AIX 7.2. + * lib/utimecmp.c (utimecmpat): On AIX, declare equality when the two + times differ by less than 0.01 seconds. + * tests/test-futimens.h (test_futimens): Pass UTIMECMP_TRUNCATE_SOURCE + flag. + 2021-01-05 Bruno Haible utimensat: Work around trailing slash bug in utimensat() on AIX 7.2. diff --git a/lib/utimecmp.c b/lib/utimecmp.c index 7f73925ae9..781a0d2892 100644 --- a/lib/utimecmp.c +++ b/lib/utimecmp.c @@ -157,6 +157,17 @@ utimecmpat (int dfd, char const *dst_name, if (options & UTIMECMP_TRUNCATE_SOURCE) { +#if defined _AIX + /* On AIX 7.2, on a jfs2 file system, the times may differ by up to + 0.01 seconds in either direction. But it does not seem to come + from clock ticks of 0.01 seconds each. */ + long long difference = + ((long long) dst_s - (long long) src_s) * BILLION + + ((long long) dst_ns - (long long) src_ns); + if (difference < 10000000 && difference > -10000000) + return 0; +#endif + /* Look up the timestamp resolution for the destination device. */ /* Hash table for caching information learned about devices. */ diff --git a/tests/test-futimens.h b/tests/test-futimens.h index 31ff900f3d..53eeb5c042 100644 --- a/tests/test-futimens.h +++ b/tests/test-futimens.h @@ -154,7 +154,7 @@ test_futimens (int (*func) (int, struct timespec const *), ASSERT (st3.st_atime == Y2K); ASSERT (0 <= get_stat_atime_ns (&st3)); ASSERT (get_stat_atime_ns (&st3) <= BILLION / 2); - ASSERT (utimecmp (BASE "file", &st1, &st3, 0) <= 0); + ASSERT (utimecmp (BASE "file", &st1, &st3, UTIMECMP_TRUNCATE_SOURCE) <= 0); if (check_ctime) ASSERT (ctime_compare (&st2, &st3) < 0); nap ();