blob: 67613666d03f9a501cfb76cbcabdaab17a7fb2b3 [file] [log] [blame]
Dmitry V. Levinfdfa7222014-09-23 00:14:04 +00001BEGIN {
2 lines = 5
3 fail = 0
4
Dmitry V. Levinfdfa7222014-09-23 00:14:04 +00005 r_i = "[1-9][0-9]*"
6 r_port = "[1-9][0-9][0-9][0-9]+"
7 r_localhost = "127\\.0\\.0\\.1"
Dmitry V. Levined7ada22015-01-13 00:06:09 +00008 r_connect = "^connect\\(0<TCP:\\[" r_i "\\]>, \\{sa_family=AF_INET, sin_port=htons\\((" r_port ")\\), sin_addr=inet_addr\\(\"" r_localhost "\"\\)\\}, " r_i ") += 0$"
Dmitry V. Levinfdfa7222014-09-23 00:14:04 +00009}
10
11NR == 1 && /^socket\(PF_INET, SOCK_STREAM, IPPROTO_IP\) += 0$/ {next}
12
13NR == 2 {
14 if (match($0, r_connect, a)) {
Dmitry V. Levin959205c2014-12-26 23:29:26 +000015 port_r = a[1]
16 r_send = "^send\\(0<TCP:\\[" r_localhost ":(" r_port ")->" r_localhost ":" port_r "\\]>, \"data\", 4, MSG_DONTROUTE\\) += 4$"
17 r_sendto = "^sendto\\(0<TCP:\\[" r_localhost ":(" r_port ")->" r_localhost ":" port_r "\\]>, \"data\", 4, MSG_DONTROUTE, NULL, 0\\) += 4$"
Dmitry V. Levinfdfa7222014-09-23 00:14:04 +000018 next
19 }
20}
21
22NR == 3 {
Dmitry V. Levin959205c2014-12-26 23:29:26 +000023 if (r_send != "" && (match($0, r_send, a) || match($0, r_sendto, a))) {
Dmitry V. Levinfdfa7222014-09-23 00:14:04 +000024 port_l = a[1]
Dmitry V. Levin959205c2014-12-26 23:29:26 +000025 r_close = "^close\\(0<TCP:\\[" r_localhost ":" port_l "->" r_localhost ":" port_r "\\]>\\) += 0$"
Dmitry V. Levinfdfa7222014-09-23 00:14:04 +000026 next
27 }
28}
29
Dmitry V. Levin959205c2014-12-26 23:29:26 +000030NR == 4 {if (r_close != "" && match($0, r_close)) next}
Dmitry V. Levinfdfa7222014-09-23 00:14:04 +000031
Dmitry V. Levin959205c2014-12-26 23:29:26 +000032NR == lines && $0 == "+++ exited with 0 +++" {next}
Dmitry V. Levinfdfa7222014-09-23 00:14:04 +000033
34{
35 print "Line " NR " does not match: " $0
36 fail=1
37}
38
39END {
40 if (NR != lines) {
41 print "Expected " lines " lines, found " NR " line(s)."
42 print ""
43 exit 1
44 }
45 if (fail) {
46 print ""
47 exit 1
48 }
49}