diff mbox series

[V3] syscalls/timer_settime01: Make sure the timer fires

Message ID 47e40724c2a7a9612aca0265e493e62c69d65996.1594204153.git.viresh.kumar@linaro.org
State Accepted
Headers show
Series [V3] syscalls/timer_settime01: Make sure the timer fires | expand

Commit Message

Viresh Kumar July 8, 2020, 10:31 a.m. UTC
This patch improves the testcase by doing multiple things:

- Make sure the timer fires and catch the signals.

- Verify the values set to the itimerspec by reading them again using
  timer_gettime() syscalls.

- Reduce the timer interval, 5 seconds was way too much.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
V3:
- Changed timer values to 100 ms instead of 1 sec and that resulted in
  few changes.
- Moved some code around to keep related bits together.
- Improved check for testing value read from timer.

 .../syscalls/timer_settime/timer_settime01.c  | 106 ++++++++++++------
 1 file changed, 70 insertions(+), 36 deletions(-)

Comments

Cyril Hrubis July 14, 2020, 2:28 p.m. UTC | #1
Hi!
Pushed with minor changes, thanks.

Among other fixes I've moved the signal check from the signal handler to
the clear_signal() function, since the tst_res() function is not
signal-async-safe...

diff --git a/testcases/kernel/syscalls/timer_settime/timer_settime01.c b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
index f9d1456da..76f283b81 100644
--- a/testcases/kernel/syscalls/timer_settime/timer_settime01.c
+++ b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
@@ -10,7 +10,7 @@
 /*
  * This tests the timer_settime(2) syscall under various conditions:
  *
- * 1) General initialization: No old_value, no flags, 5-second-timer
+ * 1) General initialization: No old_value, no flags
  * 2) Setting a pointer to a itimerspec struct as old_set parameter
  * 3) Using a periodic timer
  * 4) Using absolute time
@@ -38,10 +38,10 @@ static struct testcase {
 	int			flag;
 	char			*description;
 } tcases[] = {
-	{NULL, 100000, 0, 0, "general initialization"},
-	{&old_set, 100000, 0, 0, "setting old_value"},
-	{&old_set, 100000, 100000, 0, "using periodic timer"},
-	{&old_set, 100000, 0, TIMER_ABSTIME, "using absolute time"},
+	{NULL, 50000, 0, 0, "general initialization"},
+	{&old_set, 50000, 0, 0, "setting old_value"},
+	{&old_set, 50000, 50000, 0, "using periodic timer"},
+	{&old_set, 50000, 0, TIMER_ABSTIME, "using absolute time"},
 };
 
 static struct test_variants {
@@ -71,15 +71,17 @@ static void clear_signal(void)
 	 */
 	while (!caught_signal);
 
+	if (caught_signal != SIGALRM) {
+		tst_res(TFAIL, "Received incorrect signal: %s",
+			tst_strsig(caught_signal));
+	}
+
 	caught_signal = 0;
 }
 
 static void sighandler(int sig)
 {
-	if (sig != SIGALRM)
-		tst_res(TFAIL, "Received incorrect signal: %d", sig);
-
-	caught_signal = 1;
+	caught_signal = sig;
 }
 
 static void setup(void)
Viresh Kumar July 15, 2020, 2:36 a.m. UTC | #2
On 14-07-20, 16:28, Cyril Hrubis wrote:
> Hi!
> Pushed with minor changes, thanks.
> 
> Among other fixes I've moved the signal check from the signal handler to
> the clear_signal() function, since the tst_res() function is not
> signal-async-safe...

What does that mean ? I remember that I added it there in
clear_signal() first, but then I tried to print the stuff (forcefully)
from sighandler() and it worked without any issues and so I did that.
Cyril Hrubis July 15, 2020, 8:53 a.m. UTC | #3
Hi!
> > Pushed with minor changes, thanks.
> > 
> > Among other fixes I've moved the signal check from the signal handler to
> > the clear_signal() function, since the tst_res() function is not
> > signal-async-safe...
> 
> What does that mean ? I remember that I added it there in
> clear_signal() first, but then I tried to print the stuff (forcefully)
> from sighandler() and it worked without any issues and so I did that.

Calling printf() from signal handler is not safe, which tst_res() does.

