summaryrefslogtreecommitdiff
path: root/ubuntu/scripts
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2014-11-17 22:00:58 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2014-11-24 16:44:15 +0000
commitddc9ab2b9bf1ca9db7dd9c7b48031dc71edbee60 (patch)
treec326f85480c58f7d625dd8e97e1dd2e442b0c971 /ubuntu/scripts
parent44a85d1316b9730be34bd1606902651bd612e92f (diff)
ubuntu: add dedicated usb test case
Test code has been validated in LAVA. Signed-off by: Chase Qi <chase.qi@linaro.org> Change-Id: I58845cc31647b666aecc78895eea0e4871ee72fa
Diffstat (limited to 'ubuntu/scripts')
-rwxr-xr-xubuntu/scripts/usb-test-basic.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/ubuntu/scripts/usb-test-basic.sh b/ubuntu/scripts/usb-test-basic.sh
new file mode 100755
index 0000000..fa30d6c
--- /dev/null
+++ b/ubuntu/scripts/usb-test-basic.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+#
+# USB test cases for Linux Linaro ubuntu
+#
+# Copyright (C) 2012 - 2014, 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>
+#
+
+# generate test result with lava-test-case
+test_result(){
+if [ $? -eq 0 ]; then
+ lava-test-case $1 --result pass
+else
+ lava-test-case $1 --result fail
+fi
+}
+
+# get the usb devices/hubs list
+echo "========"
+lsusb
+test_result list-all-usb-devices
+
+# examine all usb devices/hubs
+if [ -d /dev/bus/usb/ ]; then
+ for bus in `ls /dev/bus/usb/`; do
+ for device in `ls /dev/bus/usb/$bus/`; do
+ echo "========"
+ echo "Bus $bus, device $device"
+ lsusb -D /dev/bus/usb/$bus/$device
+ status=$?
+
+ if [ $status -ne 0 ]; then
+ echo "Bus$bus-Device$device examination failed"
+ break 2
+ fi
+
+ done
+ done
+
+ if [ $status -eq 0 ]; then
+ lava-test-case examine-all-usb-devices --result pass
+ else
+ lava-test-case examine-all-usb-devices --result fail
+ fi
+
+else
+ echo "/dev/bus/usb/ not exists"
+ lava-test-case examine-all-usb-devices --result fail
+fi
+
+# print supported usb protocols
+echo "========"
+if [ -z "`lsusb -v | grep -i bcdusb`" ]; then
+ lava-test-case print-supported-protocols --result fail
+else
+ lsusb -v | grep -i bcdusb | sort | uniq
+ test_result print-supported-protocols
+fi
+
+# print supported speeds
+echo "========"
+if [ -z "`lsusb -t`" ]; then
+ lava-test-case print-supported-speeds --result fail
+else
+ lsusb -t
+ test_result print-supported-speeds
+fi
+# clean exit so lava-test can trust the results
+exit 0