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