public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [RFC] statx Timestamp Test case
@ 2018-08-09 13:30 vaishnavi.d
  2018-08-10 12:42 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: vaishnavi.d @ 2018-08-09 13:30 UTC (permalink / raw)
  To: ltp


Hi,
  We are trying to write a testcase for statx timestamp fields(btime,
atime, mtime and ctime).

In our approach, we are getting the system time before and after calling
the corresponding system call that affects the timestamp using
clock_gettime.

The problem we are facing is there is no sufficient time difference
between successive times.

To introduce a delay, we are writing a function that will read time until
there is a time change as below:

>void my_clock_gettime(struct timespec *time)
> {
>    int ret;
>    struct timespec prev_time;


>    ret = clock_gettime(CLOCK_REALTIME_COARSE, &prev_time);
>    if (ret == -1)
>	tst_brk(TINFO | TERRNO, "clock_gettime failed");

>    do {
>	ret = clock_gettime(CLOCK_REALTIME_COARSE, time);
>	if (ret == -1)
>	    tst_brk(TINFO | TERRNO, "clock_gettime failed");
>    } while (time == prev_time);
>}

Is this approach fine or is there any other better way of doing it?

Thanks & Regards,
Vaishnavi.D
Subash.G





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [LTP] [RFC] statx Timestamp Test case
  2018-08-09 13:30 [LTP] [RFC] statx Timestamp Test case vaishnavi.d
@ 2018-08-10 12:42 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2018-08-10 12:42 UTC (permalink / raw)
  To: ltp

Hi!
> >void my_clock_gettime(struct timespec *time)
> > {
> >    int ret;
> >    struct timespec prev_time;
> 
> 
> >    ret = clock_gettime(CLOCK_REALTIME_COARSE, &prev_time);
> >    if (ret == -1)
> >	tst_brk(TINFO | TERRNO, "clock_gettime failed");
> 
> >    do {
> >	ret = clock_gettime(CLOCK_REALTIME_COARSE, time);
> >	if (ret == -1)
> >	    tst_brk(TINFO | TERRNO, "clock_gettime failed");
> >    } while (time == prev_time);
> >}
> 
> Is this approach fine or is there any other better way of doing it?

You can use clock_getres() to query the lenght of the timer tick then
usleep a bit more than that, e.g. multiply that by 1.5.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-10 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-09 13:30 [LTP] [RFC] statx Timestamp Test case vaishnavi.d
2018-08-10 12:42 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox