blob: 4f34f51a02fe91d87842f4616b9efd64372a9a39 [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. Levin3d463be2015-08-02 01:41:26 +00007 r_socket = "^socket\\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\\) += 0<UNIX:\\[(" r_i ")\\]>$"
Masatake YAMATO6077ad82014-12-24 20:59:32 +09008}
9
Dmitry V. Levin3d463be2015-08-02 01:41:26 +000010NR == 1 {
11 if (match($0, r_socket, a)) {
12 inode_listen = a[2]
13 r_bind = "^bind\\(0<UNIX:\\[" inode_listen "\\]>, \\{sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"" addr "\"\\}, " addrlen "\\) += 0$"
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000014 r_listen = "^listen\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>, 5\\) += 0$"
Dmitry V. Levined7ada22015-01-13 00:06:09 +000015 r_getsockname = "^getsockname\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>, \\{sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"" addr "\"\\}, \\[" addrlen "\\]\\) += 0$"
16 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 +090017 next
18 }
19}
20
Dmitry V. Levin3d463be2015-08-02 01:41:26 +000021NR == 2 {if (r_bind != "" && match($0, r_bind)) next}
22
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000023NR == 3 {if (r_listen != "" && match($0, r_listen)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090024
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000025NR == 4 {if (r_getsockname != "" && match($0, r_getsockname)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090026
27NR == 5 {
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000028 if (r_accept != "" && match($0, r_accept, a)) {
29 inode_accepted = a[2]
30 inode_peer = a[3]
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000031 r_close_listen = "^close\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>\\) += 0$"
32 r_close_accepted = "^close\\(1<UNIX:\\[" inode_accepted ",\"" addr "\"\\]>\\) += 0$"
Masatake YAMATO6077ad82014-12-24 20:59:32 +090033 next
34 }
35}
36
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000037NR == 6 {if (r_close_listen != "" && match($0, r_close_listen)) next}
38NR == 7 {if (r_close_accepted != "" && match($0, r_close_accepted)) next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090039
Dmitry V. Levinf0ed1672014-12-25 00:32:23 +000040NR == lines && $0 == "+++ exited with 0 +++" {next}
Masatake YAMATO6077ad82014-12-24 20:59:32 +090041
42{
43 print "Line " NR " does not match: " $0
44 fail=1
45}
46
47END {
48 if (NR != lines) {
49 print "Expected " lines " lines, found " NR " line(s)."
50 print ""
51 exit 1
52 }
53 if (fail) {
54 print ""
55 exit 1
56 }
57}