[PATCH] stdio-common: Avoid spurious mtime/ctime-related failure in tst-fseek
Florian Weimer
fweimer@redhat.com
Mon Sep 7 13:04:50 GMT 2026
* Florian Weimer:
> The test seems to use the timestamps to verify that the file
> has been written as part of the buffer flush. Any change should
> be sufficient. Using the nanosecond field means that if the
> second field does not change due to clock rounding differences,
> the test does not fail unexpectedly.
>
> This was originally observed as a failure on s390x-linux-gnu:
>
> =====FAIL: stdio-common/tst-fseek.out=====
> 350: st_ctime not changed
> 355: st_mtime not changed
> 436: SEEK_END works
> 468: SEEK_END works
>
> ---
> stdio-common/tst-fseek.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/stdio-common/tst-fseek.c b/stdio-common/tst-fseek.c
> index 086ede5967..64f1e0a057 100644
> --- a/stdio-common/tst-fseek.c
> +++ b/stdio-common/tst-fseek.c
> @@ -345,12 +345,14 @@ do_test (void)
> printf ("%d: st_mtime not updated\n", __LINE__);
> result = 1;
> }
> - if (st1.st_ctime >= st2.st_ctime)
> + if (st1.st_ctime >= st2.st_ctime
> + && st1.st_ctim.tv_nsec == st2.st_ctim.tv_nsec)
> {
> printf ("%d: st_ctime not changed\n", __LINE__);
> result = 1;
> }
> - if (st1.st_mtime >= st2.st_mtime)
> + if (st1.st_mtime >= st2.st_mtime
> + && st1.st_mtim.tv_nsec == st2.st_mtim.tv_nsec)
> {
> printf ("%d: st_mtime not changed\n", __LINE__);
> result = 1;
>
> base-commit: 13c114c10bd3b665c1f11bd5f843bfe5e8238efb
This fix is related:
commit 0d28f1f1a07e3a4473fb87cfade9528e54fbffe0
Author: Yury Khrustalev <yury.khrustalev@arm.com>
Date: Mon Feb 2 14:06:38 2026 +0000
tests: posix: use cpu clock for sleep
On some emulated targets sleep may result in inconsistent wait
times which will lead to the failure of the tst-chmod test.
To account for this we use the CLOCK_PROCESS_CPUTIME_ID clock ID
while also consuming CPU time by repeatedly calling clock_gettime.
Reviewed-by: DJ Delorie <dj@redhat.com>
I'll probably submit something along those lines later.
Thanks,
Florian
More information about the Libc-alpha
mailing list