Re: [LTP] [PATCH 1/5] Add stat04 test

Li Wang
2024-07-04T11:28:20Z

On Thu, Jul 4, 2024 at 5:23 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > > > + /* change st_atime / st_mtime / st_ctime */
> > > > + sleep(1);
> > > >
> > >
> > > Does this 1sec sleep make real sense to the test? Can we remove it?
> >
> > With utimensat we can easily change access time and modification time
> > but you can't change status change time. So we either sleep here or set
> > the system clock back, change the file and then reset the system clock
> > back.
>
> And if you are asking if the test will run fine without the sleep, it
> will run and it will pass, but the timestamps will be same for the link
> and the file, so if kernel picks up wrong timestamp we will not find
> out.
>

I'm confused, do you mean if the kernel sets a wrong timestamp it could
report TFAIL?

From what I can tell, the stat(sym_path,) also retrieves information of
the target file,
shouldn't that always equal the stat(file_path,) timestamp? As long as the
stat()
works correctly, with sleep(1) or not won't impact anything.

--
Regards,
Li Wang