Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 1 | BEGIN { |
| 2 | lines = 8 |
| 3 | fail = 0 |
| 4 | |
Dmitry V. Levin | c9cc4cb | 2015-01-07 20:14:19 +0000 | [diff] [blame] | 5 | addrlen = length(addr) + 3 |
Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 6 | r_i = "[1-9][0-9]*" |
Dmitry V. Levin | ed7ada2 | 2015-01-13 00:06:09 +0000 | [diff] [blame] | 7 | r_bind = "^bind\\(0<UNIX:\\[(" r_i ")\\]>, \\{sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"" addr "\"\\}, " addrlen "\\) += 0$" |
Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 8 | } |
| 9 | |
Dmitry V. Levin | f0ed167 | 2014-12-25 00:32:23 +0000 | [diff] [blame] | 10 | NR == 1 && /^socket\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 0$/ {next} |
Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 11 | |
| 12 | NR == 2 { |
| 13 | if (match($0, r_bind, a)) { |
| 14 | inode_listen = a[1] |
Dmitry V. Levin | c9cc4cb | 2015-01-07 20:14:19 +0000 | [diff] [blame] | 15 | r_listen = "^listen\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>, 5\\) += 0$" |
Dmitry V. Levin | ed7ada2 | 2015-01-13 00:06:09 +0000 | [diff] [blame] | 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 YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 18 | next |
| 19 | } |
| 20 | } |
| 21 | |
Dmitry V. Levin | f0ed167 | 2014-12-25 00:32:23 +0000 | [diff] [blame] | 22 | NR == 3 {if (r_listen != "" && match($0, r_listen)) next} |
Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 23 | |
Dmitry V. Levin | f0ed167 | 2014-12-25 00:32:23 +0000 | [diff] [blame] | 24 | NR == 4 {if (r_getsockname != "" && match($0, r_getsockname)) next} |
Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 25 | |
| 26 | NR == 5 { |
Dmitry V. Levin | f0ed167 | 2014-12-25 00:32:23 +0000 | [diff] [blame] | 27 | if (r_accept != "" && match($0, r_accept, a)) { |
| 28 | inode_accepted = a[2] |
| 29 | inode_peer = a[3] |
Dmitry V. Levin | c9cc4cb | 2015-01-07 20:14:19 +0000 | [diff] [blame] | 30 | r_close_listen = "^close\\(0<UNIX:\\[" inode_listen ",\"" addr "\"\\]>\\) += 0$" |
| 31 | r_close_accepted = "^close\\(1<UNIX:\\[" inode_accepted ",\"" addr "\"\\]>\\) += 0$" |
Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 32 | next |
| 33 | } |
| 34 | } |
| 35 | |
Dmitry V. Levin | f0ed167 | 2014-12-25 00:32:23 +0000 | [diff] [blame] | 36 | NR == 6 {if (r_close_listen != "" && match($0, r_close_listen)) next} |
| 37 | NR == 7 {if (r_close_accepted != "" && match($0, r_close_accepted)) next} |
Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 38 | |
Dmitry V. Levin | f0ed167 | 2014-12-25 00:32:23 +0000 | [diff] [blame] | 39 | NR == lines && $0 == "+++ exited with 0 +++" {next} |
Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame] | 40 | |
| 41 | { |
| 42 | print "Line " NR " does not match: " $0 |
| 43 | fail=1 |
| 44 | } |
| 45 | |
| 46 | END { |
| 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 | } |