bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

utimens, utimensat, fdutimensat: Avoid test failures on AIX 7.2


From: Bruno Haible
Subject: utimens, utimensat, fdutimensat: Avoid test failures on AIX 7.2
Date: Wed, 06 Jan 2021 06:38:50 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; )

On AIX 7.2, on a jfs2 file system, I observe test failures:

FAIL: test-fdutimensat
======================

../../gltests/test-utimens.h:136: assertion '0 <= utimecmp (BASE "file", &st3, 
&st1, UTIMECMP_TRUNCATE_SOURCE)' failed
FAIL test-fdutimensat (exit status: 134)

FAIL: test-utimens
==================

../../gltests/test-utimens.h:136: assertion '0 <= utimecmp (BASE "file", &st3, 
&st1, UTIMECMP_TRUNCATE_SOURCE)' failed
FAIL test-utimens (exit status: 134)

FAIL: test-utimensat
====================

../../gltests/test-utimens.h:136: assertion '0 <= utimecmp (BASE "file", &st3, 
&st1, UTIMECMP_TRUNCATE_SOURCE)' failed
FAIL test-utimensat (exit status: 134)

and sometimes (randomly) also

FAIL: test-futimens
===================

../../gltests/test-futimens.h:157: assertion 'utimecmp (BASE "file", &st1, 
&st3, 0) <= 0' failed
FAIL test-futimens (exit status: 134)


utimecmp is function designed to determine whether two time stamps compare
as "in order", for the purpose of the tests. It has been written under the
assumption that the time stamps are multiples of a "clock tick", such as
10 ms, 1 ms, or such.

Here, the situation is different: Time stamps which should be "in order"
appear as if time goes backwards, by up to 0.01 seconds:

$ ./test-utimens
st1.st_mtime = 1609906369.621672000
st1.st_atime = 1609906369.621672000
st1.st_ctime = 1609906369.621406477
st3.st_mtime = 1609906369.621740005
st3.st_atime =  946684800.499999999
st3.st_ctime = 1609906369.621740005
st1.st_mtime = 1609906369.667310000
st1.st_atime = 1609906369.667310000
st1.st_ctime = 1609906369.667262448
st3.st_mtime = 1609906369.667404212
st3.st_atime =  946684800.499999999
st3.st_ctime = 1609906369.667404212
$ ./test-utimens
st1.st_mtime = 1609906379.606703000
st1.st_atime = 1609906379.606703000
st1.st_ctime = 1609906379.596986073
st3.st_mtime = 1609906379.596986072
st3.st_atime =  946684800.499999999
st3.st_ctime = 1609906379.596986075
../../gltests/test-utimens.h:142: assertion '0 <= utimecmp (BASE "file", &st3, 
&st1, UTIMECMP_TRUNCATE_SOURCE)' failed
IOT/Abort trap (core dumped)
$ ./test-utimens
st1.st_mtime = 1609907028.480332000
st1.st_atime = 1609907028.480332000
st1.st_ctime = 1609907028.476985876
st3.st_mtime = 1609907028.476985875
st3.st_atime = 946684800.499999999
st3.st_ctime = 1609907028.476985878
../../gltests/test-utimens.h:142: assertion '0 <= utimecmp (BASE "file", &st3, 
&st1, UTIMECMP_TRUNCATE_SOURCE)' failed
IOT/Abort trap (core dumped)
$ ./test-utimens
st1.st_mtime = 1609907035.595854000
st1.st_atime = 1609907035.595854000
st1.st_ctime = 1609907035.595626217
st3.st_mtime = 1609907035.595919210
st3.st_atime = 946684800.499999999
st3.st_ctime = 1609907035.595919210
st1.st_mtime = 1609907035.704475000
st1.st_atime = 1609907035.704475000
st1.st_ctime = 1609907035.704438042
st3.st_mtime = 1609907035.704565207
st3.st_atime = 946684800.499999999
st3.st_ctime = 1609907035.704565207
$ ./test-utimens
st1.st_mtime = 1609907038.407856000
st1.st_atime = 1609907038.407856000
st1.st_ctime = 1609907038.407656680
st3.st_mtime = 1609907038.407915701
st3.st_atime = 946684800.499999999
st3.st_ctime = 1609907038.407915701
st1.st_mtime = 1609907038.470543000
st1.st_atime = 1609907038.470543000
st1.st_ctime = 1609907038.466986760
st3.st_mtime = 1609907038.466986759
st3.st_atime = 946684800.499999999
st3.st_ctime = 1609907038.466986762
../../gltests/test-utimens.h:142: assertion '0 <= utimecmp (BASE "file", &st3, 
&st1, UTIMECMP_TRUNCATE_SOURCE)' failed
IOT/Abort trap (core dumped)
$ ./test-utimens
st1.st_mtime = 1609907043.288970000
st1.st_atime = 1609907043.288970000
st1.st_ctime = 1609907043.288844908
st3.st_mtime = 1609907043.288844908
st3.st_atime = 946684800.499999999
st3.st_ctime = 1609907043.288844910
../../gltests/test-utimens.h:142: assertion '0 <= utimecmp (BASE "file", &st3, 
&st1, UTIMECMP_TRUNCATE_SOURCE)' failed
IOT/Abort trap (core dumped)

