summaryrefslogtreecommitdiff
path: root/automated/linux
diff options
context:
space:
mode:
Diffstat (limited to 'automated/linux')
-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