]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix test_format_newc timestamp race condition 2918/head
authorAlejandro Perez <alejandroperezpestana99@gmail.com>
Mon, 27 Apr 2026 06:18:19 +0000 (06:18 +0000)
committerAlejandro Perez <alejandroperezpestana99@gmail.com>
Mon, 27 Apr 2026 06:18:19 +0000 (06:18 +0000)
Add 1-second tolerance to timestamp assertion to account
for timing variations in containerized build environments.

Fixes #2917

cpio/test/test_format_newc.c

index 9d4e4e9fb6743f46add0c0007a671cdcb2a631f2..7363fc148f1663f6b8d7577c4064b5c8b6bdafd5 100644 (file)
@@ -198,7 +198,7 @@ DEFINE_TEST(test_format_newc)
        t = from_hex(e + 46, 8); /* mtime */
        failure("t=%#08jx now=%#08jx=%jd", (uintmax_t)t, (uintmax_t)now,
            (intmax_t)now);
-       assert(t <= now); /* File wasn't created in future. */
+       assert(t <= now + 1); /* Allow 1 sec margin for timing variations. */
        failure("t=%#08jx now - 2=%#08jx=%jd", (uintmax_t)t, (uintmax_t)now - 2,
            (intmax_t)now - 2);
        assert(t >= now - 2); /* File was created w/in last 2 secs. */