blob: ad1d39ec86207c34899c8fa3eaa98186db6b1b2e [file] [log] [blame]
Masatake YAMATO6077ad82014-12-24 20:59:32 +09001BEGIN {
2 lines = 8
3 fail = 0
4
5 inode_listen = "?"
6 inode_accepted = "?"
7 inode_peer = "?"
8
9 r_i = "[1-9][0-9]*"
10 r_bind = "^bind\\(0<UNIX:\\[(" r_i ")\\]>, {sa_family=AF_LOCAL, sun_path=\"local-stream\"}, " r_i "\\) += 0$"
11 r_listen = "^/$"
12 r_getsockname = "^/$"
13 r_accept = "^/$"
14 r_close0 = "^/$"
15 r_close1 = "^/$"
16}
17
18NR == 1 && /^socket\(PF_LOCAL, SOCK_STREAM, 0\) += 0$/ {next}
19
20NR == 2 {
21 if (match($0, r_bind, a)) {
22 inode_listen = a[1]
23 r_listen = "^listen\\(0<UNIX:\\[" inode_listen ",\"local-stream\"\\]>, 5\\) += 0$"
24 r_getsockname = "^getsockname\\(0<UNIX:\\[" inode_listen ",\"local-stream\"\\]>, {sa_family=AF_LOCAL, sun_path=\"local-stream\"}, \\[" r_i "\\]\\) += 0$"
25 r_accept = "^accept\\(0<UNIX:\\[" inode_listen ",\"local-stream\"\\]>, {sa_family=AF_LOCAL, NULL}, \\[" r_i "\\]\\) += 1<UNIX:\\[(" r_i ")->(" r_i "),\"local-stream\"\\]>"
26 next
27 }
28}
29
30NR == 3 {if (match($0, r_listen)) next}
31
32NR == 4 {if (match($0, r_getsockname)) next}
33
34NR == 5 {
35 if (match($0, r_accept, a)) {
36 inode_accepted = a[1]
37 inode_peer = a[2]
38 print inode_accepted
39 r_close0 = "^close\\(0<UNIX:\\[" inode_listen ",\"local-stream\"\\]>\\) += 0$"
40 r_close1 = "^close\\(1<UNIX:\\[" inode_accepted ",\"local-stream\"\\]>\\) += 0$"
41 next
42 }
43}
44
45NR == 6 {if (match($0, r_close0)) next}
46NR == 7 {if (match($0, r_close1)) next}
47
48NR == lines && /^\+\+\+ exited with 0 \+\+\+$/ {next}
49
50{
51 print "Line " NR " does not match: " $0
52 fail=1
53}
54
55END {
56 if (NR != lines) {
57 print "Expected " lines " lines, found " NR " line(s)."
58 print ""
59 exit 1
60 }
61 if (fail) {
62 print ""
63 exit 1
64 }
65}