• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2016 Linux Test Project
4  * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
5  * Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
6  */
7 
8 /*\
9  * [Description]
10  *
11  * This test checks if select() timeout is not updated when personality with
12  * STICKY_TIMEOUTS is used.
13  */
14 
15 #include "tst_test.h"
16 #include "lapi/personality.h"
17 #include <sys/select.h>
18 
19 #define USEC 10
20 
run(void)21 static void run(void)
22 {
23 	struct timeval tv = { .tv_sec = 0, .tv_usec = USEC };
24 	fd_set rfds;
25 
26 	FD_ZERO(&rfds);
27 	FD_SET(1, &rfds);
28 
29 	SAFE_PERSONALITY(PER_LINUX | STICKY_TIMEOUTS);
30 
31 	TEST(select(2, &rfds, NULL, NULL, &tv));
32 	if (TST_RET == -1)
33 		tst_brk(TBROK | TERRNO, "select() error");
34 
35 	SAFE_PERSONALITY(PER_LINUX);
36 
37 	TST_EXP_EQ_LI(tv.tv_usec, USEC);
38 }
39 
40 static struct tst_test test = {
41 	.test_all = run,
42 };
43