summaryrefslogtreecommitdiff
path: root/extra/testing.exp
blob: 4ddd79609a38dca4d8a152007df7ab567dae7aa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/usr/bin/expect -f
#
# Usage: testing.ex <path to arping> <ip address> <mac address>
#
# Test all cases against a "normal" machine:
# * Responds to ARP
# * Responds to ping
# * Doesn't respond to broadcast pings.
#
# Abnormal machines, to be tested elsewhere:
# * Proxy ARP
# * Respond to broadcast pings
# * Lost packets
# * Duplicated replies
#
# Tested here:
# * -a
# * -c
# * -D
# * -e
# * -h
# * -q (soon)
# * -r (soon)
# * -R (soon)
# * -s (soon)
# * -S (soon)
# * -t
# * -T
# * -u (soon)
# * -v (soon)
# * -w (soon)
# * -W (soon)
#
# Not tested here:
# * -0
# * -A (forced on with mac ping)
# * -b
# * -B
# * -d
# * -p
# * -U
# * Mac ping without -T.
#
set bin [lindex $argv 0]
set ip [lindex $argv 1]
set mac [lindex $argv 2]
set bad_ip "1.2.4.3"
set bad_mac "00:11:22:33:44:55"

send_user -- "--------------- No options ------------------\n"
spawn $bin
expect -re "ARPing 2\.\d+, by Thomas Habets <thomas@habets.se>\r
usage: arping \\\[ -0aAbdDeFpqrRuUv \\\] \\\[ -w <us> \\\] \\\[ -S <host/ip> \\\]\r
\\\[ -T <host/ip \\\] \\\[ -s <MAC> \\\] \\\[ -t <MAC> \\\] \\\[ -c <count> \\\]\r
\\\[ -i <interface> \\\] <host/ip/MAC | -B>\r
For complete usage info, use --help or check the manpage.\r
"
expect eof

send_user -- "--------------- -h ------------------\n"
spawn $bin -h
expect -re "ARPing 2\.\d+, by Thomas Habets <thomas@habets.se>\r
usage: arping \\\[ -0aAbdDeFpqrRuUv \\\] \\\[ -w <us> \\\] \\\[ -S <host/ip> \\\]\r
\\\[ -T <host/ip \\\] \\\[ -s <MAC> \\\] \\\[ -t <MAC> \\\] \\\[ -c <count> \\\]\r
\\\[ -i <interface> \\\] <host/ip/MAC | -B>\r
For complete usage info, use --help or check the manpage.\r
"
expect eof

send_user -- "--------------- --help ------------------\n"
spawn $bin --help
expect -re "ARPing 2\.\d+, by Thomas Habets <thomas@habets.se>\r
usage: arping \\\[ -0aAbdDeFpqrRuUv \\\] \\\[ -w <us> \\\] \\\[ -S <host/ip> \\\]\r
\\\[ -T <host/ip \\\] \\\[ -s <MAC> \\\] \\\[ -t <MAC> \\\] \\\[ -c <count> \\\]\r
\\\[ -i <interface> \\\] <host/ip/MAC | -B>\r
\r
"
expect "Report bugs to: thomas@habets.se\r
Arping home page: <http://www.habets.pp.se/synscan/>\r
Development repo: http://github.com/ThomasHabets/arping\r
"
expect eof

send_user -- "--------------- Ping IP Simple ------------------\n"
spawn $bin -c 1 $ip
expect -re "ARPING $ip\r
60 bytes from $mac \\($ip\\): index=0 time=(.*)sec\r
\r
--- $ip statistics ---\r
1 packets transmitted, 1 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/0.000 ms\r
"
expect eof

send_user -- "--------------- Ping IP Raw (-r) ------------------\n"
spawn $bin -c 2 -r $ip
expect -re "$mac\r
$mac\r
"
expect eof

send_user -- "--------------- Ping IP Raw audio (-r -a) ------------------\n"
spawn $bin -c 2 -r -a $ip
expect -re "\a$mac\r
\a$mac\r
"
expect eof

send_user -- "--------------- Ping IP Raw audio bad dest (-r -e) ------------------\n"
spawn $bin -c 2 -r -e $bad_ip
expect -re "\a\a"
expect eof

