summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaresh Kamboju <naresh.kamboju@linaro.org>2016-09-08 16:56:00 +0530
committerNaresh Kamboju <naresh.kamboju@linaro.org>2016-09-08 16:56:00 +0530
commite5e33ecb1bd68559f8b3eeb66f5534751d071217 (patch)
treec382464062b2b1d2aa26d10568eb26552a55b6cf
parent7f19b1cbac2433735b1ca02eb0fad41d447b1e78 (diff)
v2: linux: Adding usb smoke testHEADmaster
Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
-rwxr-xr-xautomated/lib/sh-test-lib34
-rwxr-xr-xautomated/linux/usb-smoke/usb-smoke-test.sh101
-rw-r--r--automated/linux/usb-smoke/usb-smoke-test.yaml37
3 files changed, 171 insertions, 1 deletions
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib
index 8cbb931..87de9ca 100755
--- a/automated/lib/sh-test-lib
+++ b/automated/lib/sh-test-lib
@@ -55,12 +55,25 @@ check_return() {
fi
}
+report_pass() {
+ [ "$#" -ne 1 ] && error_msg "Usage: report_pass test"
+ local test="$1"
+ echo "${test} pass" | tee -a "${RESULT_FILE}"
+}
+
+report_fail() {
+ [ "$#" -ne 1 ] && error_msg "Usage: report_fail test"
+ local test="$1"
+ echo "${test} fail" | tee -a "${RESULT_FILE}"
+}
+
increment_return_status() {
local exit_code="$?"
[ "$#" -ne 1 ] && error_msg "Usage: increment_return_status value"
local value="$1"
- return $(expr $exit_code + $value)
+ return $(expr "${exit_code}" + "${value}")
}
+
add_metric() {
if [ "$#" -ne 4 ]; then
warn_msg "The number of parameters less then 4"
@@ -120,3 +133,22 @@ install_deps() {
esac
fi
}
+
+validate_check_sum() {
+ if [ "$#" -ne 2 ]; then
+ warn_msg "The number of parameters should be 2"
+ error_msg "Usage: validate_check_sum filename known_sha256sum"
+ return 1
+ fi
+ OUTPUT_FILE_NAME="$1"
+ SHA256SUM_CHECK="$2"
+ # Get sha256sum of output_file
+ GET_SHA256SUM=$(sha256sum ${OUTPUT_FILE_NAME} | awk '{print $1}')
+ echo "GET_SHA256SUM is "${GET_SHA256SUM}""
+ if [ "${SHA256SUM_CHECK}" = "${GET_SHA256SUM}" ] ; then
+ return 0
+ else
+ echo "checksum did not match"
+ return 1
+ fi
+}
diff --git a/automated/linux/usb-smoke/usb-smoke-test.sh b/automated/linux/usb-smoke/usb-smoke-test.sh
new file mode 100755
index 0000000..6f1ec1d
--- /dev/null
+++ b/automated/linux/usb-smoke/usb-smoke-test.sh
@@ -0,0 +1,101 @@
+#!/bin/bash
+#
+# USB smoke test cases
+#
+# Copyright (C) 2016, 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: Chase Qi <chase.qi@linaro.org>
+# Author: Naresh Kamboju <naresh.kamboju@linaro.org>
+#
+
+. ../../lib/sh-test-lib
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+STATUS=0
+
+usage() {
+ echo "Usage: $0 [-s <true>]" 1>&2
+ exit 1
+}
+
+while getopts "s:" o; do
+ case "$o" in
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+# Get the usb devices/hubs list
+list_all_usb_devices() {
+ info_msg "Running list-all-usb-devices test..."
+ lsusb
+ exit_on_fail "lsusb"
+}
+
+# Examine all usb devices/hubs
+examine_all_usb_devices() {
+ info_msg "Running examine_all_usb_devices test..."
+ USB_BUS="/dev/bus/usb/"
+ if [ -d "${USB_BUS}" ]; then
+ for bus in $(ls "${USB_BUS}"); do
+ for device in $(ls "${USB_BUS}""${bus}"/); do
+ info_msg "USB Bus "${bus}", device "${device}""
+ lsusb -D "${USB_BUS}""${bus}"/"${device}"
+ increment_return_status "${STATUS}"
+ STATUS=$?
+ done
+ done
+ if [ "${STATUS}" -ne 0 ]; then
+ report_fail "examine-all-usb-devices"
+ else
+ report_pass "examine-all-usb-devices"
+ fi
+ else
+ report_fail "examine-all-usb-devices"
+ fi
+}
+
+# Print supported usb protocols
+print_supported_usb_protocols() {
+ info_msg "Running print-supported-usb-protocols test..."
+ lsusb -v | grep -i bcdusb
+ check_return "print-supported-usb-protocols"
+}
+
+# Print supported usb speeds
+print_supported_usb_speeds() {
+ info_msg "Running print-supported-usb-speeds test..."
+ lsusb -t
+ check_return "print-supported-usb-speeds"
+}
+
+# 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}"
+
+info_msg "About to run USB test..."
+info_msg "Output directory: ${OUTPUT}"
+
+# Install usbutils package
+pkgs="usbutils"
+install_deps "${pkgs}" "${SKIP_INSTALL}"
+
+list_all_usb_devices
+examine_all_usb_devices
+print_supported_usb_protocols
+print_supported_usb_speeds
diff --git a/automated/linux/usb-smoke/usb-smoke-test.yaml b/automated/linux/usb-smoke/usb-smoke-test.yaml
new file mode 100644
index 0000000..9c2386b
--- /dev/null
+++ b/automated/linux/usb-smoke/usb-smoke-test.yaml
@@ -0,0 +1,37 @@
+metadata:
+ format: Lava-Test Test Definition 1.0
+ name: usb-test-basic
+ description: "Basic USB test for Linaro Ubuntu images. The test examines all available USB devices
+ and prints supported USB protocols and speed."
+ maintainer:
+ - chase.qi@linaro.org
+ - naresh.kamboju@linaro.org
+ os:
+ - debian
+ - ubuntu
+ - centos
+ - fedora
+ scope:
+ - functional
+ devices:
+ - panda
+ - panda-es
+ - arndale
+ - vexpress-tc2
+ - beaglebone-black
+ - juno
+ - hi6220-hikey
+ - apq8016-sbc
+ - mustang
+ - overdrive
+ - d02
+ - d03
+
+params:
+ SKIP_INSTALL: "false"
+
+run:
+ steps:
+ - cd ./automated/linux/usb-smoke
+ - ./usb-smoke-test.sh -s "${SKIP_INSTALL}"
+ - ../../utils/send-to-lava.sh ./output/result.txt