summaryrefslogtreecommitdiffstats
path: root/recipes-test/ddt-runner/files/scripts/p4080ds/usb
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-test/ddt-runner/files/scripts/p4080ds/usb')
-rwxr-xr-xrecipes-test/ddt-runner/files/scripts/p4080ds/usb100
1 files changed, 100 insertions, 0 deletions
diff --git a/recipes-test/ddt-runner/files/scripts/p4080ds/usb b/recipes-test/ddt-runner/files/scripts/p4080ds/usb
new file mode 100755
index 0000000..970e913
--- /dev/null
+++ b/recipes-test/ddt-runner/files/scripts/p4080ds/usb
@@ -0,0 +1,100 @@
1#!/bin/sh
2#
3# This script is used to test usb functionality for p4080ds.
4#
5
6result=0
7devpath=""
8usbinfo=""
9
10usbutils_is_installed=`which lsusb`
11if [ -z $usbutils_is_installed ]; then
12 echo "FAIL: Cannot find lsusb"
13 exit 1
14fi
15
16usbdev_num=`lsusb | grep -v root\ hub | wc -l`
17if [ $usbdev_num -eq 0 ]; then
18 echo "FAIL: USB device is not connected"
19 exit 1
20else
21 echo "$usbdev_num USB device(s) connected"
22fi
23
24sd=`ls -l /dev/sd[^0-9] | awk '{print $5 $6 "," $10}'`
25if [ -z "$sd" ]; then
26 echo "FAIL: find sd device"
27 exit 1
28else
29 echo "PASS: find sd device"
30fi
31
32HDPARM=`which hdparm`
33if [ -z $HDPARM ]; then
34 result=$?
35 echo "FAIL: find hdparm"
36fi
37 echo "PASS: find hdparm"
38
39for s in $sd
40do
41 devpath=`echo "$s" | awk -F "," '{print "/sys/dev/block/" $1 ":" $2}'`
42 usbinfo=`ls -l $devpath | grep usb`
43
44 if [ -z "$usbinfo" ] ; then
45 continue
46 fi
47
48 s=`echo "$s" | awk -F "," '{print $3}'`
49
50 echo "Testing $s"
51 $HDPARM -I $s
52 if [ $? -ne 0 ]; then
53 result=$?
54 echo "FAIL: $HDPARM -I $s Detailed/current information directly from $s"
55 else
56 echo "PASS: $HDPARM -I $s Detailed/current information directly from $s"
57 fi
58
59 $HDPARM -tT $s
60 if [ $? -ne 0 ]; then
61 result=$?
62 echo "FAIL: $HDPARM -tT $s Perform device/cache read timings on $s"
63 else
64 echo "PASS: $HDPARM -tT $s Perform device/cache read timings on $s"
65 fi
66
67 mkdir -p /mnt/usb_tmp
68 for partition in `ls "$s"[1-9]`
69 do
70 echo "Testing $partition"
71
72 mount "$partition" /mnt/usb_tmp
73 if [ $? -ne 0 ]; then
74 result=$?
75 echo "FAIL: mount $s"
76 else
77 echo "PASS: mount $s"
78 dd if=/dev/urandom of=/mnt/usb_tmp/writefile bs=1M count=50
79 if [ $? -ne 0 ]; then
80 result=$?
81 echo "FAIL: write test on $s"
82 else
83 echo "PASS: write test on $s"
84 rm -f /mnt/usb_tmp/writefile
85 fi
86 dd if=$s of=/mnt/usb_tmp/readfile bs=1M count=10
87 if [ $? -ne 0 ]; then
88 result=$?
89 echo "FAIL: read test on $s"
90 else
91 echo "PASS: read test on $s"
92 rm -f /mnt/usb_tmp/readfile
93 fi
94 umount /mnt/usb_tmp
95 fi
96 done
97
98 rm -fr /mnt/usb_tmp
99done
100exit $result