]> granicus.if.org Git - strace/blob - tests/oldselect.c
tests: add oldselect.test
[strace] / tests / oldselect.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include <unistd.h>
6 #include <sys/select.h>
7 #include <sys/syscall.h>
8
9 #if defined __NR_select && defined __NR__newselect \
10  && __NR_select != __NR__newselect \
11  && !defined SPARC
12
13 int
14 main(void)
15 {
16         int fds[2];
17         fd_set r = {}, w = {};
18         struct timeval timeout = { .tv_sec = 0, .tv_usec = 42 };
19         long args[] = {
20                 2, (long) &r, (long) &w, 0, (long) &timeout,
21                 0xdeadbeef, 0xbadc0ded, 0xdeadbeef, 0xbadc0ded, 0xdeadbeef
22         };
23
24         (void) close(0);
25         (void) close(1);
26         if (pipe(fds))
27                 return 77;
28
29         FD_SET(0, &w);
30         FD_SET(1, &r);
31         if (syscall(__NR_select, args))
32                 return 77;
33
34         return 0;
35 }
36
37 #else
38
39 int
40 main(void)
41 {
42         return 77;
43 }
44
45 #endif