summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2014-01-29 11:22:48 +0000
committerLinaro Code Review <review@review.linaro.org>2014-01-29 11:22:48 +0000
commitae8cf61555233b8e631ea2376dd186840015e997 (patch)
tree155ec2e21af18ed72cc106daa5a577f4ca801274
parente7951d1a57724a4b98806a4f1bb284a6e340c5bf (diff)
parent7e27303996420d7c5c2706308c754814371e96c3 (diff)
Merge "Add Ethernet Test for Linaro Android"2014.01
-rw-r--r--android/ethernet-android.yaml26
-rwxr-xr-xandroid/scripts/ethernet-android.sh156
2 files changed, 182 insertions, 0 deletions
diff --git a/android/ethernet-android.yaml b/android/ethernet-android.yaml
new file mode 100644
index 0000000..d5b3c9f
--- /dev/null
+++ b/android/ethernet-android.yaml
@@ -0,0 +1,26 @@
+metadata:
+ name: ethernet-android
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Test Ethernet on Linaro Android"
+ maintainer:
+ - botao.sun@linaro.org
+ os:
+ - android
+ devices:
+ - panda
+ - panda-es
+ - vexpress-a9
+ - vexpress-tc2
+ - arndale
+ scope:
+ - functional
+
+run:
+ steps:
+ - "./android/scripts/ethernet-android.sh"
+
+parse:
+ pattern: "(?P<test_case_id>[a-zA-Z0-9_-]+):\\s(?P<result>\\w+)"
+ fixupdict:
+ FAIL: fail
+ PASS: pass \ No newline at end of file
diff --git a/android/scripts/ethernet-android.sh b/android/scripts/ethernet-android.sh
new file mode 100755
index 0000000..7c94fcb
--- /dev/null
+++ b/android/scripts/ethernet-android.sh
@@ -0,0 +1,156 @@
+#!/system/bin/sh
+#
+# Ethernet test cases for Linaro Android
+#
+# Copyright (C) 2013, Linaro Limited.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Author: Botao Sun <botao.sun@linaro.org>
+
+function check_return_fail() {
+ if [ $? -ne 0 ]; then
+ fail_test "$1"
+ return 0
+ else
+ return 1
+ fi
+}
+
+function fail_test() {
+ local reason=$1
+ echo "${TEST}: FAIL - ${reason}"
+}
+
+function pass_test() {
+ echo "${TEST}: PASS"
+}
+
+## Test case definitions
+# Check Ethernet can be disabled or not
+test_disable_ethernet() {
+ TEST="disable_ethernet"
+
+ echo `which busybox`
+ busybox ifconfig eth0 down
+
+ if [ $? -ne 0 ]; then
+ fail_test "Ethernet disable failed"
+ return 1
+ fi
+
+ sleep 20
+
+ echo "###########################################"
+ busybox ifconfig -a
+ echo "###########################################"
+
+ busybox ifconfig eth0 | grep "inet addr"
+
+ if [ $? -ne 1 ]; then
+ fail_test "Ethernet IP address still exists"
+ return 1
+ fi
+
+ pass_test
+}
+
+# Check Ethernet can be enabled or not
+test_enable_ethernet() {
+ TEST="enable_ethernet"
+
+ echo `which busybox`
+ busybox ifconfig eth0 up
+
+ if [ $? -ne 0 ]; then
+ fail_test "Ethernet enable failed"
+ return 1
+ fi
+
+ sleep 20
+
+ echo "###########################################"
+ busybox ifconfig -a
+ echo "###########################################"
+
+ busybox ifconfig eth0 | grep "inet addr"
+
+ if [ $? -ne 0 ]; then
+ fail_test "Ethernet IP not found"
+ return 1
+ fi
+
+ pass_test
+}
+
+# Ethernet ping test
+test_ethernet_ping() {
+ TEST="ethernet_ping"
+
+ echo `which busybox`
+ busybox ifconfig eth0 up
+
+ sleep 20
+
+ echo "###########################################"
+ busybox ifconfig -a
+ echo "###########################################"
+
+ busybox ifconfig eth0 | grep "inet addr"
+ if [ $? -ne 0 ]; then
+ fail_test "Ethernet IP not found"
+ return 1
+ fi
+
+ # Get ip address from Ethernet interface
+ ip_address_line=`busybox ifconfig eth0 | grep "inet addr"`
+ echo $ip_address_line
+
+ ip_address_array=($ip_address_line)
+ ip_address_element=${ip_address_array[1]}
+ echo $ip_address_element
+
+ ip_address=${ip_address_element:5}
+ echo $ip_address
+
+ # Ping test here
+ ping -c 5 -I ${ip_address} www.google.com
+ if [ $? -ne 0 ]; then
+ fail_test "Ping test failed from $ip_address"
+ return 1
+ fi
+
+ # Packet loss report
+ packet_loss_line=`ping -c 5 -I ${ip_address} www.google.com | grep "packet loss"`
+ echo $packet_loss_line
+
+ packet_loss_array=($packet_loss_line)
+ packet_loss=${packet_loss_array[5]}
+ echo "The packet loss rate is $packet_loss"
+
+ if [ "$packet_loss" != "0%" ]; then
+ fail_test "Packet loss happened, rate is $packet_loss"
+ return 1
+ fi
+
+ pass_test
+}
+
+# run the tests
+test_disable_ethernet
+test_enable_ethernet
+test_ethernet_ping
+# clean exit so lava-test can trust the results
+exit 0 \ No newline at end of file