summaryrefslogtreecommitdiffstats
path: root/recipes-test/ddt-runner/files/scripts/p2041rdb/ethernet
diff options
context:
space:
mode:
authorTudor Florea <tudor.florea@enea.com>2015-10-08 22:50:30 +0200
committerTudor Florea <tudor.florea@enea.com>2015-10-08 22:50:30 +0200
commit56fadd5827f95396b1237dfe628e2b8a3d28dd00 (patch)
treea1bcdf8f990f18fb0222d215522a99176719c4eb /recipes-test/ddt-runner/files/scripts/p2041rdb/ethernet
downloadmeta-enea-56fadd5827f95396b1237dfe628e2b8a3d28dd00.tar.gz
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'recipes-test/ddt-runner/files/scripts/p2041rdb/ethernet')
-rwxr-xr-xrecipes-test/ddt-runner/files/scripts/p2041rdb/ethernet111
1 files changed, 111 insertions, 0 deletions
diff --git a/recipes-test/ddt-runner/files/scripts/p2041rdb/ethernet b/recipes-test/ddt-runner/files/scripts/p2041rdb/ethernet
new file mode 100755
index 0000000..0f2b4cf
--- /dev/null
+++ b/recipes-test/ddt-runner/files/scripts/p2041rdb/ethernet
@@ -0,0 +1,111 @@
1#!/bin/sh
2
3
4exit1() {
5 echo $@ >&2
6 exit 1
7}
8
9
10err() {
11 echo $@ >&2
12 exit_status=1
13}
14
15
16get_default_gw() {
17 echo $(route | grep default | awk '{ print $2 }')
18}
19
20
21test_eth_device() {
22 local readonly dev=$1
23 local readonly ethernet_ping_ipaddr=$2
24 local readonly MINDATASIZE=56
25 local readonly MAXDATASIZE=650
26 local readonly STEPSIZE=100
27 local readonly ITERATION=2
28 local datasize
29 local i
30 local ping_err
31 for i in `seq 1 $ITERATION`; do
32 datasize=$MINDATASIZE
33 while [ $datasize -le $MAXDATASIZE ]; do
34 ping -I $dev -c 1 -s $datasize $ethernet_ping_ipaddr > $STATISTICS
35 ping_err=$?
36 packets_received=`cat $STATISTICS | grep "received" |
37 awk '{print$4}'`
38
39 # Evaluate possible errors on the ping operation
40 if [ $ping_err -ne 0 ] || [ -z "$packets_received" ] ||
41 [ $packets_received -eq 0 ]; then
42 err "FAIL: ping $ethernet_ping_ipaddr through $dev"
43 cat $STATISTICS >> $LOGFILE
44 echo "Size: $datasize Iteration: $i" >> $LOGFILE
45 fi
46 datasize=$((datasize+STEPSIZE))
47 done
48 done
49}
50
51
52clean_tasks() {
53 echo "Executing clean up tasks"
54 rm -f $LOGFILE $STATISTICS
55}
56
57
58cleanup() {
59 echo "Aborting script execution"
60 clean_tasks
61 exit 1
62}
63
64
65
66readonly LOGFILE=`/bin/mktemp`
67readonly STATISTICS=`/bin/mktemp`
68exit_status=0
69
70trap cleanup SIGHUP SIGINT SIGTERM
71
72
73
74readonly DEF_GW=$(get_default_gw)
75
76[ -n "$DEF_GW" ] && echo "Found default gw $DEF_GW" ||
77 exit1 "FAIL: no default gw"
78
79readonly S=:
80readonly DEVS="$(route -n | tail -n +3 | sort -k8 -u | awk '{print $8"'$S'"$2}')"
81
82if [ -n "$DEVS" ]; then
83 echo "Will test: $DEVS"
84else
85 exit1 "FAIL: no ethernet devices to test"
86fi
87
88for iface_gw in $DEVS; do
89 iface=$(echo "$iface_gw" | sed -n 's/\(.*\)'$S'.*/\1/p')
90 gw=$(echo "$iface_gw" | sed -n 's/.*'$S'\(.*\)/\1/p')
91 if [ -z "$gw" ]; then
92 err "FAIL: no ethernet gateway for $iface"
93 else
94 [ "$gw" = 0.0.0.0 ] && gw="$DEF_GW"
95 echo "Testing $iface:$gw"
96 test_eth_device $iface $gw
97 fi
98done
99
100# Report failures
101if [ $exit_status -ne 0 ]; then
102 echo "=================== error report ==================="
103 cat $LOGFILE
104 echo "===================================================="
105 echo "FAIL: ping test"
106else
107 echo "PASS: ping test success"
108fi
109
110clean_tasks
111exit $exit_status