Debian Codegraph @

testsuite/systemtap.syscall/poll.c

raw
1 /* COVERAGE: epoll_create epoll_create1 epoll_ctl epoll_wait epoll_pwait */
2 /* COVERAGE: poll ppoll */
3 #define _GNU_SOURCE
4 #include <stdio.h>
5 #include <unistd.h>
6 #include <sys/epoll.h>
7 #include <poll.h>
8 #include <signal.h>
9 #include <sys/syscall.h>
10
11
12 #ifdef SYS_epoll_pwait
13 static inline int
14 __epoll_pwait(int epfd, struct epoll_event *events, int maxevents, int timeout,
15 const sigset_t *set)
16 {
17 return syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout,
18 set, _NSIG / 8);
19 }
20 #endif
21
22 int main()
23 {
24 struct epoll_event ev, events[17];
25 struct pollfd pfd = {7, 0x23, 0};
26 int fd;
27 struct timespec tim = {.tv_sec=0, .tv_nsec=200000000};
28 sigset_t sigs;
29
30 sigemptyset(&sigs);
31 sigaddset(&sigs,SIGUSR2);
32
33 #ifdef EPOLL_CLOEXEC
34 fd = epoll_create1(EPOLL_CLOEXEC);
35 //staptest// epoll_create1 (EPOLL_CLOEXEC) = NNNN
36
37 epoll_create1(-1);
38 //staptest// epoll_create1 (EPOLL_CLOEXEC|0xfff7ffff) = -NNNN (EINVAL)
39 #else
40 fd = epoll_create(32);
41 //staptest// epoll_create (32) = NNNN
42
43 epoll_create(-1);
44 //staptest// epoll_create (-1) = -NNNN (EINVAL)
45 #endif
46
47 epoll_ctl(fd, EPOLL_CTL_ADD, 13, &ev);
48 //staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, 13, XXXX) = -NNNN (EBADF)
49
50 epoll_ctl(-1, EPOLL_CTL_ADD, 13, &ev);
51 //staptest// epoll_ctl (-1, EPOLL_CTL_ADD, 13, XXXX) = -NNNN (EBADF)
52
53 epoll_ctl(fd, -1, 13, &ev);
54 //staptest// epoll_ctl (NNNN, 0xffffffff, 13, XXXX) = -NNNN (EBADF)
55
56 epoll_ctl(fd, EPOLL_CTL_ADD, -1, &ev);
57 //staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, -1, XXXX) = -NNNN (EBADF)
58
59 epoll_ctl(fd, EPOLL_CTL_ADD, 13, (struct epoll_event *)-1);
60 #ifdef __s390__
61 //staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, 13, 0x[7]?[f]+) = -NNNN (EFAULT)
62 #else
63 //staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, 13, 0x[f]+) = -NNNN (EFAULT)
64 #endif
65
66 epoll_wait(fd, events, 17, 0);
67 // epoll_wait() can be implemented in terms of epoll_pwait()
68 //staptest// [[[[epoll_wait (NNNN, XXXX, 17, 0)!!!!epoll_pwait (NNNN, XXXX, 17, 0, XXXX, NNNN)]]]] = 0
69
70 epoll_wait(-1, events, 17, 0);
71 //staptest// [[[[epoll_wait (-1, XXXX, 17, 0)!!!!epoll_pwait (-1, XXXX, 17, 0, XXXX, NNNN)]]]] = -NNNN (EBADF)
72
73 epoll_wait(fd, (struct epoll_event *)-1, 17, 0);
74 #ifdef __s390__
75 //staptest// [[[[epoll_wait (NNNN, 0x[7]?[f]+, 17, 0)!!!!epoll_pwait (NNNN, 0x[7]?[f]+, 17, 0, XXXX, NNNN)]]]] = NNNN
76 #else
77 //staptest// [[[[epoll_wait (NNNN, 0x[f]+, 17, 0)!!!!epoll_pwait (NNNN, 0x[f]+, 17, 0, XXXX, NNNN)]]]] = NNNN
78 #endif
79
80 epoll_wait(fd, events, -1, 0);
81 //staptest// [[[[epoll_wait (NNNN, XXXX, -1, 0)!!!!epoll_pwait (NNNN, XXXX, -1, 0, XXXX, NNNN)]]]] = NNNN (EINVAL)
82
83 epoll_wait(-1, events, 17, -1);
84 //staptest// [[[[epoll_wait (-1, XXXX, 17, -1)!!!!epoll_pwait (-1, XXXX, 17, -1, XXXX, NNNN)]]]] = NNNN (EBADF)
85
86 // RHEL5 x86_64 defines SYS_epoll_pwait, but doesn't have epoll_pwait()
87 #ifdef SYS_epoll_pwait
88 __epoll_pwait(fd, events, 17, 0, NULL);
89 //staptest// [[[[epoll_pwait (NNNN, XXXX, 17, 0, 0x0, NNNN) = 0!!!!ni_syscall () = -38 (ENOSYS)]]]]
90
91 __epoll_pwait(fd, events, 17, 0, &sigs);
92 //staptest// [[[[epoll_pwait (NNNN, XXXX, 17, 0, XXXX, NNNN) = 0!!!!ni_syscall () = -38 (ENOSYS)]]]]
93
94 __epoll_pwait(-1, events, 17, 0, &sigs);
95 //staptest// [[[[epoll_pwait (-1, XXXX, 17, 0, XXXX, NNNN) = -NNNN (EBADF)!!!!ni_syscall () = -38 (ENOSYS)]]]]
96
97 __epoll_pwait(fd, (struct epoll_event *)-1, 17, 0, &sigs);
98 #ifdef __s390__
99 //staptest// epoll_pwait (NNNN, 0x[7]?[f]+, 17, 0, XXXX, NNNN) =
100 #else
101 //staptest// [[[[epoll_pwait (NNNN, 0x[f]+, 17, 0, XXXX, NNNN) =!!!!ni_syscall () = -38 (ENOSYS)]]]]
102 #endif
103
104 __epoll_pwait(fd, events, -1, 0, &sigs);
105 //staptest// [[[[epoll_pwait (NNNN, XXXX, -1, 0, XXXX, NNNN) = -NNNN (EINVAL)!!!!ni_syscall () = -38 (ENOSYS)]]]]
106
107 __epoll_pwait(-1, events, 17, -1, &sigs);
108 //staptest// [[[[epoll_pwait (-1, XXXX, 17, -1, XXXX, NNNN) = -NNNN (EBADF)!!!!ni_syscall () = -38 (ENOSYS)]]]]
109
110 __epoll_pwait(fd, events, 17, 0, (sigset_t *)-1);
111 #ifdef __s390__
112 //staptest// epoll_pwait (NNNN, XXXX, 17, 0, 0x[7]?[f]+, NNNN) = -NNNN (EFAULT)
113 #else
114 //staptest// [[[[epoll_pwait (NNNN, XXXX, 17, 0, 0x[f]+, NNNN) = -NNNN (EFAULT)!!!!ni_syscall () = -38 (ENOSYS)]]]]
115 #endif
116 #endif
117
118 close(fd);
119 //staptest// close (NNNN) = 0
120
121 poll(&pfd, 1, 0);
122 #if defined(__aarch64__)
123 //staptest// ppoll (XXXX, 1, \[0.000000000\], XXXX, NNNN) = NNNN
124 #else
125 //staptest// poll (XXXX, 1, 0) = NNNN
126 #endif
127
128 poll((struct pollfd *)-1, 1, 0);
129 #ifdef __s390__
130 //staptest// poll (0x[7]?[f]+, 1, 0) = -NNNN (EFAULT)
131 #elif defined(__aarch64__)
132 //staptest// ppoll (0x[f]+, 1, \[0.000000000\], XXXX, NNNN) = -NNNN (EFAULT)
133 #else
134 //staptest// poll (0x[f]+, 1, 0) = -NNNN (EFAULT)
135 #endif
136
137 poll(&pfd, -1, 0);
138 #if defined(__aarch64__)
139 //staptest// ppoll (XXXX, 4294967295, \[0.000000000\], XXXX, NNNN) = -NNNN (EINVAL)
140 #else
141 //staptest// poll (XXXX, 4294967295, 0) = -NNNN (EINVAL)
142 #endif
143
144 // A timetout value of -1 means an infinite timeout. So, we'll also
145 // send a NULL pollfd structure pointer.
146 poll(NULL, 1, -1);
147 #if defined(__aarch64__)
148 //staptest// ppoll (0x0, 1, NULL, XXXX, NNNN) = -NNNN (EFAULT)
149 #else
150 //staptest// poll (0x0, 1, -1) = -NNNN (EFAULT)
151 #endif
152
153 #ifdef SYS_ppoll
154 ppoll(&pfd, 1, &tim, &sigs);
155 //staptest// ppoll (XXXX, 1, \[0.200000000\], XXXX, 8) = NNNN
156
157 ppoll((struct pollfd *)-1, 1, &tim, &sigs);
158 #ifdef __s390__
159 //staptest// ppoll (0x[7]?[f]+, 1, \[0.200000000\], XXXX, 8) = -NNNN (EFAULT)
160 #else
161 //staptest// ppoll (0x[f]+, 1, \[0.200000000\], XXXX, 8) = -NNNN (EFAULT)
162 #endif
163
164 ppoll(&pfd, -1, &tim, &sigs);
165 //staptest// ppoll (XXXX, 4294967295, \[0.200000000\], XXXX, 8) = -NNNN (EINVAL)
166
167 // Specifying a timespec pointer of -1 will crash the test
168 // executable, so we'll have to skip it.
169 //ppoll((struct pollfd *)-1, 1, (struct timespec *)-1, &sigs);
170
171 ppoll(&pfd, 1, &tim, (sigset_t *)-1);
172 #ifdef __s390__
173 //staptest// ppoll (XXXX, 1, \[0.200000000\], 0x[7]?[f]+, 8) = -NNNN (EFAULT)
174 #else
175 //staptest// ppoll (XXXX, 1, \[0.200000000\], 0x[f]+, 8) = -NNNN (EFAULT)
176 #endif
177 #endif
178
179 return 0;
180 }