send_user -- "--------------- Ping IP reverse raw (-R) ------------------\n"
spawn $bin -c 2 -R $ip
expect -re "$ip\r
$ip\r
"
expect eof

send_user -- "--------------- Ping IP double raw (-R) ------------------\n"
spawn $bin -c 2 -R -r $ip
expect -re "$mac $ip\r
$mac $ip\r
"
expect eof

send_user -- "--------------- Ping IP max 2 (-C) ------------------\n"
spawn $bin -C 2 -c 10 $ip
expect -re "ARPING $ip\r
60 bytes from $mac \\($ip\\): index=0 time=(.*)sec\r
60 bytes from $mac \\($ip\\): index=1 time=(.*)sec\r
\r
--- $ip statistics ---\r
2 packets transmitted, 2 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
"
expect eof

send_user -- "--------------- Ping IP x 3 (-c) ------------------\n"
spawn $bin -c 3 $ip
expect -re "ARPING $ip\r
60 bytes from $mac \\($ip\\): index=0 time=\[0-9.\]+ \[mu\]?sec\r
60 bytes from $mac \\($ip\\): index=1 time=\[0-9.\]+ \[mu\]?sec\r
60 bytes from $mac \\($ip\\): index=2 time=\[0-9.\]+ \[mu\]?sec\r
\r
--- $ip statistics ---\r
3 packets transmitted, 3 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
"
expect eof

send_user -- "--------------- Ping IP x 3 with audio (-a)  ------------------\n"
spawn $bin -c 3 -a $ip
expect -re "ARPING $ip\r
\a60 bytes from $mac \\($ip\\): index=0 time=\[0-9.\]+ \[mu\]?sec\r
\a60 bytes from $mac \\($ip\\): index=1 time=\[0-9.\]+ \[mu\]?sec\r
\a60 bytes from $mac \\($ip\\): index=2 time=\[0-9.\]+ \[mu\]?sec\r
\r
--- $ip statistics ---\r
3 packets transmitted, 3 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
"
expect eof

send_user -- "--------- Ping IP x 2 with inverted audio (-e)  ------------\n"
spawn $bin -c 2 -e $ip
expect -re "ARPING $ip\r
60 bytes from $mac \\($ip\\): index=0 time=\[0-9.\]+ \[mu\]?sec\r
60 bytes from $mac \\($ip\\): index=1 time=\[0-9.\]+ \[mu\]?sec\r
\r
--- $ip statistics ---\r
2 packets transmitted, 2 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
"
expect eof

send_user -- "--------- Ping IP x 2 with inverted audio, bad IP (-e)  ------------\n"
spawn $bin -c 2 -e "$bad_ip"
expect -re "ARPING $bad_ip\r
\aTimeout\r
\aTimeout\r
\r
--- $bad_ip statistics ---\r
2 packets transmitted, 0 packets received, 100% unanswered \\(0 extra\\)\r
\r
"
expect eof

send_user -- "--------- Ping IP x 2 with inverted audio (-e -D)  ------------\n"
spawn $bin -c 2 -e -D $ip
expect "!!\t  0% packet loss (0 extra)\r\n"
expect eof

send_user -- "--------- Ping IP x 2 with inverted audio, bad IP (-e -D)  ------------\n"
spawn $bin -c 2 -e -i eth0 -D "$bad_ip"
expect "\a.\a.\t100% packet loss (0 extra)\r\n"
expect eof

send_user -- "--------------- Ping IP cisco style (-D) ------------------\n"
spawn $bin -c 3 -D $ip
expect "!!!\t  0% packet loss (0 extra)\r\n"
expect eof

send_user -- "--------------- Ping IP cisco style with audio (-D -a) -----------\n"
spawn $bin -c 3 -D -a $ip
expect "\a!\a!\a!\t  0% packet loss (0 extra)\r\n"
expect eof

send_user -- "--------------- Ping IP Targeted (-t) ------------------\n"
spawn $bin -c 1 $ip -t $mac
expect -re "ARPING $ip\r
60 bytes from $mac \\($ip\\): index=0 time=(.*)sec\r
\r
--- $ip statistics ---\r
1 packets transmitted, 1 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/0.000 ms\r
"
expect eof