It will work fine 99% of the cases and this is the reason most people do
it anyways. One of the failure modes is the malloc arena lock. Printf
may allocate temporary buffer so if the signal comes when the process is
in the malloc code the process will hang forewer because it will try to
acquire a lock that has been locked before we jumped into the signal
handler, but there is probably more. It usually gets triggered on
stranger architectures, x86 is quite forgiving in this regard.

Signal handlers are generally tricky and there is a list of functions
that carefuly avoid messing with any global state and can be safely used
from withing a signal handler (man 7 signal-safety) anything else is,
unlikely to fail, but still potential hazard.

Generally the safest approach to signal handlers is to set a variable
and exit, which is what I usually do in tests...
Yang Xu July 23, 2020, 2:39 a.m. UTC | #4
Hi Viresh, Cyril

When tesing timer_settime01 on 3.10.0-1136.el7.x86_64, this case fails 
whether we use any type clock.

timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) 
reported bad values (0: 678013000): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) 
reported bad values (0: 358240000): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed

Best Regards
Yang Xu


> Hi!
> Pushed with minor changes, thanks.
> 
> Among other fixes I've moved the signal check from the signal handler to
> the clear_signal() function, since the tst_res() function is not
> signal-async-safe...
> 
> diff --git a/testcases/kernel/syscalls/timer_settime/timer_settime01.c b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
> index f9d1456da..76f283b81 100644
> --- a/testcases/kernel/syscalls/timer_settime/timer_settime01.c
> +++ b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
> @@ -10,7 +10,7 @@
>   /*
>    * This tests the timer_settime(2) syscall under various conditions:
>    *
> - * 1) General initialization: No old_value, no flags, 5-second-timer
> + * 1) General initialization: No old_value, no flags
>    * 2) Setting a pointer to a itimerspec struct as old_set parameter
>    * 3) Using a periodic timer
>    * 4) Using absolute time
> @@ -38,10 +38,10 @@ static struct testcase {
>   	int			flag;
>   	char			*description;
>   } tcases[] = {
> -	{NULL, 100000, 0, 0, "general initialization"},
> -	{&old_set, 100000, 0, 0, "setting old_value"},
> -	{&old_set, 100000, 100000, 0, "using periodic timer"},
> -	{&old_set, 100000, 0, TIMER_ABSTIME, "using absolute time"},
> +	{NULL, 50000, 0, 0, "general initialization"},
> +	{&old_set, 50000, 0, 0, "setting old_value"},
> +	{&old_set, 50000, 50000, 0, "using periodic timer"},
> +	{&old_set, 50000, 0, TIMER_ABSTIME, "using absolute time"},
>   };
>   
>   static struct test_variants {
> @@ -71,15 +71,17 @@ static void clear_signal(void)
>   	 */
>   	while (!caught_signal);
>   
> +	if (caught_signal != SIGALRM) {
> +		tst_res(TFAIL, "Received incorrect signal: %s",
> +			tst_strsig(caught_signal));
> +	}
> +
>   	caught_signal = 0;
>   }
>   
>   static void sighandler(int sig)
>   {
> -	if (sig != SIGALRM)
> -		tst_res(TFAIL, "Received incorrect signal: %d", sig);
> -
> -	caught_signal = 1;
> +	caught_signal = sig;
>   }
>   
>   static void setup(void)
>
Viresh Kumar July 24, 2020, 3:37 a.m. UTC | #5
Hi,

On 23-07-20, 10:39, Yang Xu wrote:
> When tesing timer_settime01 on 3.10.0-1136.el7.x86_64, this case fails
> whether we use any type clock.
> 
> timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
> timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) reported
> bad values (0: 678013000): SUCCESS (0)
> timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
> timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) reported
> bad values (0: 358240000): SUCCESS (0)
> timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
> timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed

Can you share the complete test log? I am not sure if only the _ALARM
cocks are failing or all. You are getting values in the order of
300-700 ms, while the max value can't be greater than 50 ms. So seems
like a kernel issue to me. Over that, both _ALARM type clocks weren't
supported before 3.11 and looks like your kernel version is 3.10.
Yang Xu July 24, 2020, 5:07 a.m. UTC | #6
Hi Virsh


