From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
qemu-stable@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: [PULL 03/11] tests/tcg/multiarch/linux/linux-test: Don't try to test atime update
Date: Mon, 20 Oct 2025 11:41:41 +0100 [thread overview]
Message-ID: <20251020104149.4034124-4-alex.bennee@linaro.org> (raw)
In-Reply-To: <20251020104149.4034124-1-alex.bennee@linaro.org>
From: Peter Maydell <peter.maydell@linaro.org>
The linux-test test includes an attempt to check the utime and stat
syscalls by setting the atime and mtime of a file to specific values,
and then calling stat() to check that the values read back correctly.
Unfortunately this is flaky, as it will fail if some other process
(for instance a virus scanner, backup program, etc) gets in and reads
the file between the utime() and stat() call, resulting in a host
syscall sequence like this:
utimensat(AT_FDCWD, "file2",
[{tv_sec=1001, tv_nsec=0} /* 1970-01-01T01:16:41+0100 */,
{tv_sec=1000, tv_nsec=0} /* 1970-01-01T01:16:40+0100 */], 0) = 0
# successfully set atime to 1001 and mtime to 1000
statx(AT_FDCWD, "file2", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT,
STATX_BASIC_STATS,
{stx_mask=STATX_BASIC_STATS|STATX_MNT_ID,
stx_blksize=4096, stx_attributes=0, stx_nlink=1, stx_uid=32808,
stx_gid=32808, stx_mode=S_IFREG|0600, stx_ino=21659016,
stx_size=100, stx_blocks=8,
stx_attributes_mask=STATX_ATTR_COMPRESSED|STATX_ATTR_IMMUTABLE|
STATX_ATTR_APPEND|STATX_ATTR_NODUMP|STATX_ATTR_ENCRYPTED|
STATX_ATTR_AUTOMOUNT|STATX_ATTR_MOUNT_ROOT|STATX_ATTR_VERITY|
STATX_ATTR_DAX,
stx_atime={tv_sec=1760091862, tv_nsec=63509009} /* 2025-10-10T11:24:22.063509009+0100 */,
stx_ctime={tv_sec=1760091862, tv_nsec=63509009} /* 2025-10-10T11:24:22.063509009+0100 */,
stx_mtime={tv_sec=1000, tv_nsec=0} /* 1970-01-01T01:16:40+0100 */,
stx_rdev_major=0, stx_rdev_minor=0, stx_dev_major=252,
stx_dev_minor=0, stx_mnt_id=0x1f}) = 0
# but when we statx the file, we get back an mtime of 1000
# but an atime corresponding to when the other process read it
and which will cause the test program to fail with the error
message "stat time".
In theory we could defend against this by e.g. operating on files in
a dummy loopback mount filesystem which we mounted as 'noatime', but
this isn't worth the hassle. Just drop the check on atime.
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20251016150357.876415-4-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/tests/tcg/multiarch/linux/linux-test.c b/tests/tcg/multiarch/linux/linux-test.c
index 64f57cb287e..bf6e0fda262 100644
--- a/tests/tcg/multiarch/linux/linux-test.c
+++ b/tests/tcg/multiarch/linux/linux-test.c
@@ -155,9 +155,14 @@ static void test_file(void)
error("stat mode");
if ((st.st_mode & 0777) != 0600)
error("stat mode2");
- if (st.st_atime != 1001 ||
- st.st_mtime != 1000)
+ /*
+ * Only check mtime, not atime: other processes such as
+ * virus scanners might race with this test program and get
+ * in and update the atime, causing random failures.
+ */
+ if (st.st_mtime != 1000) {
error("stat time");
+ }
chk_error(stat(tmpdir, &st));
if (!S_ISDIR(st.st_mode))
--
2.47.3
next prev parent reply other threads:[~2025-10-20 10:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 10:41 [PULL 00/11] maintainer updates (gitlab, check-tcg, virtio-gpu, plugins, docs) Alex Bennée
2025-10-20 10:41 ` [PULL 01/11] gitlab: use template for ubuntu-24.04-aarch64 jobs Alex Bennée
2025-10-20 10:41 ` [PULL 02/11] gitlab: drop aarch32 runner and associated bits Alex Bennée
2025-10-20 10:41 ` Alex Bennée [this message]
2025-10-20 10:41 ` [PULL 04/11] Support per-head resolutions with virtio-gpu Alex Bennée
2025-10-20 11:55 ` Markus Armbruster
2025-10-20 12:46 ` Alex Bennée
2025-10-20 10:41 ` [PULL 05/11] ui/gtk-gl-area: Remove extra draw call in refresh Alex Bennée
2025-10-20 10:41 ` [PULL 06/11] hw/display: add blob map/unmap trace events Alex Bennée
2025-10-20 10:41 ` [PULL 07/11] contrib/plugins/uftrace_symbols.py: generate debug files to map symbols to source Alex Bennée
2025-10-20 10:41 ` [PULL 08/11] docs/system: split VirtIO devices from the rest Alex Bennée
2025-10-20 10:41 ` [PULL 09/11] docs/system: unify the naming style for VirtIO devices Alex Bennée
2025-10-20 10:41 ` [PULL 10/11] docs/system: drop vhost-user-rng docs Alex Bennée
2025-10-20 10:41 ` [PULL 11/11] docs/system: merge vhost-user-input into vhost-user-contrib Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251020104149.4034124-4-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).