blob: 7f0a9cb82b848a3740cb6c70fb588f8131ec0730 [file] [log] [blame]
Masatake YAMATO6077ad82014-12-24 20:59:32 +09001BEGIN {
2 lines = 8
3 fail = 0
4
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +00005 addrlen = length(addr) + 3
Masatake YAMATO6077ad82014-12-24 20:59:32 +09006 r_i = "[1-9][0-9]*"
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +00007 r_bind = "^bind\\(0<UNIX:\\[(" r_i ")\\]>, {sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"" addr "\"}, " addrlen "\\) += 0$"
Masatake YAMATO6077ad82014-12-24 20:59:32 +09008}
9
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000010NR == 1 && /^socket\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 0$/ {next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090011
12NR == 2 {
13 if (match($0, r_bind, a)) {
14 inode_listen = a[1]
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000015 r_listen = "^listen\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>, 5\\) += 0$"
16 r_getsockname = "^getsockname\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>, {sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"" addr "\"}, \\[" addrlen "\\]\\) += 0$"
17 r_accept = "^accept\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>, {sa_family=AF_(LOCAL|UNIX|FILE), NULL}, \\[2\\]\\) += 1<UNIX:\\[(" r_i ")->(" r_i "),\"" addr "\"\\]>"
Masatake YAMATO6077ad82014-12-24 20:59:32 +090018 next
19 }
20}
21
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000022NR == 3 {if (r_listen != "" && match($0, r_listen)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090023
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000024NR == 4 {if (r_getsockname != "" && match($0, r_getsockname)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090025
26NR == 5 {
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000027 if (r_accept != "" && match($0, r_accept, a)) {
28 inode_accepted = a[2]
29 inode_peer = a[3]
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000030 r_close_listen = "^close\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>\\) += 0$"
31 r_close_accepted = "^close\\(1<UNIX:\\[" inode_accepted ",\"" addr "\"\\]>\\) += 0$"
Masatake YAMATO6077ad82014-12-24 20:59:32 +090032 next
33 }
34}
35
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000036NR == 6 {if (r_close_listen != "" && match($0, r_close_listen)) next}
37NR == 7 {if (r_close_accepted != "" && match($0, r_close_accepted)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090038
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000039NR == lines && $0 == "+++ exited with 0 +++" {next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090040
41{
42 print "Line " NR " does not match: " $0
43 fail=1
44}
45
46END {
47 if (NR != lines) {
48 print "Expected " lines " lines, found " NR " line(s)."
49 print ""
50 exit 1
51 }
52 if (fail) {
53 print ""
54 exit 1
55 }
56}