[LTP] [PATCH] syscalls/timer_settime01: adjust for rounding from nsec to usec

Thadeu Lima de Souza Cascardo cascardo@canonical.com
Mon Oct 26 16:12:50 CET 2020


On Tue, Oct 20, 2020 at 02:23:51PM +0200, Cyril Hrubis wrote:
> Hi!
> > What about this change instead?
> > 
> > diff --git a/testcases/kernel/syscalls/timer_settime/timer_settime01.c b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
> > index 67143e8f8..599ef2891 100644
> > --- a/testcases/kernel/syscalls/timer_settime/timer_settime01.c
> > +++ b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
> > @@ -132,11 +132,13 @@ static void run(unsigned int n)
> >  					get_clock_str(clock));
> >  				continue;
> >  			}
> > -			val += tst_ts_to_us(timenow);
> > +			tst_ts_add_us(timenow, val);
> > +			tst_its_set_value_from_ts(&new_set, timenow);
> > +		} else {
> > +			tst_its_set_value_from_us(&new_set, val);
> >  		}
> >  
> >  		tst_its_set_interval_from_us(&new_set, tc->it_interval_tv_usec);
> > -		tst_its_set_value_from_us(&new_set, val);
> >  
> >  		TEST(tv->timer_settime(timer, tc->flag, tst_its_get(&new_set), tst_its_get(tc->old_ptr)));
> >  
> > 
> > 
> > By adding the us to the timenow first and then setting the its.value
> > from it we can avoid the rounding completely.
> 
> Does this fix work for you?
> 

Sorry, I was out on vacation. This fixes it for me when using
clocksource=jiffies.

Thanks.
Cascardo.

> -- 
> Cyril Hrubis
> chrubis@suse.cz


More information about the ltp mailing list