1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
4 */
5 #include <sys/select.h>
6 #include <sys/time.h>
7 #include <sys/types.h>
8 #include <errno.h>
9
10 #include "tst_timer_test.h"
11
sample_fn(int clk_id,long long usec)12 int sample_fn(int clk_id, long long usec)
13 {
14 fd_set readfds;
15 struct timespec tv = tst_timespec_from_us(usec);
16
17 FD_ZERO(&readfds);
18 FD_SET(0, &readfds);
19
20 tst_timer_start(clk_id);
21 TEST(pselect(0, &readfds, NULL, NULL, &tv, NULL));
22 tst_timer_stop();
23 tst_timer_sample();
24
25 if (TST_RET != 0) {
26 tst_res(TFAIL | TTERRNO,
27 "pselect() returned %li on timeout", TST_RET);
28 return 1;
29 }
30
31 return 0;
32 }
33
34 static struct tst_test test = {
35 .scall = "pselect()",
36 .sample = sample_fn,
37 };
38