* [LTP] [PATCH] timer_settime01: Check signal timing
@ 2024-07-30 15:20 Martin Doucha
2024-07-31 9:48 ` Petr Vorel
2024-08-01 12:56 ` Cyril Hrubis
0 siblings, 2 replies; 4+ messages in thread
From: Martin Doucha @ 2024-07-30 15:20 UTC (permalink / raw)
To: ltp
Add a new check that the timer signal does not get delivered too early.
Also fix a bug where tc->it_value_tv_usec was ignored in TIMER_ABSTIME
subtests.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
.../syscalls/timer_settime/timer_settime01.c | 49 +++++++++++++------
1 file changed, 33 insertions(+), 16 deletions(-)
diff --git a/testcases/kernel/syscalls/timer_settime/timer_settime01.c b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
index 6fa1e7487..f8e7ffa22 100644
--- a/testcases/kernel/syscalls/timer_settime/timer_settime01.c
+++ b/testcases/kernel/syscalls/timer_settime/timer_settime01.c
@@ -58,8 +58,11 @@ static struct time64_variants variants[] = {
static volatile int caught_signal;
-static void clear_signal(void)
+static void clear_signal(clock_t clock, const struct tst_ts *exptime)
{
+ struct time64_variants *tv = &variants[tst_variant];
+ struct tst_ts curtime = { .type = tv->ts_type };
+
/*
* The busy loop is intentional. The signal is sent after X
* seconds of CPU time has been accumulated for the process and
@@ -74,6 +77,17 @@ static void clear_signal(void)
}
caught_signal = 0;
+
+ if (tv->clock_gettime(clock, tst_ts_get(&curtime)) < 0) {
+ tst_res(TFAIL, "clock_gettime(%s) failed",
+ get_clock_str(clock));
+ return;
+ }
+
+ if (tst_ts_lt(curtime, *exptime)) {
+ tst_res(TFAIL, "Timer %s expired too early",
+ get_clock_str(clock));
+ }
}
static void sighandler(int sig)
@@ -116,22 +130,22 @@ static void run(unsigned int n)
memset(&new_set, 0, sizeof(new_set));
memset(&old_set, 0, sizeof(old_set));
- new_set.type = old_set.type = tv->ts_type;
+ new_set.type = old_set.type = timenow.type = tv->ts_type;
val = tc->it_value_tv_usec;
- if (tc->flag & TIMER_ABSTIME) {
- timenow.type = tv->ts_type;
- if (tv->clock_gettime(clock, tst_ts_get(&timenow)) < 0) {
- tst_res(TFAIL,
- "clock_gettime(%s) failed - skipping the test",
- get_clock_str(clock));
- continue;
- }
- tst_ts_add_us(timenow, val);
+ if (tv->clock_gettime(clock, tst_ts_get(&timenow)) < 0) {
+ tst_res(TFAIL,
+ "clock_gettime(%s) failed - skipping the test",
+ get_clock_str(clock));
+ continue;
+ }
+
+ timenow = tst_ts_add_us(timenow, val);
+
+ if (tc->flag & TIMER_ABSTIME)
tst_its_set_value_from_ts(&new_set, timenow);
- } else {
+ else
tst_its_set_value_from_us(&new_set, val);
- }
tst_its_set_interval_from_us(&new_set, tc->it_interval_tv_usec);
@@ -157,11 +171,14 @@ static void run(unsigned int n)
tst_its_get_value_nsec(new_set));
}
- clear_signal();
+ clear_signal(clock, &timenow);
/* Wait for another event when interval was set */
- if (tc->it_interval_tv_usec)
- clear_signal();
+ if (tc->it_interval_tv_usec) {
+ timenow = tst_ts_add_us(timenow,
+ tc->it_interval_tv_usec);
+ clear_signal(clock, &timenow);
+ }
tst_res(TPASS, "timer_settime(%s) passed",
get_clock_str(clock));
--
2.44.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] timer_settime01: Check signal timing
2024-07-30 15:20 [LTP] [PATCH] timer_settime01: Check signal timing Martin Doucha
@ 2024-07-31 9:48 ` Petr Vorel
2024-08-01 12:56 ` Cyril Hrubis
1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2024-07-31 9:48 UTC (permalink / raw)
To: Martin Doucha; +Cc: ltp
Hi Martin,
> Add a new check that the timer signal does not get delivered too early.
> Also fix a bug where tc->it_value_tv_usec was ignored in TIMER_ABSTIME
> subtests.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
LGTM, but I'll wait little longer to give others change to have look.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] timer_settime01: Check signal timing
2024-07-30 15:20 [LTP] [PATCH] timer_settime01: Check signal timing Martin Doucha
2024-07-31 9:48 ` Petr Vorel
@ 2024-08-01 12:56 ` Cyril Hrubis
2024-08-15 9:57 ` Petr Vorel
1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2024-08-01 12:56 UTC (permalink / raw)
To: Martin Doucha; +Cc: ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] timer_settime01: Check signal timing
2024-08-01 12:56 ` Cyril Hrubis
@ 2024-08-15 9:57 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2024-08-15 9:57 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi all,
merged, thanks!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-15 9:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-30 15:20 [LTP] [PATCH] timer_settime01: Check signal timing Martin Doucha
2024-07-31 9:48 ` Petr Vorel
2024-08-01 12:56 ` Cyril Hrubis
2024-08-15 9:57 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox