• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #include <sys/select.h>
18 #include <sys/time.h>
19 #include <sys/types.h>
20 #include <errno.h>
21 
22 #include "tst_timer_test.h"
23 
sample_fn(int clk_id,long long usec)24 int sample_fn(int clk_id, long long usec)
25 {
26 	fd_set readfds;
27 	struct timespec tv = tst_us_to_timespec(usec);
28 
29 	FD_ZERO(&readfds);
30 	FD_SET(0, &readfds);
31 
32 	tst_timer_start(clk_id);
33 	TEST(pselect(0, &readfds, NULL, NULL, &tv, NULL));
34 	tst_timer_stop();
35 	tst_timer_sample();
36 
37 	if (TST_RET != 0) {
38 		tst_res(TFAIL | TTERRNO,
39 			"pselect() returned %li on timeout", TST_RET);
40 		return 1;
41 	}
42 
43 	return 0;
44 }
45 
46 static struct tst_test test = {
47 	.scall = "pselect()",
48 	.sample = sample_fn,
49 };
50