> Hi,
> 
> On 23-07-20, 10:39, Yang Xu wrote:
>> When tesing timer_settime01 on 3.10.0-1136.el7.x86_64, this case fails
>> whether we use any type clock.
>>
>> timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
>> timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) reported
>> bad values (0: 678013000): SUCCESS (0)
>> timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
>> timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) reported
>> bad values (0: 358240000): SUCCESS (0)
>> timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
>> timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed
> 
> Can you share the complete test log? I am not sure if only the _ALARM
> cocks are failing or all. You are getting values in the order of
> 300-700 ms, while the max value can't be greater than 50 ms. So seems
> like a kernel issue to me. Over that, both _ALARM type clocks weren't
> supported before 3.11 and looks like your kernel version is 3.10.
Yes, only _ALARM fails. I  only find a kernel patch (commit 
11ffa9d6065f344  timerfd: Add alarm timers) introduced alarm clock types 
for timefd in kernel 3.11 and  a kernel patch (commit 9a7adcf5c6dea63d 
timers: Posix interface for alarm-timers)  in kernel 3.1. It seems my 
kernel version has supported this two alarm clock, but not sure why this 
case fails.


  the full log as below:
tst_test.c:1247: INFO: Timeout per run is 0h 05m 00s
timer_settime01.c:89: INFO: Testing variant: syscall with old kernel spec
timer_settime01.c:100: INFO: Testing for general initialization:
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_MONOTONIC) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_PROCESS_CPUTIME_ID) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_THREAD_CPUTIME_ID) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) 
reported bad values (0: 570013221): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) 
reported bad values (0: 250240851): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed
timer_settime01.c:100: INFO: Testing for setting old_value:
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_MONOTONIC) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_PROCESS_CPUTIME_ID) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_THREAD_CPUTIME_ID) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) 
reported bad values (0: 972013941): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) 
reported bad values (0: 652241546): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed
timer_settime01.c:100: INFO: Testing for using periodic timer:
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_MONOTONIC) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_PROCESS_CPUTIME_ID) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_THREAD_CPUTIME_ID) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) 
reported bad values (50000000: 624015649): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) 
reported bad values (50000000: 354248401): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed
timer_settime01.c:100: INFO: Testing for using absolute time:
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_MONOTONIC) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_PROCESS_CPUTIME_ID) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_THREAD_CPUTIME_ID) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) 
reported bad values (0: 176017000): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) 
reported bad values (0: 856247000): SUCCESS (0)
timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed

>
Viresh Kumar July 24, 2020, 10:18 a.m. UTC | #7
On 24-07-20, 13:07, Yang Xu wrote:
> Yes, only _ALARM fails.

Right. So this seems this is rather a kernel issue. And I am not
really sure how to handle these.

Cyril, Any ideas ? Do we even try to support 3.10 here ?
Yang Xu July 24, 2020, 10:27 a.m. UTC | #8
Hi Viresh


> On 24-07-20, 13:07, Yang Xu wrote:
>> Yes, only _ALARM fails.
> 
> Right. So this seems this is rather a kernel issue. And I am not
> really sure how to handle these.
> 
> Cyril, Any ideas ? Do we even try to support 3.10 here ?

ltp supports kernel 3.10. minimal supported kernel and (g)libc version 
discussion is here[1].  I don't know this is a backport bug or a 
upstream kernel bug(has fixed). I will figure out this on next week.

[1]https://github.com/linux-test-project/ltp/issues/657
>
Cyril Hrubis July 24, 2020, 1:29 p.m. UTC | #9
Hi!
> >> When tesing timer_settime01 on 3.10.0-1136.el7.x86_64, this case fails
> >> whether we use any type clock.
> >>
> >> timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
> >> timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) reported
> >> bad values (0: 678013000): SUCCESS (0)
> >> timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
> >> timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) reported
> >> bad values (0: 358240000): SUCCESS (0)
> >> timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
> >> timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed
> > 
> > Can you share the complete test log? I am not sure if only the _ALARM
> > cocks are failing or all. You are getting values in the order of
> > 300-700 ms, while the max value can't be greater than 50 ms. So seems
> > like a kernel issue to me. Over that, both _ALARM type clocks weren't
> > supported before 3.11 and looks like your kernel version is 3.10.
> Yes, only _ALARM fails. I  only find a kernel patch (commit 
> 11ffa9d6065f344  timerfd: Add alarm timers) introduced alarm clock types 
> for timefd in kernel 3.11 and  a kernel patch (commit 9a7adcf5c6dea63d 
> timers: Posix interface for alarm-timers)  in kernel 3.1. It seems my 
> kernel version has supported this two alarm clock, but not sure why this 
> case fails.

