kselftests: timers: Make set-timer-lat fail more gracefully for !CAP_WAKE_ALARM
authorJohn Stultz <john.stultz@linaro.org>
Thu, 2 Apr 2015 03:43:39 +0000 (20:43 -0700)
committerShuah Khan <shuahkh@osg.samsung.com>
Thu, 2 Apr 2015 16:32:33 +0000 (10:32 -0600)
The set-timer-lat test fails when testing CLOCK_BOOTTIME_ALARM
or CLOCK_REALTIME_ALARM when the user isn't running as root or
with CAP_WAKE_ALARM.

So this patch improves the error checking so we report the
issue more clearly and continue rather then reporting a failure.

Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
tools/testing/selftests/timers/set-timer-lat.c

index 2ed326750ffeed21bd9bad55680e07475723c53d..4fc98c5b089972fadc77fea1c6d212b2685d4569 100644 (file)
@@ -139,6 +139,13 @@ int do_timer(int clock_id, int flags)
 
        err = timer_create(clock_id, &se, &tm1);
        if (err) {
+               if ((clock_id == CLOCK_REALTIME_ALARM) ||
+                   (clock_id == CLOCK_BOOTTIME_ALARM)) {
+                       printf("%-22s %s missing CAP_WAKE_ALARM?    : [UNSUPPORTED]\n",
+                                       clockstring(clock_id),
+                                       flags ? "ABSTIME":"RELTIME");
+                       return 0;
+               }
                printf("%s - timer_create() failed\n", clockstring(clock_id));
                return -1;
        }