aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2017-09-21 15:05:18 -0400
committerShuah Khan <shuahkh@osg.samsung.com>2017-09-25 12:09:07 -0400
commiteefd95e1f3d47b90dc768e9ebc77d390c4f34809 (patch)
tree0ff7cd4c9d969e3f41263fdfc33c9c08ebd8af0a
parent01db7fbf5487505b887fbd6a03c51f2adc952196 (diff)
selftests: timers: set-timer-lat: Fix hang when testing unsupported alarms
When timer_create() fails on a bootime or realtime clock, setup_timer() returns 0 as if timer has been set. Callers wait forever for the timer to expire. This hang is seen on a system that doesn't have support for: CLOCK_REALTIME_ALARM ABSTIME missing CAP_WAKE_ALARM? : [UNSUPPORTED] Test hangs waiting for a timer that hasn't been set to expire. Fix setup_timer() to return 1, add handling in callers to detect the unsupported case and return 0 without waiting to not fail the test. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
-rw-r--r--tools/testing/selftests/timers/set-timer-lat.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
index ea1af5dbc7b6..50da45437daa 100644
--- a/tools/testing/selftests/timers/set-timer-lat.c
+++ b/tools/testing/selftests/timers/set-timer-lat.c
@@ -143,7 +143,8 @@ int setup_timer(int clock_id, int flags, int interval, timer_t *tm1)
143 printf("%-22s %s missing CAP_WAKE_ALARM? : [UNSUPPORTED]\n", 143 printf("%-22s %s missing CAP_WAKE_ALARM? : [UNSUPPORTED]\n",
144 clockstring(clock_id), 144 clockstring(clock_id),
145 flags ? "ABSTIME":"RELTIME"); 145 flags ? "ABSTIME":"RELTIME");
146 return 0; 146 /* Indicate timer isn't set, so caller doesn't wait */
147 return 1;
147 } 148 }
148 printf("%s - timer_create() failed\n", clockstring(clock_id)); 149 printf("%s - timer_create() failed\n", clockstring(clock_id));
149 return -1; 150 return -1;
@@ -213,8 +214,9 @@ int do_timer(int clock_id, int flags)
213 int err; 214 int err;
214 215
215 err = setup_timer(clock_id, flags, interval, &tm1); 216 err = setup_timer(clock_id, flags, interval, &tm1);
217 /* Unsupported case - return 0 to not fail the test */
216 if (err) 218 if (err)
217 return err; 219 return err == 1 ? 0 : err;
218 220
219 while (alarmcount < 5) 221 while (alarmcount < 5)
220 sleep(1); 222 sleep(1);
@@ -231,8 +233,9 @@ int do_timer_oneshot(int clock_id, int flags)
231 int err; 233 int err;
232 234
233 err = setup_timer(clock_id, flags, interval, &tm1); 235 err = setup_timer(clock_id, flags, interval, &tm1);
236 /* Unsupported case - return 0 to not fail the test */
234 if (err) 237 if (err)
235 return err; 238 return err == 1 ? 0 : err;
236 239
237 memset(&timeout, 0, sizeof(timeout)); 240 memset(&timeout, 0, sizeof(timeout));
238 timeout.tv_sec = 5; 241 timeout.tv_sec = 5;