• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016 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 
18 /*
19  * If personality with STICKY_TIMEOUTS is used select() timeout is not updated.
20  */
21 
22 #include "test.h"
23 #include <sys/personality.h>
24 #include <sys/select.h>
25 
26 char *TCID = "personality02";
27 int TST_TOTAL = 1;
28 
29 #define USEC 10
30 
verify_personality(void)31 static void verify_personality(void)
32 {
33 	struct timeval tv = {.tv_sec = 0, .tv_usec = USEC};
34 	int ret;
35 	fd_set rfds;
36 
37 	FD_ZERO(&rfds);
38 	FD_SET(1, &rfds);
39 
40 	personality(PER_LINUX | STICKY_TIMEOUTS);
41 	ret = select(2, &rfds, NULL, NULL, &tv);
42 	personality(PER_LINUX);
43 	if (ret < 0)
44 		tst_resm(TBROK | TERRNO, "select()");
45 
46 	if (tv.tv_usec != USEC)
47 		tst_resm(TFAIL, "Timeout was modified");
48 	else
49 		tst_resm(TPASS, "Timeout wasn't modified");
50 }
51 
main(int ac,char ** av)52 int main(int ac, char **av)
53 {
54 	int lc;
55 
56 	tst_parse_opts(ac, av, NULL, NULL);
57 
58 	for (lc = 0; TEST_LOOPING(lc); lc++)
59 		verify_personality();
60 
61 	tst_exit();
62 }
63