Skip to content

Commit f5b3ceb

Browse files
committed
Use sh instead of tcsh for scripts.
While there, add support for redirecting output to a file. Sponsored by: Netflix
1 parent 164e601 commit f5b3ceb

25 files changed

+2958
-1792
lines changed

rcv-icmp/run-all-rcv-icmp-tests

Lines changed: 101 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env tcsh
1+
#!/usr/bin/env sh
22
#
33
# Copyright (c) 2016 Michael Tuexen
44
# All rights reserved.
@@ -25,69 +25,115 @@
2525
# SUCH DAMAGE.
2626
#
2727

28-
set packetdrill = /usr/local/bin/packetdrill
29-
set delay = 1
30-
set limit = 10
31-
set testcases = ( rcv-icmp-hard-error-proto-unreachable-ipv4 \
32-
rcv-icmp-hard-error-proto-unreachable-ipv6 \
33-
rcv-icmp-hard-error-port-unreachable-ipv4 \
34-
rcv-icmp-hard-error-port-unreachable-ipv6 \
35-
rcv-icmp-hard-error-net-prohibited-ipv4 \
36-
rcv-icmp-hard-error-host-prohibited-ipv4 \
37-
rcv-icmp-hard-error-comm-prohibited-ipv4 \
38-
rcv-icmp-hard-error-comm-prohibited-ipv6 \
39-
rcv-icmp-hard-error-ttl-exceeded-ipv4 \
40-
rcv-icmp-hard-error-ttl-exceeded-ipv6 \
41-
rcv-icmp-hard-error-ignored-ipv4 \
42-
rcv-icmp-hard-error-ignored-ipv6 )
28+
packetdrill=/usr/local/bin/packetdrill
29+
delay=1
30+
timelimit=10
31+
testcases="rcv-icmp-hard-error-proto-unreachable-ipv4 \
32+
rcv-icmp-hard-error-proto-unreachable-ipv6 \
33+
rcv-icmp-hard-error-port-unreachable-ipv4 \
34+
rcv-icmp-hard-error-port-unreachable-ipv6 \
35+
rcv-icmp-hard-error-net-prohibited-ipv4 \
36+
rcv-icmp-hard-error-host-prohibited-ipv4 \
37+
rcv-icmp-hard-error-comm-prohibited-ipv4 \
38+
rcv-icmp-hard-error-comm-prohibited-ipv6 \
39+
rcv-icmp-hard-error-ttl-exceeded-ipv4 \
40+
rcv-icmp-hard-error-ttl-exceeded-ipv6 \
41+
rcv-icmp-hard-error-ignored-ipv4 \
42+
rcv-icmp-hard-error-ignored-ipv6"
4343

44-
set rootdir = `/usr/bin/dirname $0`
45-
set passed = 0
46-
set failed = 0
47-
set run = 0
48-
set skipped = 0
49-
set timedout = 0
50-
set first = 1
44+
rootdir=`/usr/bin/dirname $0`
45+
passed=0
46+
failed=0
47+
run=0
48+
skipped=0
49+
timedout=0
50+
first=1
5151

5252
printf "Name Verdict\n"
5353
printf "===============================================================================\n"
54-
foreach testcase ($testcases)
54+
for testcase in $testcases
55+
do
5556
printf "%-68.68s " `/usr/bin/basename $testcase`
56-
if ($first == 0) then
57-
if ($delay != 0) then
58-
printf "\033[33m%10s\033[0m" "WAITING"
57+
if [ $first -eq 0 ]
58+
then
59+
if [ $delay -ne 0 ]
60+
then
61+
if [ -t 1 ]
62+
then
63+
printf "\033[33m%10s\033[0m" "WAITING"
64+
fi
5965
sleep $delay
60-
printf "\b\b\b\b\b\b\b\b\b\b"
61-
endif
66+
if [ -t 1 ]
67+
then
68+
printf "\b\b\b\b\b\b\b\b\b\b"
69+
fi
70+
fi
6271
else
63-
set first = 0
64-
endif
65-
printf "\033[33m%10s\033[0m" "RUNNING"
66-
if (-f ${rootdir}/${testcase}.pkt) then
67-
timeout $limit $packetdrill ${rootdir}/${testcase}.pkt >& /dev/null
68-
set result = $status
69-
set found = 1
72+
first=0
73+
fi
74+
if [ -t 1 ]
75+
then
76+
printf "\033[33m%10s\033[0m" "RUNNING"
77+
fi
78+
if [ -f ${rootdir}/${testcase}.pkt ]
79+
then
80+
timeout $timelimit $packetdrill ${rootdir}/${testcase}.pkt >/dev/null 2>&1
81+
result=$?
82+
found=1
7083
else
71-
set found = 0
72-
endif
73-
printf "\b\b\b\b\b\b\b\b\b\b"
74-
if ($found == 1) then
75-
if ($result == 0) then
76-
@ passed++
77-
printf "\033[32m%10s\033[0m\n" "PASSED"
78-
else if ($result == 1) then
79-
@ failed++
80-
printf "\033[31m%10s\033[0m\n" "FAILED"
81-
else
82-
@ timedout++
83-
printf "\033[35m%10s\033[0m\n" "TIMEDOUT"
84-
endif
85-
@ run++
84+
found=0
85+
fi
86+
if [ -t 1 ]
87+
then
88+
printf "\b\b\b\b\b\b\b\b\b\b"
89+
fi
90+
if [ $found -eq 1 ]
91+
then
92+
case $result in
93+
0) passed=`expr $passed + 1`
94+
if [ -t 1 ]
95+
then
96+
printf "\033[32m%10s\033[0m\n" "PASSED"
97+
else
98+
printf "%10s\n" "PASSED"
99+
fi
100+
;;
101+
1) failed=`expr $failed + 1`
102+
if [ -t 1 ]
103+
then
104+
printf "\033[31m%10s\033[0m\n" "FAILED"
105+
else
106+
printf "%10s\n" "FAILED"
107+
fi
108+
;;
109+
124) timedout=`expr $timedout + 1`
110+
if [ -t 1 ]
111+
then
112+
printf "\033[35m%10s\033[0m\n" "TIMEDOUT"
113+
else
114+
printf "%10s\n" "TIMEDOUT"
115+
fi
116+
;;
117+
*)
118+
if [ -t 1 ]
119+
then
120+
printf "\033[36m%10s\033[0m\n" "UNKNOWN"
121+
else
122+
printf "%10s\n" "UNKNOWN"
123+
fi
124+
;;
125+
esac
126+
run=`expr $run + 1`
86127
else
87-
printf "\033[34m%10s\033[0m\n" "SKIPPED"
88-
@ skipped++
89-
endif
90-
end
128+
if [ -t 1 ]
129+
then
130+
printf "\033[34m%10s\033[0m\n" "SKIPPED"
131+
else
132+
printf "%10s\n" "SKIPPED"
133+
fi
134+
skipped=`expr $skipped + 1`
135+
fi
136+
done
91137
printf "===============================================================================\n"
92138
printf "Summary: Number of tests run: %3u\n" $run
93139
printf " Number of tests passed: %3u\n" $passed

0 commit comments

Comments
 (0)