Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3#
4# OVS kernel module self tests
5
6# Kselftest framework requirement - SKIP code is 4.
7ksft_skip=4
8
9PAUSE_ON_FAIL=no
10VERBOSE=0
11TRACING=0
12
13tests="
14 arp_ping eth-arp: Basic arp ping between two NS
15 ct_connect_v4 ip4-ct-xon: Basic ipv4 tcp connection using ct
16 connect_v4 ip4-xon: Basic ipv4 ping between two NS
17 nat_connect_v4 ip4-nat-xon: Basic ipv4 tcp connection via NAT
18 netlink_checks ovsnl: validate netlink attrs and settings
19 upcall_interfaces ovs: test the upcall interfaces
20 drop_reason drop: test drop reasons are emitted"
21
22info() {
23 [ $VERBOSE = 0 ] || echo $*
24}
25
26ovs_base=`pwd`
27sbxs=
28sbx_add () {
29 info "adding sandbox '$1'"
30
31 sbxs="$sbxs $1"
32
33 NO_BIN=0
34
35 # Create sandbox.
36 local d="$ovs_base"/$1
37 if [ -e $d ]; then
38 info "removing $d"
39 rm -rf "$d"
40 fi
41 mkdir "$d" || return 1
42 ovs_setenv $1
43}
44
45ovs_exit_sig() {
46 [ -e ${ovs_dir}/cleanup ] && . "$ovs_dir/cleanup"
47}
48
49on_exit() {
50 echo "$1" > ${ovs_dir}/cleanup.tmp
51 cat ${ovs_dir}/cleanup >> ${ovs_dir}/cleanup.tmp
52 mv ${ovs_dir}/cleanup.tmp ${ovs_dir}/cleanup
53}
54
55ovs_setenv() {
56 sandbox=$1
57
58 ovs_dir=$ovs_base${1:+/$1}; export ovs_dir
59
60 test -e ${ovs_dir}/cleanup || : > ${ovs_dir}/cleanup
61}
62
63ovs_sbx() {
64 if test "X$2" != X; then
65 (ovs_setenv $1; shift; "$@" >> ${ovs_dir}/debug.log)
66 else
67 ovs_setenv $1
68 fi
69}
70
71ovs_add_dp () {
72 info "Adding DP/Bridge IF: sbx:$1 dp:$2 {$3, $4, $5}"
73 sbxname="$1"
74 shift
75 ovs_sbx "$sbxname" python3 $ovs_base/ovs-dpctl.py add-dp $*
76 on_exit "ovs_sbx $sbxname python3 $ovs_base/ovs-dpctl.py del-dp $1;"
77}
78
79ovs_add_if () {
80 info "Adding IF to DP: br:$2 if:$3"
81 if [ "$4" != "-u" ]; then
82 ovs_sbx "$1" python3 $ovs_base/ovs-dpctl.py add-if "$2" "$3" \
83 || return 1
84 else
85 python3 $ovs_base/ovs-dpctl.py add-if \
86 -u "$2" "$3" >$ovs_dir/$3.out 2>$ovs_dir/$3.err &
87 pid=$!
88 on_exit "ovs_sbx $1 kill -TERM $pid 2>/dev/null"
89 fi
90}
91
92ovs_del_if () {
93 info "Deleting IF from DP: br:$2 if:$3"
94 ovs_sbx "$1" python3 $ovs_base/ovs-dpctl.py del-if "$2" "$3" || return 1
95}
96
97ovs_netns_spawn_daemon() {
98 sbx=$1
99 shift
100 netns=$1
101 shift
102 info "spawning cmd: $*"
103 ip netns exec $netns $* >> $ovs_dir/stdout 2>> $ovs_dir/stderr &
104 pid=$!
105 ovs_sbx "$sbx" on_exit "kill -TERM $pid 2>/dev/null"
106}
107
108ovs_add_netns_and_veths () {
109 info "Adding netns attached: sbx:$1 dp:$2 {$3, $4, $5}"
110 ovs_sbx "$1" ip netns add "$3" || return 1
111 on_exit "ovs_sbx $1 ip netns del $3"
112 ovs_sbx "$1" ip link add "$4" type veth peer name "$5" || return 1
113 on_exit "ovs_sbx $1 ip link del $4 >/dev/null 2>&1"
114 ovs_sbx "$1" ip link set "$4" up || return 1
115 ovs_sbx "$1" ip link set "$5" netns "$3" || return 1
116 ovs_sbx "$1" ip netns exec "$3" ip link set "$5" up || return 1
117
118 if [ "$6" != "" ]; then
119 ovs_sbx "$1" ip netns exec "$3" ip addr add "$6" dev "$5" \
120 || return 1
121 fi
122
123 if [ "$7" != "-u" ]; then
124 ovs_add_if "$1" "$2" "$4" || return 1
125 else
126 ovs_add_if "$1" "$2" "$4" -u || return 1
127 fi
128
129 [ $TRACING -eq 1 ] && ovs_netns_spawn_daemon "$1" "$ns" \
130 tcpdump -i any -s 65535
131
132 return 0
133}
134
135ovs_add_flow () {
136 info "Adding flow to DP: sbx:$1 br:$2 flow:$3 act:$4"
137 ovs_sbx "$1" python3 $ovs_base/ovs-dpctl.py add-flow "$2" "$3" "$4"
138 if [ $? -ne 0 ]; then
139 echo "Flow [ $3 : $4 ] failed" >> ${ovs_dir}/debug.log
140 return 1
141 fi
142 return 0
143}
144
145ovs_drop_record_and_run () {
146 local sbx=$1
147 shift
148
149 perf record -a -q -e skb:kfree_skb -o ${ovs_dir}/perf.data $* \
150 >> ${ovs_dir}/stdout 2>> ${ovs_dir}/stderr
151 return $?
152}
153
154ovs_drop_reason_count()
155{
156 local reason=$1
157
158 local perf_output=`perf script -i ${ovs_dir}/perf.data -F trace:event,trace`
159 local pattern="skb:kfree_skb:.*reason: $reason"
160
161 return `echo "$perf_output" | grep "$pattern" | wc -l`
162}
163
164usage() {
165 echo
166 echo "$0 [OPTIONS] [TEST]..."
167 echo "If no TEST argument is given, all tests will be run."
168 echo
169 echo "Options"
170 echo " -t: capture traffic via tcpdump"
171 echo " -v: verbose"
172 echo " -p: pause on failure"
173 echo
174 echo "Available tests${tests}"
175 exit 1
176}
177
178# drop_reason test
179# - drop packets and verify the right drop reason is reported
180test_drop_reason() {
181 which perf >/dev/null 2>&1 || return $ksft_skip
182
183 sbx_add "test_drop_reason" || return $?
184
185 ovs_add_dp "test_drop_reason" dropreason || return 1
186
187 info "create namespaces"
188 for ns in client server; do
189 ovs_add_netns_and_veths "test_drop_reason" "dropreason" "$ns" \
190 "${ns:0:1}0" "${ns:0:1}1" || return 1
191 done
192
193 # Setup client namespace
194 ip netns exec client ip addr add 172.31.110.10/24 dev c1
195 ip netns exec client ip link set c1 up
196
197 # Setup server namespace
198 ip netns exec server ip addr add 172.31.110.20/24 dev s1
199 ip netns exec server ip link set s1 up
200
201 # Allow ARP
202 ovs_add_flow "test_drop_reason" dropreason \
203 'in_port(1),eth(),eth_type(0x0806),arp()' '2' || return 1
204 ovs_add_flow "test_drop_reason" dropreason \
205 'in_port(2),eth(),eth_type(0x0806),arp()' '1' || return 1
206
207 # Allow client ICMP traffic but drop return path
208 ovs_add_flow "test_drop_reason" dropreason \
209 "in_port(1),eth(),eth_type(0x0800),ipv4(src=172.31.110.10,proto=1),icmp()" '2'
210 ovs_add_flow "test_drop_reason" dropreason \
211 "in_port(2),eth(),eth_type(0x0800),ipv4(src=172.31.110.20,proto=1),icmp()" 'drop'
212
213 ovs_drop_record_and_run "test_drop_reason" ip netns exec client ping -c 2 172.31.110.20
214 ovs_drop_reason_count 0x30001 # OVS_DROP_FLOW_ACTION
215 if [[ "$?" -ne "2" ]]; then
216 info "Did not detect expected drops: $?"
217 return 1
218 fi
219
220 # Drop UDP 6000 traffic with an explicit action and an error code.
221 ovs_add_flow "test_drop_reason" dropreason \
222 "in_port(1),eth(),eth_type(0x0800),ipv4(src=172.31.110.10,proto=17),udp(dst=6000)" \
223 'drop(42)'
224 # Drop UDP 7000 traffic with an explicit action with no error code.
225 ovs_add_flow "test_drop_reason" dropreason \
226 "in_port(1),eth(),eth_type(0x0800),ipv4(src=172.31.110.10,proto=17),udp(dst=7000)" \
227 'drop(0)'
228
229 ovs_drop_record_and_run \
230 "test_drop_reason" ip netns exec client nc -i 1 -zuv 172.31.110.20 6000
231 ovs_drop_reason_count 0x30004 # OVS_DROP_EXPLICIT_ACTION_ERROR
232 if [[ "$?" -ne "1" ]]; then
233 info "Did not detect expected explicit error drops: $?"
234 return 1
235 fi
236
237 ovs_drop_record_and_run \
238 "test_drop_reason" ip netns exec client nc -i 1 -zuv 172.31.110.20 7000
239 ovs_drop_reason_count 0x30003 # OVS_DROP_EXPLICIT_ACTION
240 if [[ "$?" -ne "1" ]]; then
241 info "Did not detect expected explicit drops: $?"
242 return 1
243 fi
244
245 return 0
246}
247
248# arp_ping test
249# - client has 1500 byte MTU
250# - server has 1500 byte MTU
251# - send ARP ping between two ns
252test_arp_ping () {
253
254 which arping >/dev/null 2>&1 || return $ksft_skip
255
256 sbx_add "test_arp_ping" || return $?
257
258 ovs_add_dp "test_arp_ping" arpping || return 1
259
260 info "create namespaces"
261 for ns in client server; do
262 ovs_add_netns_and_veths "test_arp_ping" "arpping" "$ns" \
263 "${ns:0:1}0" "${ns:0:1}1" || return 1
264 done
265
266 # Setup client namespace
267 ip netns exec client ip addr add 172.31.110.10/24 dev c1
268 ip netns exec client ip link set c1 up
269 HW_CLIENT=`ip netns exec client ip link show dev c1 | grep -E 'link/ether [0-9a-f:]+' | awk '{print $2;}'`
270 info "Client hwaddr: $HW_CLIENT"
271
272 # Setup server namespace
273 ip netns exec server ip addr add 172.31.110.20/24 dev s1
274 ip netns exec server ip link set s1 up
275 HW_SERVER=`ip netns exec server ip link show dev s1 | grep -E 'link/ether [0-9a-f:]+' | awk '{print $2;}'`
276 info "Server hwaddr: $HW_SERVER"
277
278 ovs_add_flow "test_arp_ping" arpping \
279 "in_port(1),eth(),eth_type(0x0806),arp(sip=172.31.110.10,tip=172.31.110.20,sha=$HW_CLIENT,tha=ff:ff:ff:ff:ff:ff)" '2' || return 1
280 ovs_add_flow "test_arp_ping" arpping \
281 "in_port(2),eth(),eth_type(0x0806),arp()" '1' || return 1
282
283 ovs_sbx "test_arp_ping" ip netns exec client arping -I c1 172.31.110.20 -c 1 || return 1
284
285 return 0
286}
287
288# ct_connect_v4 test
289# - client has 1500 byte MTU
290# - server has 1500 byte MTU
291# - use ICMP to ping in each direction
292# - only allow CT state stuff to pass through new in c -> s
293test_ct_connect_v4 () {
294
295 which nc >/dev/null 2>/dev/null || return $ksft_skip
296
297 sbx_add "test_ct_connect_v4" || return $?
298
299 ovs_add_dp "test_ct_connect_v4" ct4 || return 1
300 info "create namespaces"
301 for ns in client server; do
302 ovs_add_netns_and_veths "test_ct_connect_v4" "ct4" "$ns" \
303 "${ns:0:1}0" "${ns:0:1}1" || return 1
304 done
305
306 ip netns exec client ip addr add 172.31.110.10/24 dev c1
307 ip netns exec client ip link set c1 up
308 ip netns exec server ip addr add 172.31.110.20/24 dev s1
309 ip netns exec server ip link set s1 up
310
311 # Add forwarding for ARP and ip packets - completely wildcarded
312 ovs_add_flow "test_ct_connect_v4" ct4 \
313 'in_port(1),eth(),eth_type(0x0806),arp()' '2' || return 1
314 ovs_add_flow "test_ct_connect_v4" ct4 \
315 'in_port(2),eth(),eth_type(0x0806),arp()' '1' || return 1
316 ovs_add_flow "test_ct_connect_v4" ct4 \
317 'ct_state(-trk),eth(),eth_type(0x0800),ipv4()' \
318 'ct(commit),recirc(0x1)' || return 1
319 ovs_add_flow "test_ct_connect_v4" ct4 \
320 'recirc_id(0x1),ct_state(+trk+new),in_port(1),eth(),eth_type(0x0800),ipv4(src=172.31.110.10)' \
321 '2' || return 1
322 ovs_add_flow "test_ct_connect_v4" ct4 \
323 'recirc_id(0x1),ct_state(+trk+est),in_port(1),eth(),eth_type(0x0800),ipv4(src=172.31.110.10)' \
324 '2' || return 1
325 ovs_add_flow "test_ct_connect_v4" ct4 \
326 'recirc_id(0x1),ct_state(+trk+est),in_port(2),eth(),eth_type(0x0800),ipv4(dst=172.31.110.10)' \
327 '1' || return 1
328 ovs_add_flow "test_ct_connect_v4" ct4 \
329 'recirc_id(0x1),ct_state(+trk+inv),eth(),eth_type(0x0800),ipv4()' 'drop' || \
330 return 1
331
332 # do a ping
333 ovs_sbx "test_ct_connect_v4" ip netns exec client ping 172.31.110.20 -c 3 || return 1
334
335 # create an echo server in 'server'
336 echo "server" | \
337 ovs_netns_spawn_daemon "test_ct_connect_v4" "server" \
338 nc -lvnp 4443
339 ovs_sbx "test_ct_connect_v4" ip netns exec client nc -i 1 -zv 172.31.110.20 4443 || return 1
340
341 # Now test in the other direction (should fail)
342 echo "client" | \
343 ovs_netns_spawn_daemon "test_ct_connect_v4" "client" \
344 nc -lvnp 4443
345 ovs_sbx "test_ct_connect_v4" ip netns exec client nc -i 1 -zv 172.31.110.10 4443
346 if [ $? == 0 ]; then
347 info "ct connect to client was successful"
348 return 1
349 fi
350
351 info "done..."
352 return 0
353}
354
355# connect_v4 test
356# - client has 1500 byte MTU
357# - server has 1500 byte MTU
358# - use ICMP to ping in each direction
359test_connect_v4 () {
360
361 sbx_add "test_connect_v4" || return $?
362
363 ovs_add_dp "test_connect_v4" cv4 || return 1
364
365 info "create namespaces"
366 for ns in client server; do
367 ovs_add_netns_and_veths "test_connect_v4" "cv4" "$ns" \
368 "${ns:0:1}0" "${ns:0:1}1" || return 1
369 done
370
371
372 ip netns exec client ip addr add 172.31.110.10/24 dev c1
373 ip netns exec client ip link set c1 up
374 ip netns exec server ip addr add 172.31.110.20/24 dev s1
375 ip netns exec server ip link set s1 up
376
377 # Add forwarding for ARP and ip packets - completely wildcarded
378 ovs_add_flow "test_connect_v4" cv4 \
379 'in_port(1),eth(),eth_type(0x0806),arp()' '2' || return 1
380 ovs_add_flow "test_connect_v4" cv4 \
381 'in_port(2),eth(),eth_type(0x0806),arp()' '1' || return 1
382 ovs_add_flow "test_connect_v4" cv4 \
383 'in_port(1),eth(),eth_type(0x0800),ipv4(src=172.31.110.10)' '2' || return 1
384 ovs_add_flow "test_connect_v4" cv4 \
385 'in_port(2),eth(),eth_type(0x0800),ipv4(src=172.31.110.20)' '1' || return 1
386
387 # do a ping
388 ovs_sbx "test_connect_v4" ip netns exec client ping 172.31.110.20 -c 3 || return 1
389
390 info "done..."
391 return 0
392}
393
394# nat_connect_v4 test
395# - client has 1500 byte MTU
396# - server has 1500 byte MTU
397# - use ICMP to ping in each direction
398# - only allow CT state stuff to pass through new in c -> s
399test_nat_connect_v4 () {
400 which nc >/dev/null 2>/dev/null || return $ksft_skip
401
402 sbx_add "test_nat_connect_v4" || return $?
403
404 ovs_add_dp "test_nat_connect_v4" nat4 || return 1
405 info "create namespaces"
406 for ns in client server; do
407 ovs_add_netns_and_veths "test_nat_connect_v4" "nat4" "$ns" \
408 "${ns:0:1}0" "${ns:0:1}1" || return 1
409 done
410
411 ip netns exec client ip addr add 172.31.110.10/24 dev c1
412 ip netns exec client ip link set c1 up
413 ip netns exec server ip addr add 172.31.110.20/24 dev s1
414 ip netns exec server ip link set s1 up
415
416 ip netns exec client ip route add default via 172.31.110.20
417
418 ovs_add_flow "test_nat_connect_v4" nat4 \
419 'in_port(1),eth(),eth_type(0x0806),arp()' '2' || return 1
420 ovs_add_flow "test_nat_connect_v4" nat4 \
421 'in_port(2),eth(),eth_type(0x0806),arp()' '1' || return 1
422 ovs_add_flow "test_nat_connect_v4" nat4 \
423 "ct_state(-trk),in_port(1),eth(),eth_type(0x0800),ipv4(dst=192.168.0.20)" \
424 "ct(commit,nat(dst=172.31.110.20)),recirc(0x1)"
425 ovs_add_flow "test_nat_connect_v4" nat4 \
426 "ct_state(-trk),in_port(2),eth(),eth_type(0x0800),ipv4()" \
427 "ct(commit,nat),recirc(0x2)"
428
429 ovs_add_flow "test_nat_connect_v4" nat4 \
430 "recirc_id(0x1),ct_state(+trk-inv),in_port(1),eth(),eth_type(0x0800),ipv4()" "2"
431 ovs_add_flow "test_nat_connect_v4" nat4 \
432 "recirc_id(0x2),ct_state(+trk-inv),in_port(2),eth(),eth_type(0x0800),ipv4()" "1"
433
434 # do a ping
435 ovs_sbx "test_nat_connect_v4" ip netns exec client ping 192.168.0.20 -c 3 || return 1
436
437 # create an echo server in 'server'
438 echo "server" | \
439 ovs_netns_spawn_daemon "test_nat_connect_v4" "server" \
440 nc -lvnp 4443
441 ovs_sbx "test_nat_connect_v4" ip netns exec client nc -i 1 -zv 192.168.0.20 4443 || return 1
442
443 # Now test in the other direction (should fail)
444 echo "client" | \
445 ovs_netns_spawn_daemon "test_nat_connect_v4" "client" \
446 nc -lvnp 4443
447 ovs_sbx "test_nat_connect_v4" ip netns exec client nc -i 1 -zv 172.31.110.10 4443
448 if [ $? == 0 ]; then
449 info "connect to client was successful"
450 return 1
451 fi
452
453 info "done..."
454 return 0
455}
456
457# netlink_validation
458# - Create a dp
459# - check no warning with "old version" simulation
460test_netlink_checks () {
461 sbx_add "test_netlink_checks" || return 1
462
463 info "setting up new DP"
464 ovs_add_dp "test_netlink_checks" nv0 || return 1
465 # now try again
466 PRE_TEST=$(dmesg | grep -E "RIP: [0-9a-fA-Fx]+:ovs_dp_cmd_new\+")
467 ovs_add_dp "test_netlink_checks" nv0 -V 0 || return 1
468 POST_TEST=$(dmesg | grep -E "RIP: [0-9a-fA-Fx]+:ovs_dp_cmd_new\+")
469 if [ "$PRE_TEST" != "$POST_TEST" ]; then
470 info "failed - gen warning"
471 return 1
472 fi
473
474 ovs_add_netns_and_veths "test_netlink_checks" nv0 left left0 l0 || \
475 return 1
476 ovs_add_netns_and_veths "test_netlink_checks" nv0 right right0 r0 || \
477 return 1
478 [ $(python3 $ovs_base/ovs-dpctl.py show nv0 | grep port | \
479 wc -l) == 3 ] || \
480 return 1
481 ovs_del_if "test_netlink_checks" nv0 right0 || return 1
482 [ $(python3 $ovs_base/ovs-dpctl.py show nv0 | grep port | \
483 wc -l) == 2 ] || \
484 return 1
485
486 ERR_MSG="Flow actions may not be safe on all matching packets"
487 PRE_TEST=$(dmesg | grep -c "${ERR_MSG}")
488 ovs_add_flow "test_netlink_checks" nv0 \
489 'in_port(1),eth(),eth_type(0x0806),arp()' 'drop(0),2' \
490 &> /dev/null && return 1
491 POST_TEST=$(dmesg | grep -c "${ERR_MSG}")
492 if [ "$PRE_TEST" == "$POST_TEST" ]; then
493 info "failed - error not generated"
494 return 1
495 fi
496 return 0
497}
498
499test_upcall_interfaces() {
500 sbx_add "test_upcall_interfaces" || return 1
501
502 info "setting up new DP"
503 ovs_add_dp "test_upcall_interfaces" ui0 -V 2:1 || return 1
504
505 ovs_add_netns_and_veths "test_upcall_interfaces" ui0 upc left0 l0 \
506 172.31.110.1/24 -u || return 1
507
508 sleep 1
509 info "sending arping"
510 ip netns exec upc arping -I l0 172.31.110.20 -c 1 \
511 >$ovs_dir/arping.stdout 2>$ovs_dir/arping.stderr
512
513 grep -E "MISS upcall\[0/yes\]: .*arp\(sip=172.31.110.1,tip=172.31.110.20,op=1,sha=" $ovs_dir/left0.out >/dev/null 2>&1 || return 1
514 return 0
515}
516
517run_test() {
518 (
519 tname="$1"
520 tdesc="$2"
521
522 if ! lsmod | grep openvswitch >/dev/null 2>&1; then
523 stdbuf -o0 printf "TEST: %-60s [NOMOD]\n" "${tdesc}"
524 return $ksft_skip
525 fi
526
527 if python3 ovs-dpctl.py -h 2>&1 | \
528 grep "Need to install the python" >/dev/null 2>&1; then
529 stdbuf -o0 printf "TEST: %-60s [PYLIB]\n" "${tdesc}"
530 return $ksft_skip
531 fi
532 printf "TEST: %-60s [START]\n" "${tname}"
533
534 unset IFS
535
536 eval test_${tname}
537 ret=$?
538
539 if [ $ret -eq 0 ]; then
540 printf "TEST: %-60s [ OK ]\n" "${tdesc}"
541 ovs_exit_sig
542 rm -rf "$ovs_dir"
543 elif [ $ret -eq 1 ]; then
544 printf "TEST: %-60s [FAIL]\n" "${tdesc}"
545 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
546 echo
547 echo "Pausing. Logs in $ovs_dir/. Hit enter to continue"
548 read a
549 fi
550 ovs_exit_sig
551 [ "${PAUSE_ON_FAIL}" = "yes" ] || rm -rf "$ovs_dir"
552 exit 1
553 elif [ $ret -eq $ksft_skip ]; then
554 printf "TEST: %-60s [SKIP]\n" "${tdesc}"
555 elif [ $ret -eq 2 ]; then
556 rm -rf test_${tname}
557 run_test "$1" "$2"
558 fi
559
560 return $ret
561 )
562 ret=$?
563 case $ret in
564 0)
565 [ $all_skipped = true ] && [ $exitcode=$ksft_skip ] && exitcode=0
566 all_skipped=false
567 ;;
568 $ksft_skip)
569 [ $all_skipped = true ] && exitcode=$ksft_skip
570 ;;
571 *)
572 all_skipped=false
573 exitcode=1
574 ;;
575 esac
576
577 return $ret
578}
579
580
581exitcode=0
582desc=0
583all_skipped=true
584
585while getopts :pvt o
586do
587 case $o in
588 p) PAUSE_ON_FAIL=yes;;
589 v) VERBOSE=1;;
590 t) if which tcpdump > /dev/null 2>&1; then
591 TRACING=1
592 else
593 echo "=== tcpdump not available, tracing disabled"
594 fi
595 ;;
596 *) usage;;
597 esac
598done
599shift $(($OPTIND-1))
600
601IFS="
602"
603
604for arg do
605 # Check first that all requested tests are available before running any
606 command -v > /dev/null "test_${arg}" || { echo "=== Test ${arg} not found"; usage; }
607done
608
609name=""
610desc=""
611for t in ${tests}; do
612 [ "${name}" = "" ] && name="${t}" && continue
613 [ "${desc}" = "" ] && desc="${t}"
614
615 run_this=1
616 for arg do
617 [ "${arg}" != "${arg#--*}" ] && continue
618 [ "${arg}" = "${name}" ] && run_this=1 && break
619 run_this=0
620 done
621 if [ $run_this -eq 1 ]; then
622 run_test "${name}" "${desc}"
623 fi
624 name=""
625 desc=""
626done
627
628exit ${exitcode}