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