diff options
Diffstat (limited to 'recipes-test/ddt-runner/files/scripts/p2020rdb/ethernet')
| -rwxr-xr-x | recipes-test/ddt-runner/files/scripts/p2020rdb/ethernet | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/recipes-test/ddt-runner/files/scripts/p2020rdb/ethernet b/recipes-test/ddt-runner/files/scripts/p2020rdb/ethernet new file mode 100755 index 0000000..5355f10 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/p2020rdb/ethernet | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | ethernet_interface="eth1" | ||
| 4 | ethernet_ping_ipaddr="172.21.3.22" | ||
| 5 | ethernet_ipaddr=$1 | ||
| 6 | |||
| 7 | IFCONFIG=`which ifconfig` | ||
| 8 | |||
| 9 | $IFCONFIG $ethernet_interface up | ||
| 10 | $IFCONFIG | grep $ethernet_interface | ||
| 11 | if [ $? -ne 0 ]; then | ||
| 12 | echo "FAIL: $ethernet_interface is not up" | ||
| 13 | exit 1 | ||
| 14 | else | ||
| 15 | echo "PASS: $ethernet_interface is up" | ||
| 16 | fi | ||
| 17 | |||
| 18 | if [ "x$ethernet_ipaddr" != "x" ]; then | ||
| 19 | $IFCONFIG $ethernet_interface $ethernet_ipaddr | ||
| 20 | fi | ||
| 21 | |||
| 22 | $IFCONFIG $ethernet_interface |grep 'inet addr:' |sed -e 's@inet addr:@@' |sed q | awk '{print $1}' | ||
| 23 | if [ $? -ne 0 ]; then | ||
| 24 | echo "FAIL: ipaddr of $ethernet_interface setup failed" | ||
| 25 | exit 1 | ||
| 26 | else | ||
| 27 | echo "PASS: ipaddr of $ethernet_interface setup success" | ||
| 28 | fi | ||
| 29 | |||
| 30 | mindatasize=56 | ||
| 31 | maxdatasize=650 | ||
| 32 | stepsize=100 | ||
| 33 | iteration=1 | ||
| 34 | datasize=$mindatasize | ||
| 35 | logfile=`/bin/mktemp` | ||
| 36 | statistics=`/bin/mktemp` | ||
| 37 | error=0 | ||
| 38 | |||
| 39 | trap cleanup SIGHUP SIGINT SIGTERM | ||
| 40 | |||
| 41 | clean_tasks() { | ||
| 42 | echo "Executing clean up tasks" | ||
| 43 | rm -f $logfile $statistics | ||
| 44 | } | ||
| 45 | |||
| 46 | cleanup() { | ||
| 47 | echo "Aborting script execution" | ||
| 48 | clean_tasks | ||
| 49 | exit 0 | ||
| 50 | } | ||
| 51 | |||
| 52 | echo "start ping test for $ethernet_interface..." | ||
| 53 | |||
| 54 | while [ $datasize -le $maxdatasize ]; do | ||
| 55 | for i in `seq 1 $iteration`; do | ||
| 56 | ping -c 1 -s $datasize $ethernet_ping_ipaddr > $statistics | ||
| 57 | ping_err=`echo $?` | ||
| 58 | echo "" && cat $statistics | grep -r "PING" | ||
| 59 | cat $statistics | grep -r "received" | ||
| 60 | [ `echo $?` -eq 0 ] || packets_received=0 && \ | ||
| 61 | packets_received=`cat $statistics | \ | ||
| 62 | grep -r "received" | awk '{print$4}'` | ||
| 63 | |||
| 64 | # Evaluate possible errors on the ping operation | ||
| 65 | if [ $ping_err -ne 0 ] || [ $packets_received -eq 0 ]; then | ||
| 66 | error=1 | ||
| 67 | echo -e `cat $statistics | grep -r PING` >> $logfile | ||
| 68 | echo -e "Size: $datasize Iteration: $i\n" >> $logfile | ||
| 69 | fi | ||
| 70 | done | ||
| 71 | let datasize=$datasize+$stepsize | ||
| 72 | done | ||
| 73 | |||
| 74 | # Report failures | ||
| 75 | if [ $error -eq 1 ]; then | ||
| 76 | echo -e "=================== error report ===================\n" | ||
| 77 | cat $logfile | ||
| 78 | echo -e "====================================================\n" | ||
| 79 | clean_tasks | ||
| 80 | echo -e "FAIL: ping test for $ethernet_interface failed\n" | ||
| 81 | exit 1 | ||
| 82 | else | ||
| 83 | clean_tasks | ||
| 84 | echo -e "PASS: ping test for $ethernet_interface success\n" | ||
| 85 | fi | ||
| 86 | |||
| 87 | echo "PASS: $ethernet_interface test passed" | ||
| 88 | exit 0 | ||
