-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathethernet_test.sh
103 lines (86 loc) · 2.61 KB
/
ethernet_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
function readINI()
{
FILENAME=$1; SECTION=$2; KEY=$3
RESULT=`awk -F '=' '/\['$SECTION'\]/{a=1}a==1&&$1~/'$KEY'/{print $2;exit}' $FILENAME`
echo $RESULT
}
cfg_name=cfg.ini
cfg_section=ETHERNET
failcnt=0
str_boardip=$(readINI $cfg_name $cfg_section boardip)
board_ip=$(echo $str_boardip | sed 's/\r//')
#echo $board_ip
str_vmip=$(readINI $cfg_name $cfg_section vmip)
vm_ip=$(echo $str_vmip | sed 's/\r//')
#echo $vm_ip
str_baud=$(readINI $cfg_name $cfg_section baud)
sbaud=$(echo $str_baud | sed 's/\r//')
#echo $sbaud
str_expectbaudtcp=$(readINI $cfg_name $cfg_section expectbaudtcp)
expect_baudtcp=$(echo $str_expectbaudtcp | sed 's/\r//')
#echo $expect_baudtcp
echo "******************ETH0 PING testing..."
ifconfig eth0 $board_ip netmask 255.255.255.0
ping_over=0
echo "ping $vm_ip -w 5"
ping $vm_ip -w 5 2>&1 | tee ethernet_test.log
while read line
do
result=$(echo $line | grep "time=")
if [[ "$result" != "" ]]
then
ping_over=1
echo "ping_over: $ping_over"
break
fi
done < ethernet_test.log
if [[ $ping_over != 0 ]]
then
echo "ETH0 PING PASS"
echo "ETH0 PING: PASS" >> test_result.log
else
echo "ETH0 PING FAIL"
echo "ETH0 PING: FAIL" >> test_result.log
fi
echo "******************ETH0 TCP TX testing..."
iperf3 -c $vm_ip -b $sbaud 2>&1 | tee ethernet_test.log
str=$(sed -n '16p' ethernet_test.log)
#echo "string: $str"
index=`expr index "$str" /`
#echo "index: $index"
txspeed=${str:$index-12:6}
#echo "txspeed: $txspeed"
tx_speed=${str:$index-12:17}
echo "tx speed: $tx_speed"
result=$(echo $txspeed $expect_baudtcp | awk '{if($1>$2) {printf 1} else {printf 0}}')
Mbits=`expr index "$str" M`
if [[ $result = 1 ]] && [[ $index != 0 ]] && [ $Mbits -gt 0 ]
then
echo "ETH0 TCP TX SPEED PASS"
echo "ETH0 TX: PASS tx speed: $tx_speed" >> test_result.log
else
echo "ETH0 TCP TX SPEED FAIL"
echo "ETH0 TX: FAIL tx speed: $tx_speed" >> test_result.log
fi
echo "******************ETH0 TCP RX testing..."
iperf3 -c $vm_ip -b $sbaud -R 2>&1 | tee ethernet_test.log
str=$(sed -n '18p' ethernet_test.log)
#echo "string: $str"
index=`expr index "$str" /`
#echo "index: $index"
rxspeed=${str:$index-12:6}
#echo "rxspeed: $rxspeed"
rx_speed=${str:$index-12:17}
echo "rx speed: $rx_speed"
result=$(echo $rxspeed $expect_baudtcp | awk '{if($1>$2) {printf 1} else {printf 0}}')
#echo "result=$result"
Mbits=`expr index "$str" M`
if [[ $result = 1 ]] && [[ $index != 0 ]] && [ $Mbits -gt 0 ]
then
echo "ETH0 TCP RX SPEED PASS"
echo "ETH0 RX: PASS rx speed: $rx_speed" >> test_result.log
else
echo "ETH0 TCP RX SPEED FAIL"
echo "ETH0 RX: FAIL rx speed: $rx_speed" >> test_result.log
fi