From 6ebb53926665cda261f2d66ab9a603c971648cef Mon Sep 17 00:00:00 2001 From: Christiano Haesbaert Date: Sun, 27 Jul 2025 22:18:07 +0200 Subject: [PATCH] Fix file atime tests. Issue #206 It seems unlink(2) can change atime. Since the events are aggregated by quark, including the unlink, we always get the most recent atime, meaning the one from unlink. To fix the test we must do fstat after the unlink, not before. --- quark-test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/quark-test.c b/quark-test.c index b78fba1..8d9078b 100644 --- a/quark-test.c +++ b/quark-test.c @@ -775,12 +775,16 @@ t_file(const struct test *t, struct quark_queue_attr *qa) assert(write(fd, "4", 1) == 1); assert(write(fd, "5", 1) == 1); + if (unlink(path) == -1) + err(1, "unlink"); + + /* + * unlink(2) might change atime, so unlink before we fstat(2) + */ if (fstat(fd, &st) == -1) err(1, "stat"); close(fd); - if (unlink(path) != 0) - err(1, "unlink"); qev = drain_for_pid(&qq, getpid()); assert(qev->events == QUARK_EV_FILE);