blob: bafee898e73e44701a0895171472f0f0a43b54eb [file] [log] [blame]
Masatake YAMATO6077ad82014-12-24 20:59:32 +09001BEGIN {
2 lines = 8
3 fail = 0
4
Masatake YAMATO6077ad82014-12-24 20:59:32 +09005 r_i = "[1-9][0-9]*"
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +00006 r_bind = "^bind\\(0<UNIX:\\[(" r_i ")\\]>, {sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"local-stream\"}, 15\\) += 0$"
Masatake YAMATO6077ad82014-12-24 20:59:32 +09007}
8
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +00009NR == 1 && /^socket\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 0$/ {next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090010
11NR == 2 {
12 if (match($0, r_bind, a)) {
13 inode_listen = a[1]
14 r_listen = "^listen\\(0<UNIX:\\[" inode_listen ",\"local-stream\"\\]>, 5\\) += 0$"
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000015 r_getsockname = "^getsockname\\(0<UNIX:\\[" inode_listen ",\"local-stream\"\\]>, {sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"local-stream\"}, \\[15\\]\\) += 0$"
16 r_accept = "^accept\\(0<UNIX:\\[" inode_listen ",\"local-stream\"\\]>, {sa_family=AF_(LOCAL|UNIX|FILE), NULL}, \\[2\\]\\) += 1<UNIX:\\[(" r_i ")->(" r_i "),\"local-stream\"\\]>"
Masatake YAMATO6077ad82014-12-24 20:59:32 +090017 next
18 }
19}
20
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000021NR == 3 {if (r_listen != "" && match($0, r_listen)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090022
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000023NR == 4 {if (r_getsockname != "" && match($0, r_getsockname)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090024
25NR == 5 {
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000026 if (r_accept != "" && match($0, r_accept, a)) {
27 inode_accepted = a[2]
28 inode_peer = a[3]
29 r_close_listen = "^close\\(0<UNIX:\\[" inode_listen ",\"local-stream\"\\]>\\) += 0$"
30 r_close_accepted = "^close\\(1<UNIX:\\[" inode_accepted ",\"local-stream\"\\]>\\) += 0$"
Masatake YAMATO6077ad82014-12-24 20:59:32 +090031 next
32 }
33}
34
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000035NR == 6 {if (r_close_listen != "" && match($0, r_close_listen)) next}
36NR == 7 {if (r_close_accepted != "" && match($0, r_close_accepted)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090037
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000038NR == lines && $0 == "+++ exited with 0 +++" {next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090039
40{
41 print "Line " NR " does not match: " $0
42 fail=1
43}
44
45END {
46 if (NR != lines) {
47 print "Expected " lines " lines, found " NR " line(s)."
48 print ""
49 exit 1
50 }
51 if (fail) {
52 print ""
53 exit 1
54 }
55}