summaryrefslogtreecommitdiff
path: root/automated
diff options
context:
space:
mode:
authorNaresh Kamboju <naresh.kamboju@linaro.org>2016-11-14 15:43:59 +0530
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-11-16 09:23:15 +0000
commit3c4cd13b177176270f5d916b1f2156e7dfdfff72 (patch)
tree90f9859e07f12341afe90b728ed02ab3327a88de /automated
parentcfe003a9822a6394493b04f221d5ce267a19acd0 (diff)
automated: added Linux ethernet test
Ethernet test to validate given network interface, * check interface state is up * ping to default Gateway Change-Id: I55bd54367e98aba150c01cd957fb8ca90c3a0d10 Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-xautomated/linux/ethernet/ethernet.sh50
-rw-r--r--automated/linux/ethernet/ethernet.yaml37
2 files changed, 87 insertions, 0 deletions
diff --git a/automated/linux/ethernet/ethernet.sh b/automated/linux/ethernet/ethernet.sh
new file mode 100755
index 0000000..12fbec6
--- /dev/null
+++ b/automated/linux/ethernet/ethernet.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# shellcheck disable=SC1091
+. ../../lib/sh-test-lib
+
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+export RESULT_FILE
+
+# Default ethernet interface
+INTERFACE="eth0"
+
+usage() {
+ echo "Usage: $0 [-i <ethernet-interface> -s <true|false>]" 1>&2
+ exit 1
+}
+
+while getopts "s:i:" o; do
+ case "$o" in
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ # Ethernet interface
+ i) INTERFACE="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+# Test run.
+! check_root && error_msg "This script must be run as root"
+[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
+mkdir -p "${OUTPUT}"
+
+pkgs="net-tools"
+install_deps "${pkgs}" "${SKIP_INSTALL}"
+
+# Print all network interface status
+ip addr
+# Print given network interface status
+ip addr show "${INTERFACE}"
+
+# Get IP address of a given interface
+IP_ADDR=$(ip addr show "${INTERFACE}" | grep -a2 "state UP" | tail -1 | awk '{print $2}' | cut -f1 -d'/')
+
+[ -n "${IP_ADDR}" ]
+exit_on_fail "ethernet-ping-state-UP" "ethernet-ping-route"
+
+# Get default Route IP address of a given interface
+ROUTE_ADDR=$(ip route list | grep default | awk '{print $3}')
+
+# Run the test
+run_test_case "ping ${ROUTE_ADDR} -c 5" "ethernet-ping-route"
diff --git a/automated/linux/ethernet/ethernet.yaml b/automated/linux/ethernet/ethernet.yaml
new file mode 100644
index 0000000..d2999a2
--- /dev/null
+++ b/automated/linux/ethernet/ethernet.yaml
@@ -0,0 +1,37 @@
+metadata:
+ name: ethernet
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "This test checks if Ethernet is up and prints IP address."
+ maintainer:
+ - naresh.kamboju@linaro.org
+ os:
+ - debian
+ - ubuntu
+ - centos
+ - fedora
+ scope:
+ - functional
+ devices:
+ - panda
+ - panda-es
+ - arndale
+ - beaglebone-black
+ - juno
+ - hi6220-hikey
+ - apq8016-sbc
+ - d03
+ - d05
+ - overdrive
+ - mustang
+ - moonshot
+ - thunderX
+
+params:
+ SKIP_INSTALL: "False"
+ INTERFACE: "eth0"
+
+run:
+ steps:
+ - cd automated/linux/ethernet
+ - ./ethernet.sh -s "${SKIP_INSTALL}" -i "${INTERFACE}"
+ - ../../utils/send-to-lava.sh ./output/result.txt