OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / lib / Libnet / test / test-step.sh
1 #!/bin/sh
2 #
3 #   $Id: test-step.sh,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
4 #
5 #   libnet
6 #   Copyright (c) 1998 - 2001 Mike D. Schiffman <mike@infonexus.com>
7 #   All rights reserved.
8 #
9 #   Redistribution and use in source and binary forms, with or without
10 #   modification, are permitted provided that the following conditions
11 #   are met:
12 #
13 #   1. Redistributions of source code must retain the above copyright
14 #      notice, this list of conditions and the following disclaimer.
15 #   2. Redistributions in binary form must reproduce the above copyright
16 #      notice, this list of conditions and the following disclaimer in the
17 #      documentation and/or other materials provided with the distribution.
18 #
19 #   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 #   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 #   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 #   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 #   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 #   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 #   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 #   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 #   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 #   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #   SUCH DAMAGE.
30
31 #
32 #   Hard coded defaults (ie: user hits enter at prompts)
33 #
34
35 DST_IP=10.0.0.1
36 SRC_IP=10.0.0.2
37 SRC_PRT=100
38 DST_PRT=200
39 DEV=de0
40
41 echo "Libnet test code step through dealy"
42 echo ""
43 echo "This script will run you through all the testcode modules and verify
44 echo "functionality \(hopefully\).  You may want to use tcpdump in conjuction
45 echo "with this script to make sure things are working as they should be."
46 echo ""
47 echo "Although this script is here to quickly take you through the testcode"
48 echo "modules and confirm correct operation, the user is encouraged to descend"
49 echo "into the test directories and peruse the code for examples on how to use"
50 echo "the library effectively."
51 echo ""
52 echo "I will need some information from you for some of these tests."
53 echo "We don't check for sane input here, so don't be an idiot."
54 echo ""
55
56 #
57 #   Intial setup.
58 #
59
60 echo -n "Most of the test modules require a source IP address `echo \($SRC_IP\)`: "
61 read __tmp
62 if test "$__tmp" != ""; then
63     SRC_IP=$__tmp
64 fi
65
66 echo -n "And most of the test modules also require a destination IP address `echo \($DST_IP\)`: "
67 read __tmp
68 if test "$__tmp" != ""; then
69     DST_IP=$__tmp
70 fi
71
72 echo -n "The TCP and UDP tests need a source port `echo \($SRC_PRT\)`: "
73 read __tmp
74 if test "$__tmp" != ""; then
75     SRC_PRT=$__tmp
76 fi
77
78 echo -n "And a destination port `echo \($DST_PRT\)`: "
79 read __tmp
80 if test "$__tmp" != ""; then
81     DST_PRT=$__tmp
82 fi
83
84 echo -n "Some need a link-layer device `echo \($DEV\)`: "
85 read __tmp
86 if test "$__tmp" != ""; then
87     DEV=$__tmp
88 fi
89
90 echo -n "The ethernet tests need a source ethernet address (x:x:x:x:x:x):"
91 read __tmp
92 if test "$__tmp" != ""; then
93     SRC_ETH=$__tmp
94 fi
95
96 echo -n "And a destination ethernet address (x:x:x:x:x:x):"
97 read __tmp
98 if test "$__tmp" != ""; then
99     DST_ETH=$__tmp
100 fi
101
102 echo "Gotit!  The game can start now."
103
104 #
105 #   Internal win/loss variable setup.
106 #
107
108 TOTAL_WON=$((0))
109 TOTAL_LOST=$((0))
110
111 # The TCP tests
112 WIN=$((0))
113 LOSE=$((0))
114 cd TCP
115 echo ""
116 echo "TCP test suite"
117
118 if test -x tcp; then
119     echo "./tcp -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT"
120     ./tcp -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT
121     if [ $? -eq -0 ]; then
122         WIN=`expr $WIN + 1`
123     else
124         LOSE=`expr $LOSE + 1`
125     fi
126     echo "-return-"
127     read
128 fi
129 if test -x tcp+data; then
130     echo "./tcp+data -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT"
131     ./tcp+data -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT
132     if [ $? -eq -0 ]; then
133         WIN=`expr $WIN + 1`
134     else
135         LOSE=`expr $LOSE + 1`
136     fi
137     echo "-return-"
138     read
139 fi
140 if test -x tcp+data+ipopt; then
141     echo "./tcp+data+ipopt -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT"
142     ./tcp+data+ipopt -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT
143     if [ $? -eq -0 ]; then
144         WIN=`expr $WIN + 1`
145     else
146         LOSE=`expr $LOSE + 1`
147     fi
148     echo "-return-"
149     read
150 fi
151
152 echo "completed TCP test suite $WIN test(s) succeeded, $LOSE test(s) failed"
153 TOTAL_WON=`expr $TOTAL_WON + $WIN`
154 TOTAL_LOST=`expr $TOTAL_LOST + $LOSE`
155 cd ..
156
157 # The UDP tests
158 WIN=$((0))
159 LOSE=$((0))
160 cd UDP
161 echo ""
162 echo "UDP test suite"
163
164 if test -x udp; then
165     echo "./udp -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT"
166     ./udp -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT
167     if [ $? -eq -0 ]; then
168         WIN=`expr $WIN + 1`
169     else
170         LOSE=`expr $LOSE + 1`
171     fi
172     echo "-return-"
173     read
174 fi
175 if test -x udp+data; then
176     echo "./udp+data -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT"
177     ./udp+data -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT
178     if [ $? -eq -0 ]; then
179         WIN=`expr $WIN + 1`
180     else
181         LOSE=`expr $LOSE + 1`
182     fi
183     echo "-return-"
184     read
185 fi
186
187 echo "completed UDP test suite $WIN test(s) succeeded, $LOSE test(s) failed"
188 TOTAL_WON=`expr $TOTAL_WON + $WIN`
189 TOTAL_LOST=`expr $TOTAL_LOST + $LOSE`
190 cd ..
191
192 # The ICMP tests
193 WIN=$((0))
194 LOSE=$((0))
195 cd ICMP
196 echo ""
197 echo "ICMP test suite"
198
199 if test -x icmp_echo; then
200     echo "./icmp_echo -s $SRC_IP -d $DST_IP"
201     ./icmp_echo -s $SRC_IP -d $DST_IP
202     if [ $? -eq -0 ]; then
203         WIN=`expr $WIN + 1`
204     else
205         LOSE=`expr $LOSE + 1`
206     fi
207     echo "-return-"
208     read
209 fi
210 if test -x icmp_timestamp; then
211     echo "./icmp_timestamp -s $SRC_IP -d $DST_IP"
212     ./icmp_timestamp -s $SRC_IP -d $DST_IP
213     if [ $? -eq -0 ]; then
214         WIN=`expr $WIN + 1`
215     else
216         LOSE=`expr $LOSE + 1`
217     fi
218     echo "-return-"
219     read
220 fi
221 if test -x icmp_timexceed; then
222     echo "./icmp_timexceed -s $SRC_IP -d $DST_IP"
223     ./icmp_timexceed -s $SRC_IP -d $DST_IP
224     if [ $? -eq -0 ]; then
225         WIN=`expr $WIN + 1`
226     else
227         LOSE=`expr $LOSE + 1`
228     fi
229     echo "-return-"
230     read
231 fi
232 if test -x icmp_unreach; then
233     echo "./icmp_unreach -s $SRC_IP -d $DST_IP"
234     ./icmp_unreach -s $SRC_IP -d $DST_IP
235     if [ $? -eq -0 ]; then
236         WIN=`expr $WIN + 1`
237     else
238         LOSE=`expr $LOSE + 1`
239     fi
240     echo "-return-"
241     read
242 fi
243 if test -x silvertongue; then
244     echo "./silvertongue $SRC_IP 200.200.200.200 $DST_IP"
245     ./silvertongue $SRC_IP 200.200.200.200 $DST_IP
246     if [ $? -eq -0 ]; then
247         WIN=`expr $WIN + 1`
248     else
249         LOSE=`expr $LOSE + 1`
250     fi
251     echo "-return-"
252     read
253 fi
254
255 echo "completed ICMP test suite $WIN test(s) succeeded, $LOSE test(s) failed"
256 TOTAL_WON=`expr $TOTAL_WON + $WIN`
257 TOTAL_LOST=`expr $TOTAL_LOST + $LOSE`
258 cd ..
259
260 # The Ethernet tests
261 WIN=$((0))
262 LOSE=$((0))
263 cd Ethernet
264 echo ""
265 echo "Ethernet test suite"
266
267 if test -x icmp_mask; then
268     echo "./icmp_mask -i $DEV -s $SRC_IP -d $DST_IP"
269     ./icmp_mask -i $DEV -s $SRC_IP -d $DST_IP
270     if [ $? -eq -0 ]; then
271         WIN=`expr $WIN + 1`
272     else
273         LOSE=`expr $LOSE + 1`
274     fi
275     echo "-return-"
276     read
277 fi
278 if test -x arp; then
279     echo "./arp -i $DEV"
280     ./arp -i $DEV
281     if [ $? -eq -0 ]; then
282         WIN=`expr $WIN + 1`
283     else
284         LOSE=`expr $LOSE + 1`
285     fi
286     echo "-return-"
287     read
288 fi
289 if test -x tcp; then
290     echo "./tcp -i $DEV -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT"
291     ./tcp -i $DEV -s $SRC_IP.$SRC_PRT -d $DST_IP.$DST_PRT
292     if [ $? -eq -0 ]; then
293         WIN=`expr $WIN + 1`
294     else
295         LOSE=`expr $LOSE + 1`
296     fi
297     echo "-return-"
298     read
299 fi
300
301 echo "completed Ethernet test suite $WIN test(s) succeeded, $LOSE test(s) failed"
302 TOTAL_WON=`expr $TOTAL_WON + $WIN`
303 TOTAL_LOST=`expr $TOTAL_LOST + $LOSE`
304 cd ..
305
306 # Random tests
307
308
309 # IP tests
310
311 echo "completed entire test suite $TOTAL_WON test(s) succeeded, $TOTAL_LOST test(s) failed"
312
313 # EOF