OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [autotest/] [current/] [host/] [floodping.sh] - Blame information for rev 868

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#!/bin/sh
2
 
3
# timeout is the total time to run the test, or thereabouts.
4
#
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.
7
#
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
10
# test environment.
11
 
12
 
13
if [ $# -lt 1 ]; then
14
    echo "Usage: $0 [XFAIL] target [timeout [size [ping rest]]" > /dev/stderr
15
    exit 1
16
fi
17
 
18
[ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
19
TARGET=$1
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
24
 
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.
28
 
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
33
    else
34
        echo "FAIL:<$$: $TARGET is down>" > /dev/stderr; exit 1
35
    fi
36
fi
37
 
38
# allow other pingers &c to start up:
39
sleep 5
40
 
41
declare -i COUNT=0
42
 
43
# then the size we were asked to do, for the time requested
44
 
45
while [ $SECONDS -le $TIMEOUT ]; do
46
 
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
51
 
52
# dump this out for the controller logfile
53
cat /tmp/ping$$
54
 
55
INFO1=$(grep "bytes of data" /tmp/ping$$)
56
INFO2=$(grep "packet loss" /tmp/ping$$)
57
INFO3=$(grep "round-trip" /tmp/ping$$)
58
 
59
rm -f /tmp/ping$$
60
 
61
# but do not print it all out to stderr (and so to sendack and over the
62
# net); the two cannot coexist reliably.
63
 
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
67
 
68
# then a delay for other traffic - else other tests fail
69
sleep $RESTTIME
70
 
71
((COUNT++));
72
done
73
 
74
# allow other flood pingers to finish:
75
sleep 5
76
 
77
if [ "x$XFAIL" == "xXFAIL" ]; then
78
    echo "PASS:<$$: flood ping XFAIL, $PINGSIZE bytes $TIMEOUT seconds $COUNT sessions>" > /dev/stderr
79
    exit 0
80
fi
81
 
82
# we cannot really look for pass/fail from a flood ping...
83
 
84
echo "PASS:<$$: flood ping OK, $PINGSIZE bytes $TIMEOUT seconds $COUNT sessions>" > /dev/stderr
85
 
86
# EOF

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.