timer_settime02: Catch SIGALRM
PATCH 1/1 timer_settime02: Catch SIGALRM
If any of the tested timers expires due to a bug, the test will be killed by SIGALRM. Catch the signal and report a failure.
Signed-off-by Martin Doucha <[email protected]>
--- .../syscalls/timer_settime/timer_settime02.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
testcases/kernel/syscalls/timer_settime/timer_settime02.c +15 -0
@@ -33,6 +33,7 @@ static struct tst_its *pnew_set = &new_set, *pold_set = &old_set, *null_set = NUstatic void *faulty_set;static kernel_timer_t timer;static kernel_timer_t timer_inval = (kernel_timer_t)-1 ; +static volatile int caught_sig;/* separate description-array to (hopefully) improve readability */ static const char *const descriptions[] = {
@@ -69,10 +70,16 @@ static struct time64_variants variants[] = {#endif }; +static void sighandler (int sig) +{ + caught_sig = sig; +} +static void setup (void ) {tst_res (TINFO ,"Testing variant: %s" , variants[tst_variant].desc); faulty_set =tst_get_bad_addr (NULL ); +signal (SIGALRM , sighandler); }static void run (unsigned int n)
@@ -87,6 +94,8 @@ static void run(unsigned int n)for (i =0 ; i <CLOCKS_DEFINED ; ++i) {clock_t clock = clock_list[i]; + caught_sig =0 ; +/* Init temporary timer */ TEST (tst_syscall (__NR_timer_create, clock,NULL , &timer));if (TST_RET !=0 ) {
@@ -131,6 +140,12 @@ static void run(unsigned int n)TEST (tst_syscall (__NR_timer_delete, timer));if (TST_RET !=0 )tst_res (TFAIL |TTERRNO ,"timer_delete() failed!" ); + +if (caught_sig) { +tst_res (TFAIL , +"Caught unexpected signal %s while testing %s" , +tst_strsig (caught_sig),get_clock_str (clock)); + } } }
Signature · 5 lines
2.44.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Martin,
Quoted 2 lines
If any of the tested timers expires due to a bug, the test will be killed by SIGALRM. Catch the signal and report a failure.
Thanks, merged!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp