[LTP] [PATCH] syscalls: make atime-sensitive tests more robust by extending sleep to 1.5s

Li Wang liwang@redhat.com
Mon Nov 10 11:10:39 CET 2025


These two atime-sensitive tests can still occasionally (< 0.1% probability) fail
on fast or virtualized environments (e.g. tmpfs, containers, high load) because
the comparison relies on second-level st_atime and the two accesses can land
within the same wall-clock second despite a 1.001s delay.

Increase the sleep window from ~1.001s to 1.5s in the following tests to reduce
false negatives caused by second-boundary races and scheduler jitter:

  === error logs ===

  mount03.c:140: TFAIL: st.st_atime(1750804951) < atime(1750804951)

  lstat03.c:38: TFAIL: Expect: file_stat->st_atime != symb_stat->st_atime
  lstat03.c:39: TFAIL: Expect: file_stat->st_mtime != symb_stat->st_mtime
  lstat03.c:40: TFAIL: Expect: file_stat->st_ctime != symb_stat->st_ctime

Fixes: ff60156bc02f ("mount03: flip to the next second before doing the access")
Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/lstat/lstat03.c | 2 +-
 testcases/kernel/syscalls/mount/mount03.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/lstat/lstat03.c b/testcases/kernel/syscalls/lstat/lstat03.c
index a0ff4dc9b..9438e2920 100644
--- a/testcases/kernel/syscalls/lstat/lstat03.c
+++ b/testcases/kernel/syscalls/lstat/lstat03.c
@@ -70,7 +70,7 @@ static void setup(void)
 	SAFE_CLOSE(fd);
 
 	/* change st_atime / st_mtime / st_ctime */
-	usleep(1001000);
+	usleep(1500000);
 
 	SAFE_SYMLINK(FILENAME, SYMBNAME);
 }
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index 98be3dc0a..8dd6f3eed 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -120,7 +120,7 @@ static void test_file_dir_noatime(int update_fatime, int update_datime)
 	SAFE_CLOSEDIR(test_dir);
 	dir_atime = dir_st.st_atime;
 
-	usleep(1001000);
+	usleep(1500000);
 
 	SAFE_READ(0, otfd, readbuf, sizeof(readbuf));
 	SAFE_FSTAT(otfd, &st);
-- 
2.51.1



More information about the ltp mailing list