[LTP] [PATCH v2] syscalls/utime03: use realtime clock for upper bound check
Jan Stancek
jstancek@redhat.com
Mon Feb 24 17:06:34 CET 2025
On Mon, Feb 24, 2025 at 4:41 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > This test rarely fails with recent kernels (after 6.13-rc1):
> > tst_test.c:1833: TINFO: === Testing on ext4 ===
> > tst_test.c:1170: TINFO: Formatting /dev/loop0 with ext4 opts='' extra opts=''
> > mke2fs 1.47.2 (1-Jan-2025)
> > tst_test.c:1182: TINFO: Mounting /dev/loop0 to /tmp/LTP_uti42UpHj/mntpoint fstyp=ext4 flags=0
> > utime03.c:74: TPASS: utime(TEMP_FILE, NULL) passed
> > utime03.c:80: TFAIL: utime() did not set expected atime, mintime: 1738291930, maxtime: 1738291930, st_atime: 1738291931
> > utime03.c:85: TFAIL: utime() did not set expected mtime, mintime: 1738291930, maxtime: 1738291930, st_mtime: 1738291931
> >
> > Since 4e40eff0b573 ("fs: add infrastructure for multigrain timestamps"),
> > filesystem can use more precise clock to update the inode.
> >
> > Relax the check by using realtime clock for upper bound check.
> >
> > Signed-off-by: Jan Stancek <jstancek@redhat.com>
> > ---
> > testcases/kernel/syscalls/utime/utime03.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/testcases/kernel/syscalls/utime/utime03.c b/testcases/kernel/syscalls/utime/utime03.c
> > index 564e1de3dd77..56eb9e722896 100644
> > --- a/testcases/kernel/syscalls/utime/utime03.c
> > +++ b/testcases/kernel/syscalls/utime/utime03.c
> > @@ -55,6 +55,7 @@ static void run(void)
> > struct utimbuf utbuf;
> > struct stat statbuf;
> > time_t mintime, maxtime;
> > + struct timespec ts;
> >
> > utbuf.modtime = time(0) - 5;
> > utbuf.actime = utbuf.modtime + 1;
> > @@ -70,7 +71,8 @@ static void run(void)
> > SAFE_SETEUID(user_uid);
> > mintime = tst_get_fs_timestamp();
> > TST_EXP_PASS(utime(TEMP_FILE, NULL));
> > - maxtime = tst_get_fs_timestamp();
> > + tst_clock_gettime(CLOCK_REALTIME, &ts);
> > + maxtime = ts.tv_sec;
> > SAFE_SETEUID(root_uid);
> > SAFE_STAT(TEMP_FILE, &statbuf);
>
> There are six testcases that use tst_get_fs_timestamp() is this the only
> one that fails?
Good point. I managed to reproduce it with utime01 as well:
utime01.c:50: TFAIL: utime() did not set expected mtime, pre_time:
1740411917, post_time: 1740411917, st_mtime: 1740411918
utime01.c:55: TFAIL: utime() did not set expected atime, pre_time:
1740411917, post_time: 1740411917, st_atime: 1740411918
>
> Also if we are going to do this, we should at least put the code to the
> library and introduce two different functions one for the start
> timestamp and one for the end timestamp and make use of that in all the
> test
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
More information about the ltp
mailing list