kselftests: timers: set-timer-lat: Tweak reporting when timer fires early
Rather than printing an error inside the alarm signal handler, set a flag that we check later. This keeps the test from spamming the console every time the alarm fires early. It also fixes the test exiting with error code 0 if this was the only test failure. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Miroslav Lichvar <mlichvar@redhat.com> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Prarit Bhargava <prarit@redhat.com> Cc: Stephen Boyd <stephen.boyd@linaro.org> Cc: Shuah Khan <shuah@kernel.org> Cc: linux-kselftest@vger.kernel.org Signed-off-by: Greg Hackmann <ghackmann@google.com> Signed-off-by: John Stultz <john.stultz@linaro.org>
This commit is contained in:
parent
6cc636614e
commit
a524b1184b
|
@ -63,6 +63,7 @@ int alarmcount;
|
||||||
int clock_id;
|
int clock_id;
|
||||||
struct timespec start_time;
|
struct timespec start_time;
|
||||||
long long max_latency_ns;
|
long long max_latency_ns;
|
||||||
|
int timer_fired_early;
|
||||||
|
|
||||||
char *clockstring(int clockid)
|
char *clockstring(int clockid)
|
||||||
{
|
{
|
||||||
|
@ -115,12 +116,19 @@ void sigalarm(int signo)
|
||||||
delta_ns -= NSEC_PER_SEC * TIMER_SECS * alarmcount;
|
delta_ns -= NSEC_PER_SEC * TIMER_SECS * alarmcount;
|
||||||
|
|
||||||
if (delta_ns < 0)
|
if (delta_ns < 0)
|
||||||
printf("%s timer fired early: FAIL\n", clockstring(clock_id));
|
timer_fired_early = 1;
|
||||||
|
|
||||||
if (delta_ns > max_latency_ns)
|
if (delta_ns > max_latency_ns)
|
||||||
max_latency_ns = delta_ns;
|
max_latency_ns = delta_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void describe_timer(int flags)
|
||||||
|
{
|
||||||
|
printf("%-22s %s ",
|
||||||
|
clockstring(clock_id),
|
||||||
|
flags ? "ABSTIME":"RELTIME");
|
||||||
|
}
|
||||||
|
|
||||||
int do_timer(int clock_id, int flags)
|
int do_timer(int clock_id, int flags)
|
||||||
{
|
{
|
||||||
struct sigevent se;
|
struct sigevent se;
|
||||||
|
@ -136,6 +144,7 @@ int do_timer(int clock_id, int flags)
|
||||||
|
|
||||||
max_latency_ns = 0;
|
max_latency_ns = 0;
|
||||||
alarmcount = 0;
|
alarmcount = 0;
|
||||||
|
timer_fired_early = 0;
|
||||||
|
|
||||||
err = timer_create(clock_id, &se, &tm1);
|
err = timer_create(clock_id, &se, &tm1);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -170,18 +179,26 @@ int do_timer(int clock_id, int flags)
|
||||||
while (alarmcount < 5)
|
while (alarmcount < 5)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
printf("%-22s %s max latency: %10lld ns : ",
|
describe_timer(flags);
|
||||||
clockstring(clock_id),
|
printf("timer fired early: %7d : ", timer_fired_early);
|
||||||
flags ? "ABSTIME":"RELTIME",
|
if (!timer_fired_early) {
|
||||||
max_latency_ns);
|
printf("[OK]\n");
|
||||||
|
} else {
|
||||||
|
printf("[FAILED]\n");
|
||||||
|
err = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe_timer(flags);
|
||||||
|
printf("max latency: %10lld ns : ", max_latency_ns);
|
||||||
|
|
||||||
timer_delete(tm1);
|
timer_delete(tm1);
|
||||||
if (max_latency_ns < UNRESONABLE_LATENCY) {
|
if (max_latency_ns < UNRESONABLE_LATENCY) {
|
||||||
printf("[OK]\n");
|
printf("[OK]\n");
|
||||||
return 0;
|
} else {
|
||||||
|
printf("[FAILED]\n");
|
||||||
|
err = -1;
|
||||||
}
|
}
|
||||||
printf("[FAILED]\n");
|
return err;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
|
Loading…
Reference in New Issue