[LTP] [RFC] statx Timestamp Test case

Cyril Hrubis chrubis@suse.cz
Fri Aug 10 14:42:56 CEST 2018


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


More information about the ltp mailing list