This is on RHEL kernel that has backported the _ALARM support right? So
this may as well be case of badly bacported patch...
Yang Xu July 24, 2020, 3:01 p.m. UTC | #10
HI Cyril


> Hi!
>>>> When tesing timer_settime01 on 3.10.0-1136.el7.x86_64, this case fails
>>>> whether we use any type clock.
>>>>
>>>> timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME) passed
>>>> timer_settime01.c:164: FAIL: timer_gettime(CLOCK_BOOTTIME_ALARM) reported
>>>> bad values (0: 678013000): SUCCESS (0)
>>>> timer_settime01.c:174: PASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
>>>> timer_settime01.c:164: FAIL: timer_gettime(CLOCK_REALTIME_ALARM) reported
>>>> bad values (0: 358240000): SUCCESS (0)
>>>> timer_settime01.c:174: PASS: timer_settime(CLOCK_REALTIME_ALARM) passed
>>>> timer_settime01.c:174: PASS: timer_settime(CLOCK_TAI) passed
>>>
>>> Can you share the complete test log? I am not sure if only the _ALARM
>>> cocks are failing or all. You are getting values in the order of
>>> 300-700 ms, while the max value can't be greater than 50 ms. So seems
>>> like a kernel issue to me. Over that, both _ALARM type clocks weren't
>>> supported before 3.11 and looks like your kernel version is 3.10.
>> Yes, only _ALARM fails. I  only find a kernel patch (commit
>> 11ffa9d6065f344  timerfd: Add alarm timers) introduced alarm clock types
>> for timefd in kernel 3.11 and  a kernel patch (commit 9a7adcf5c6dea63d
>> timers: Posix interface for alarm-timers)  in kernel 3.1. It seems my
>> kernel version has supported this two alarm clock, but not sure why this
>> case fails.
> 
> This is on RHEL kernel that has backported the _ALARM support right? So
> this may as well be case of badly bacported patch...
Just double check. My previous word may  make you feel confused.
On RHEL7 kernel, timer_* includes ALARM supports because kernel has 
upported it since 3.1 and timers_fd doesn't introduced ALARM 
support(REHL7 doesn't backport this patch). IMO, this case doesn't 
call/use timerfd_* function. We only need timer_*  ALARM suuport to run 
this case. so it doesn't need to backport ALARM support. Or, I miss some 
thing?
>
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/timer_settime/timer_settime01.c b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
index 08fb56e4943a..f9d1456dabe9 100644
--- a/testcases/kernel/syscalls/timer_settime/timer_settime01.c
+++ b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
@@ -33,33 +33,61 @@  static timer_t timer;
 
 static struct testcase {
 	struct tst_its		*old_ptr;
-	int			it_value_tv_sec;
-	int			it_interval_tv_sec;
+	int			it_value_tv_usec;
+	int			it_interval_tv_usec;
 	int			flag;
 	char			*description;
 } tcases[] = {
-	{NULL,     5, 0, 0, "general initialization"},
-	{&old_set, 5, 0, 0, "setting old_value"},
-	{&old_set, 0, 5, 0, "using periodic timer"},
-	{&old_set, 5, 0, TIMER_ABSTIME, "using absolute time"},
+	{NULL, 100000, 0, 0, "general initialization"},
+	{&old_set, 100000, 0, 0, "setting old_value"},
+	{&old_set, 100000, 100000, 0, "using periodic timer"},
+	{&old_set, 100000, 0, TIMER_ABSTIME, "using absolute time"},
 };
 
 static struct test_variants {
-	int (*gettime)(clockid_t clk_id, void *ts);
-	int (*func)(timer_t timerid, int flags, void *its,
-		    void *old_its);
+	int (*cgettime)(clockid_t clk_id, void *ts);
+	int (*tgettime)(timer_t timer, void *its);
+	int (*func)(timer_t timerid, int flags, void *its, void *old_its);
 	enum tst_ts_type type;
 	char *desc;
 } variants[] = {
 #if (__NR_timer_settime != __LTP__NR_INVALID_SYSCALL)
-	{ .gettime = sys_clock_gettime, .func = sys_timer_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+	{ .cgettime = sys_clock_gettime, .tgettime = sys_timer_gettime, .func = sys_timer_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
 #endif
 
 #if (__NR_timer_settime64 != __LTP__NR_INVALID_SYSCALL)
-	{ .gettime = sys_clock_gettime64, .func = sys_timer_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+	{ .cgettime = sys_clock_gettime64, .tgettime = sys_timer_gettime64, .func = sys_timer_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
 #endif
 };
 
+static volatile int caught_signal;
+
+static void clear_signal(void)
+{
+	/*
+	 * The busy loop is intentional. The signal is sent after X
+	 * seconds of CPU time has been accumulated for the process and
+	 * thread specific clocks.
+	 */
+	while (!caught_signal);
+
+	caught_signal = 0;
+}
+
+static void sighandler(int sig)
+{
+	if (sig != SIGALRM)
+		tst_res(TFAIL, "Received incorrect signal: %d", sig);
+
+	caught_signal = 1;
+}
+
+static void setup(void)
+{
+	tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc);
+	SAFE_SIGNAL(SIGALRM, sighandler);
+}
+
 static void run(unsigned int n)
 {
 	struct test_variants *tv = &variants[tst_variant];
@@ -96,53 +124,59 @@  static void run(unsigned int n)
 		memset(&old_set, 0, sizeof(old_set));
 
 		new_set.type = old_set.type = tv->type;
-
-		val = tc->it_value_tv_sec;
+		val = tc->it_value_tv_usec;
 
 		if (tc->flag & TIMER_ABSTIME) {
 			timenow.type = tv->type;
-			if (tv->gettime(clock, tst_ts_get(&timenow)) < 0) {
+			if (tv->cgettime(clock, tst_ts_get(&timenow)) < 0) {
 				tst_res(TFAIL,
 					"clock_gettime(%s) failed - skipping the test",
 					get_clock_str(clock));
 				continue;
 			}
-			val += tst_ts_get_sec(timenow);
+			val += tst_ts_to_us(timenow);
 		}
 
-		tst_its_set_interval_sec(&new_set, tc->it_interval_tv_sec);
-		tst_its_set_interval_nsec(&new_set, 0);
-		tst_its_set_value_sec(&new_set, val);
-		tst_its_set_value_nsec(&new_set, 0);
+		tst_its_set_interval_from_us(&new_set, tc->it_interval_tv_usec);
+		tst_its_set_value_from_us(&new_set, val);
 
 		TEST(tv->func(timer, tc->flag, tst_its_get(&new_set), tst_its_get(tc->old_ptr)));
 
 		if (TST_RET != 0) {
-			tst_res(TFAIL | TTERRNO, "%s failed",
-					get_clock_str(clock));
-		} else {
-			tst_res(TPASS, "%s was successful",
-					get_clock_str(clock));
+			tst_res(TFAIL | TTERRNO, "timer_settime(%s) failed",
+				get_clock_str(clock));
 		}
 
+		TEST(tv->tgettime(timer, tst_its_get(&new_set)));
+		if (TST_RET != 0) {
+			tst_res(TFAIL | TTERRNO, "timer_gettime(%s) failed",
+				get_clock_str(clock));
+		} else if ((tst_its_get_interval_nsec(new_set) !=
+				tc->it_interval_tv_usec * 1000) ||
+			   (tst_its_get_value_nsec(new_set) >
+				MAX(tc->it_value_tv_usec * 1000, tc->it_interval_tv_usec * 1000))) {
+			tst_res(TFAIL | TTERRNO,
+				"timer_gettime(%s) reported bad values (%llu: %llu)",
+				get_clock_str(clock),
+				tst_its_get_interval_nsec(new_set),
+				tst_its_get_value_nsec(new_set));
+		}
+
+		clear_signal();
+
+		/* Wait for another event when interval was set */
+		if (tc->it_interval_tv_usec)
+			clear_signal();
+
+		tst_res(TPASS, "timer_settime(%s) passed",
+			get_clock_str(clock));
+
 		TEST(tst_syscall(__NR_timer_delete, timer));
 		if (TST_RET != 0)
 			tst_res(TFAIL | TTERRNO, "timer_delete() failed!");
 	}
 }
 
-static void sighandler(int sig)
-{
-	/* sighandler for CLOCK_*_ALARM */
-	tst_res(TINFO, "Caught signal %s", tst_strsig(sig));
-}
-
-static void setup(void)
-{
-	tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc);
-	SAFE_SIGNAL(SIGALRM, sighandler);
-}
-
 static struct tst_test test = {
 	.test = run,
 	.needs_root = 1,