aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2017-09-21 15:46:01 -0400
committerShuah Khan <shuahkh@osg.samsung.com>2017-09-25 12:09:06 -0400
commit01db7fbf5487505b887fbd6a03c51f2adc952196 (patch)
treedecd8fa909f501187912abaf052566f747ba46f6
parent21aadfa2426d5d199ceb474d0159d079c7f17bfa (diff)
selftests: timers: set-timer-lat: fix hang when std out/err are redirected
do_timer_oneshot() uses select() as a timer with FD_SETSIZE and readfs is cleared with FD_ZERO without FD_SET. When stdout and stderr are redirected, the test hangs in select forever. Fix the problem calling select() with readfds empty and nfds zero. This is sufficient for using select() for timer. With this fix "./set-timer-lat > /dev/null 2>&1" no longer hangs. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Acked-by: Greg Hackmann <ghackmann@google.com> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
-rw-r--r--tools/testing/selftests/timers/set-timer-lat.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
index 9c92b7bd5641..ea1af5dbc7b6 100644
--- a/tools/testing/selftests/timers/set-timer-lat.c
+++ b/tools/testing/selftests/timers/set-timer-lat.c
@@ -228,7 +228,6 @@ int do_timer_oneshot(int clock_id, int flags)
228 timer_t tm1; 228 timer_t tm1;
229 const int interval = 0; 229 const int interval = 0;
230 struct timeval timeout; 230 struct timeval timeout;
231 fd_set fds;
232 int err; 231 int err;
233 232
234 err = setup_timer(clock_id, flags, interval, &tm1); 233 err = setup_timer(clock_id, flags, interval, &tm1);
@@ -237,9 +236,8 @@ int do_timer_oneshot(int clock_id, int flags)
237 236
238 memset(&timeout, 0, sizeof(timeout)); 237 memset(&timeout, 0, sizeof(timeout));
239 timeout.tv_sec = 5; 238 timeout.tv_sec = 5;
240 FD_ZERO(&fds);
241 do { 239 do {
242 err = select(FD_SETSIZE, &fds, NULL, NULL, &timeout); 240 err = select(0, NULL, NULL, NULL, &timeout);
243 } while (err == -1 && errno == EINTR); 241 } while (err == -1 && errno == EINTR);
244 242
245 timer_delete(tm1); 243 timer_delete(tm1);