[LTP] [PATCH V6 01/17] syscalls/timer_gettime: Add support for time64 tests
Cyril Hrubis
chrubis@suse.cz
Thu Jun 25 13:07:51 CEST 2020
Hi!
> > > +static void verify(void)
> > > +{
> > > + struct test_variants *tv = &variants[tst_variant];
> > > + struct tst_its spec = {.type = tv->type, };
> > > +
> > > + TEST(tv->func(timer, tst_its_get(&spec)));
> > > + if (TST_RET == 0) {
> > > + tst_res(TPASS, "timer_gettime() Passed");
> > > + } else {
> > > + tst_res(TFAIL | TTERRNO, "timer_gettime() Failed");
> > > }
> >
> > Looking at manuals it seems that:
> >
> > * Newly created timer is disarmed
> >
> > * For disarmed timers the clock_gettime() should get itimer with zeroes
> >
> > So we check here that the returned itimer has zeroes for both oneshoot
> > and interval timers here.
>
> I am not sure what oneshoot/interval timers you are talking about :)
These are the two timerspec structures inside of the itimerspec, one of
them is for oneshoot timer/alarm and the second one is for reocurring
timer/alarm and called interval.
> This is what I came to, is this sufficient ?
>
> diff --git a/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c b/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
> index ea7cc6b59f7e..4a949486a920 100644
> --- a/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
> +++ b/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
> @@ -55,7 +55,19 @@ static void verify(void)
>
> TEST(tv->func(timer, tst_its_get(&spec)));
> if (TST_RET == 0) {
> - tst_res(TPASS, "timer_gettime() Passed");
> + if ((spec.type == TST_KERN_OLD_TIMESPEC &&
> + (spec.ts.kern_old_its.it_interval.tv_sec ||
> + spec.ts.kern_old_its.it_interval.tv_nsec ||
> + spec.ts.kern_old_its.it_value.tv_sec ||
> + spec.ts.kern_old_its.it_value.tv_nsec)) ||
> + (spec.type == TST_KERN_TIMESPEC &&
> + (spec.ts.kern_its.it_interval.tv_sec ||
> + spec.ts.kern_its.it_interval.tv_nsec ||
> + spec.ts.kern_its.it_value.tv_sec ||
> + spec.ts.kern_its.it_value.tv_nsec)))
> + tst_res(TFAIL, "timespec should have been zeroed");
Indeed that's what I had in mind, can we please abstract this properly
as well? I guess that we can add helpers such as tst_its_interval_sec()
tst_its_inverval_nsec, etc.
> + else
> + tst_res(TPASS, "timer_gettime() Passed");
> } else {
> tst_res(TFAIL | TTERRNO, "timer_gettime() Failed");
> }
>
> --
> viresh
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list