Debian Codegraph @

testsuite/systemtap.syscall/accept.c

raw
1 /* COVERAGE: accept */
2
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <string.h>
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <sys/un.h>
9 #include <netinet/in.h>
10 #include <signal.h>
11 #include <errno.h>
12 #include <stdlib.h>
13 #include <sys/stat.h>
14 #include <fcntl.h>
15
16 int main()
17 {
18 int s, fd_null;
19 struct sockaddr_in sin1;
20 socklen_t sinlen;
21
22 /* On several platforms, glibc substitutes accept4() for
23 * accept(). So, we'll just accept accept() or accept4(). */
24
25 /* initialize sockaddr's */
26 sin1.sin_family = AF_INET;
27 sin1.sin_port = htons((getpid() % 32768) + 11000);
28 sin1.sin_addr.s_addr = INADDR_ANY;
29 sinlen = sizeof(sin1);
30
31 fd_null = open("/dev/null", O_WRONLY);
32
33 accept(-1, (struct sockaddr *)&sin1, &sinlen);
34 //staptest// accept[4]? (-1, XXXX, XXXX[[[[, 0x0]]]]?) = -NNNN (EBADF)
35
36 accept(fd_null, (struct sockaddr *)&sin1, &sinlen);
37 //staptest// accept[4]? (NNNN, XXXX, XXXX[[[[, 0x0]]]]?) = -NNNN (ENOTSOCK)
38
39 s = socket(PF_INET, SOCK_STREAM, 0);
40 //staptest// socket (PF_INET, SOCK_STREAM, IPPROTO_IP) = NNNN
41
42 bind(s, (struct sockaddr *)&sin1, sizeof(sin1));
43 //staptest// bind (NNNN, {AF_INET, 0.0.0.0, NNNN}, 16) = NNNN
44
45 accept(s, (struct sockaddr *)-1, &sinlen);
46 //staptest// accept[4]? (NNNN, 0x[f]+, XXXX[[[[, 0x0]]]]?) = -NNNN (EINVAL)
47
48 accept(s, (struct sockaddr *)&sin1, (socklen_t *)-1);
49 //staptest// accept[4]? (NNNN, XXXX, 0x[f]+[[[[, 0x0]]]]?) = -NNNN (EINVAL)
50
51 close(s);
52 //staptest// close (NNNN) = 0
53
54 close(fd_null);
55 //staptest// close (NNNN) = 0
56
57 return 0;
58 }