3 # timeout is the total time to run the test, or thereabouts.
5 # ping/rest times are to let us do stuff like flood for 3 seconds then do
6 # nothing for 5 seconds, over the total test time.
8 # That way this script can be used to torment other test variants such as
9 # the SNMP walk, ordinary pinging and so on, all making for a more diverse
14 echo "Usage: $0 [XFAIL] target [timeout [size [ping rest]]" > /dev/stderr
18 [ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
20 if [ "x" == "x$2" ]; then TIMEOUT=10; else TIMEOUT=$2; fi
21 if [ "x" == "x$3" ]; then PINGSIZE=64; else PINGSIZE=$3; fi
22 if [ "x" == "x$4" ]; then PINGTIME=19; else PINGTIME=$4; fi
23 if [ "x" == "x$5" ]; then RESTTIME=1; else RESTTIME=$5; fi
25 # By default, flood for 19 seconds then rest for one.
26 # We take one second off occasionally to allow eg. DHCP to stay alive in
27 # configurations/environments where it is so short lived.
29 if [ "x$XFAIL" != "xXFAIL" ]; then
30 # first try normal size packets
31 if ping -n -c 5 $TARGET > /dev/null ; then
32 echo "INFO:<$$: $TARGET is up>" > /dev/stderr
34 echo "FAIL:<$$: $TARGET is down>" > /dev/stderr; exit 1
38 # allow other pingers &c to start up:
43 # then the size we were asked to do, for the time requested
45 while [ $SECONDS -le $TIMEOUT ]; do
47 # Use an explicit path in '.' because this must be an SUID script to be
48 # able to use the flood option. Direct stderr to tmp also because we
49 # cannot report results whilst flooding.
50 ./_suping -f -n -w $PINGTIME -q -s $PINGSIZE $TARGET > /tmp/ping$$ 2>&1
52 # dump this out for the controller logfile
55 INFO1=$(grep "bytes of data" /tmp/ping$$)
56 INFO2=$(grep "packet loss" /tmp/ping$$)
57 INFO3=$(grep "round-trip" /tmp/ping$$)
61 # but do not print it all out to stderr (and so to sendack and over the
62 # net); the two cannot coexist reliably.
64 #[ "x" != "x$INFO1" ] && echo "INFO:<$$: $INFO1>" > /dev/stderr
65 #[ "x" != "x$INFO2" ] && echo "INFO:<$$: $INFO2>" > /dev/stderr
66 #[ "x" != "x$INFO3" ] && echo "INFO:<$$: $INFO3>" > /dev/stderr
68 # then a delay for other traffic - else other tests fail
74 # allow other flood pingers to finish:
77 if [ "x$XFAIL" == "xXFAIL" ]; then
78 echo "PASS:<$$: flood ping XFAIL, $PINGSIZE bytes $TIMEOUT seconds $COUNT sessions>" > /dev/stderr
82 # we cannot really look for pass/fail from a flood ping...
84 echo "PASS:<$$: flood ping OK, $PINGSIZE bytes $TIMEOUT seconds $COUNT sessions>" > /dev/stderr