summaryrefslogtreecommitdiff
path: root/automated
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-02-06 17:09:32 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-02-07 13:30:47 +0000
commit1b2ee2c16d62a1c410059280b9525552b5c3fada (patch)
treeb96f1c76685524e503fbf3689c527b5138206125 /automated
parent050e4e2c929b136a68b8455496eb67f2f1172adb (diff)
automated: linux: add lshw test
Change-Id: Iec4efd0a4d4e9dede50505b7284d6221b83a7433 Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-xautomated/linux/lshw/lshw.sh59
-rw-r--r--automated/linux/lshw/lshw.yaml36
2 files changed, 95 insertions, 0 deletions
diff --git a/automated/linux/lshw/lshw.sh b/automated/linux/lshw/lshw.sh
new file mode 100755
index 0000000..4017488
--- /dev/null
+++ b/automated/linux/lshw/lshw.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# shellcheck disable=SC1091
+. ../../lib/sh-test-lib
+
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+export RESULT_FILE
+
+# The number of hardware class may vary dpending on the system under testing.
+# This test check if lshw able to report the classes defined in ${CLASSES},
+# which are very common ones by default and can be changed with -c.
+CLASSES="system bus processor memory network"
+
+usage() {
+ echo "usage: $0 [-s <true|false>] [-c classes]" 1>&2
+ exit 1
+}
+
+while getopts ':s:c:' opt; do
+ case "${opt}" in
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ c) CLASSES="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+! check_root && error_msg "lshw must be run as super user or it will only report partial information."
+[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
+mkdir -p "${OUTPUT}"
+
+install_deps "lshw" "${SKIP_INSTALL}"
+
+# If lshw fails to run, skip the following tests and exit.
+skip_list=$(echo "${CLASSES}" | awk '{for (i=1; i<=NF; i++) printf("lshw-%s ",$i)}')
+lshw > "${OUTPUT}/lshw.txt"
+exit_on_fail "lshw-run" "${skip_list}"
+
+# Obtain classes detected by lshw.
+lshw -json > "${OUTPUT}/lshw.json"
+detected_classes=$(grep '"class" : ' "${OUTPUT}/lshw.json" | awk -F'"' '{print $(NF-1)}' | uniq)
+
+# Check if lshw able to detect and report the classes defined in ${CLASSES}.
+for class in ${CLASSES}; do
+ logfile="${OUTPUT}/lshw-${class}.txt"
+ if ! echo "${detected_classes}" | grep -q "${class}"; then
+ warn_msg "lshw failed to detect ${class} class!"
+ report_fail "lshw-${class}"
+ else
+ # lshw may exit with zero and report nothing, so check the size of
+ # logfile as well.
+ if lshw -class "${class}" > "${logfile}" || ! test -s "${logfile}"; then
+ report_pass "lshw-${class}"
+ else
+ report_fail "lshw-${class}"
+ fi
+ cat "${logfile}"
+ fi
+done
diff --git a/automated/linux/lshw/lshw.yaml b/automated/linux/lshw/lshw.yaml
new file mode 100644
index 0000000..f63fc90
--- /dev/null
+++ b/automated/linux/lshw/lshw.yaml
@@ -0,0 +1,36 @@
+metadata:
+ name: lshw
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "lshw is a small tool to extract detailed information
+ on the hardware configuration of the machine."
+ maintainer:
+ - chase.qi@linaro.org
+ os:
+ - debian
+ - ubuntu
+ - fedora
+ - centos
+ - openembedded
+ scope:
+ - functional
+ environment:
+ - lava-test-shell
+ devices:
+ - hi6220-hikey
+ - apq8016-sbc
+ - mustang
+ - moonshot
+ - thunderX
+ - d03
+ - d05
+
+params:
+ # Test if lshw able to report the classes pre-defined in ${CLASSES}.
+ CLASSES: "system bus processor memory network"
+ SKIP_INSTALL: "false"
+
+run:
+ steps:
+ - cd ./automated/linux/lshw/
+ - ./lshw.sh -s "${SKIP_INSTALL}" -c "${CLASSES}"
+ - ../../utils/send-to-lava.sh ./output/result.txt