send_user -- "--------------- Ping IP Mistargeted (-t) ------------------\n"
spawn $bin -c 1 $ip -t $bad_mac
expect "ARPING $ip\r
Timeout\r
\r
--- $ip statistics ---\r
1 packets transmitted, 0 packets received, 100% unanswered \\(0 extra\\)\r
"
expect eof

send_user -- "--------------- Ping MAC with IP destination ------------------\n"
spawn $bin -A -c 1 $mac -T $ip
expect -re "ARPING $mac\r
60 bytes from $ip \\($mac\\): icmp_seq=0 time=(.*)sec\r
\r
--- $mac statistics ---\r
1 packets transmitted, 1 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/0.000 ms\r
"
expect eof

send_user -- "--------------- Ping MAC Raw (-r) ------------------\n"
spawn $bin -c 2 -r $mac -T $ip
expect -re "$ip\r
$ip\r
"
expect eof

send_user -- "--------------- Ping MAC Raw audio (-r -a) ------------------\n"
spawn $bin -c 2 -a -r $mac -T $ip
expect -re "\a$ip\r
\a$ip\r
"
expect eof

send_user -- "--------------- Ping MAC Raw audio bad dest (-r -e) ------------------\n"
spawn $bin -c 2 -r -e $bad_mac -T $ip
expect -re "\a\a"
expect eof

send_user -- "--------------- Ping MAC reverse raw (-R) ------------------\n"
spawn $bin -c 2 -R $mac -T $ip
expect -re "$mac\r
$mac\r
"
expect eof

send_user -- "--------------- Ping MAC double raw (-a -R) ------------------\n"
spawn $bin -c 2 -R -r $mac -T $ip
expect -re "$mac $ip\r
$mac $ip\r
"
expect eof


send_user -- "--------------- Ping MAC max 2 (-C) ------------------\n"
spawn $bin -A -C 2 -c 10 $mac -T $ip
expect -re "ARPING $mac\r
60 bytes from $ip \\($mac\\): icmp_seq=0 time=(.*)sec\r
60 bytes from $ip \\($mac\\): icmp_seq=1 time=(.*)sec\r
\r
--- $mac statistics ---\r
2 packets transmitted, 2 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
"
expect eof

send_user -- "--------------- Ping MAC cisco style (-D) ------------------\n"
spawn $bin -A -c 3 -D $mac -T $ip
expect "!!!\t  0% packet loss (0 extra)\r\n"
expect eof

send_user -- "--------------- Ping MAC cisco style with audio (-D -a) -----------\n"
spawn $bin -A -c 3 -D -a $mac -T $ip
expect "\a!\a!\a!\t  0% packet loss (0 extra)\r\n"
expect eof

send_user -- "--------- Ping MAC x 2 with inverted audio (-e)  ------------\n"
spawn $bin -c 2 "$mac" -T $ip
expect -re "ARPING $mac\r
60 bytes from $ip \\($mac\\): icmp_seq=0 time=(.*)sec\r
60 bytes from $ip \\($mac\\): icmp_seq=1 time=(.*)sec\r
\r
--- $mac statistics ---\r
2 packets transmitted, 2 packets received,   0% unanswered \\(0 extra\\)\r
rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
"
expect eof

send_user -- "--------- Ping MAC x 2 with inverted audio, bad dest (-e)  ------------\n"
spawn $bin -e -c 2 "$bad_mac" -T $ip
expect -re "ARPING $bad_mac\r
\aTimeout\r
\aTimeout\r
\r
--- $bad_mac statistics ---\r
2 packets transmitted, 0 packets received, 100% unanswered \\(0 extra\\)\r
\r
"
expect eof

send_user -- "--------- Ping MAC x 2 with inverted audio (-e -D)  ------------\n"
spawn $bin -A -e -c 2 -D $mac -T $ip
expect "!!\t  0% packet loss (0 extra)\r\n"
expect eof

send_user -- "--------- Ping MAC x 2 with inverted audio, bad dest (-e -D)  ------------\n"
spawn $bin -A -c 2 -e -i eth0 -D $bad_mac -T $ip
expect "\a.\a.\t100% packet loss (0 extra)\r\n"
expect eof