It's clearer if I just print the mtime difference (over 100 runs of
'test-utimens'):

mtime difference = 102269
mtime difference = 88078
mtime difference = 59314
mtime difference = -2716420
mtime difference = 60556
mtime difference = 90279
mtime difference = 56208
mtime difference = 90255
mtime difference = -5406942
mtime difference = 59136
mtime difference = 91349
mtime difference = -5235182
mtime difference = -2215750
mtime difference = -2451879
mtime difference = -4995827
mtime difference = -1039040
mtime difference = 58166
mtime difference = 85718
mtime difference = -2036801
mtime difference = -4750180
mtime difference = 59994
mtime difference = 88496
mtime difference = -1964430
mtime difference = -512567
mtime difference = 61406
mtime difference = 90015
mtime difference = 60291
mtime difference = 89468
mtime difference = 60197
mtime difference = 91156
mtime difference = -4191143
mtime difference = 61894
mtime difference = 85000
mtime difference = 61929
mtime difference = 92613
mtime difference = -1111325
mtime difference = 61617
mtime difference = 87962
mtime difference = 61089
mtime difference = 90451
mtime difference = 63025
mtime difference = 104164
mtime difference = 61339
mtime difference = 86675
mtime difference = -8087954
mtime difference = 59607
mtime difference = 85099
mtime difference = 57197
mtime difference = 90576
mtime difference = -4997754
mtime difference = 60498
mtime difference = 90583
mtime difference = -3081135
mtime difference = 62537
mtime difference = 90949
mtime difference = 59898
mtime difference = 87783
mtime difference = 64150
mtime difference = -2567752
mtime difference = 99449
mtime difference = 135939
mtime difference = -6060792
mtime difference = -3522588
mtime difference = -4817743
mtime difference = -1982393
mtime difference = 59529
mtime difference = 90375
mtime difference = -818543
mtime difference = -4529657
mtime difference = 60093
mtime difference = 89392
mtime difference = 60750
mtime difference = 85148
mtime difference = -290612
mtime difference = -196229
mtime difference = 59058
mtime difference = 89201
mtime difference = -1770276
mtime difference = 60750
mtime difference = -412469
mtime difference = -1630333
mtime difference = -1389713
mtime difference = -1895295
mtime difference = -1584598
mtime difference = -1941405
mtime difference = 61082
mtime difference = 87808
mtime difference = 59550
mtime difference = 88339
mtime difference = 59355
mtime difference = 87164
mtime difference = 60029
mtime difference = 85466
mtime difference = 61498
mtime difference = 85361
mtime difference = 65230
mtime difference = 91011
mtime difference = -25500
mtime difference = -3130006
mtime difference = 60609
mtime difference = -1831252
mtime difference = 74957
mtime difference = 102685
mtime difference = -6218831
mtime difference = -2086973
mtime difference = 75783
mtime difference = 143380
mtime difference = 58056
mtime difference = 90425
mtime difference = 57830
mtime difference = 105798
mtime difference = 59007
mtime difference = 87763
mtime difference = 74103
mtime difference = 91105
mtime difference = 93701
mtime difference = -1139805
mtime difference = 59820
mtime difference = 84414
mtime difference = 59585
mtime difference = 88613
mtime difference = 58863
mtime difference = 87679
mtime difference = 75562
mtime difference = 89884
mtime difference = 60734
mtime difference = 93246
mtime difference = -590307
mtime difference = 86720
mtime difference = 85435
mtime difference = -3902206
mtime difference = -5258852
mtime difference = -6645235
mtime difference = 59707
mtime difference = 91017
mtime difference = -527125
mtime difference = -866682
mtime difference = -5369446
mtime difference = 60558
mtime difference = 84812
mtime difference = 58886
mtime difference = 88626
mtime difference = -6358227
mtime difference = -579729
mtime difference = -4900700
mtime difference = -492584
mtime difference = 61525
mtime difference = 87703
mtime difference = 60591
mtime difference = 90726
mtime difference = 60552
mtime difference = 93738
mtime difference = 59935
mtime difference = 91166
mtime difference = 60283
mtime difference = 89480

The smallest mtime difference here is -8087954 ns, the largest is 143380 ns.

Setting the "resolution" to 10000000 in utimecmp.c did not succeed in making
the tests work. But this ad-hoc code worked. Since the purpose of 'utimecmp'
is to make the tests succeed, I'm committing this. We may want to generalize
it to other OSes, if there is need to.


2021-01-05  Bruno Haible  <bruno@clisp.org>

        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/lib/utimecmp.c b/lib/utimecmp.c
index 7f73925..781a0d2 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 31ff900..53eeb5c 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 ();





reply via email to

[Prev in Thread] Current Thread [Next in Thread]