aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuah Khan (Samsung OSG) <shuah@kernel.org>2018-05-30 23:00:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-31 11:49:48 -0400
commit5ef12cb4a3a78ffb331c03a795a15eea4ae35155 (patch)
tree367751ffec9bb765b54f8830a3ac95a6cc5b5834
parentbc9832c4a1921a662870d51f81a699ec8c18545f (diff)
selftests: add test for USB over IP driver
Add test for USB over IP driver. This test runs several tests on a device specified in the -b <busid> argument and path to the usbip tools. usbip_test.sh -b <busid> -p <usbip tools path> e.g: cd tools/testing selftests/drivers/usb/usbip sudo ./usbip_test.sh -b 3-10.2 -p <yoursrctree>/tools/usb/usbip This test should be run as root and user should build usbip tools before running the test. The usbip test isn't included in the Kselftest run as it requires user to specify a device to run tests on. Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--MAINTAINERS1
-rwxr-xr-xtools/testing/selftests/drivers/usb/usbip/usbip_test.sh198
2 files changed, 199 insertions, 0 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 4b7d977572ac..34d02d8a7728 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14670,6 +14670,7 @@ S: Maintained
14670F: Documentation/usb/usbip_protocol.txt 14670F: Documentation/usb/usbip_protocol.txt
14671F: drivers/usb/usbip/ 14671F: drivers/usb/usbip/
14672F: tools/usb/usbip/ 14672F: tools/usb/usbip/
14673F: tools/testing/selftests/drivers/usb/usbip/
14673 14674
14674USB PEGASUS DRIVER 14675USB PEGASUS DRIVER
14675M: Petko Manolov <petkan@nucleusys.com> 14676M: Petko Manolov <petkan@nucleusys.com>
diff --git a/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh b/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh
new file mode 100755
index 000000000000..1893d0f59ad7
--- /dev/null
+++ b/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh
@@ -0,0 +1,198 @@
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4# Kselftest framework requirement - SKIP code is 4.
5ksft_skip=4
6
7usage() { echo "usbip_test.sh -b <busid> -p <usbip tools path>"; exit 1; }
8
9while getopts "h:b:p:" arg; do
10 case "${arg}" in
11 h)
12 usage
13 ;;
14 b)
15 busid=${OPTARG}
16 ;;
17 p)
18 tools_path=${OPTARG}
19 ;;
20 *)
21 usage
22 ;;
23 esac
24done
25shift $((OPTIND-1))
26
27if [ -z "${busid}" ]; then
28 usage
29fi
30
31echo "Running USB over IP Testing on $busid";
32
33test_end_msg="End of USB over IP Testing on $busid"
34
35if [ $UID != 0 ]; then
36 echo "Please run usbip_test as root [SKIP]"
37 echo $test_end_msg
38 exit $ksft_skip
39fi
40
41echo "Load usbip_host module"
42if ! /sbin/modprobe -q -n usbip_host; then
43 echo "usbip_test: module usbip_host is not found [SKIP]"
44 echo $test_end_msg
45 exit $ksft_skip
46fi
47
48if /sbin/modprobe -q usbip_host; then
49 /sbin/modprobe -q -r test_bitmap
50 echo "usbip_test: module usbip_host is loaded [OK]"
51else
52 echo "usbip_test: module usbip_host failed to load [FAIL]"
53 echo $test_end_msg
54 exit 1
55fi
56
57echo "Load vhci_hcd module"
58if /sbin/modprobe -q vhci_hcd; then
59 /sbin/modprobe -q -r test_bitmap
60 echo "usbip_test: module vhci_hcd is loaded [OK]"
61else
62 echo "usbip_test: module vhci_hcd failed to load [FAIL]"
63 echo $test_end_msg
64 exit 1
65fi
66echo "=============================================================="
67
68cd $tools_path;
69
70if [ ! -f src/usbip ]; then
71 echo "Please build usbip tools"
72 echo $test_end_msg
73 exit $ksft_skip
74fi
75
76echo "Expect to see export-able devices";
77src/usbip list -l;
78echo "=============================================================="
79
80echo "Run lsusb to see all usb devices"
81lsusb -t;
82echo "=============================================================="
83
84src/usbipd -D;
85
86echo "Get exported devices from localhost - expect to see none";
87src/usbip list -r localhost;
88echo "=============================================================="
89
90echo "bind devices";
91src/usbip bind -b $busid;
92echo "=============================================================="
93
94echo "Run lsusb - bound devices should be under usbip_host control"
95lsusb -t;
96echo "=============================================================="
97
98echo "bind devices - expect already bound messages"
99src/usbip bind -b $busid;
100echo "=============================================================="
101
102echo "Get exported devices from localhost - expect to see exported devices";
103src/usbip list -r localhost;
104echo "=============================================================="
105
106echo "unbind devices";
107src/usbip unbind -b $busid;
108echo "=============================================================="
109
110echo "Run lsusb - bound devices should be rebound to original drivers"
111lsusb -t;
112echo "=============================================================="
113
114echo "unbind devices - expect no devices bound message";
115src/usbip unbind -b $busid;
116echo "=============================================================="
117
118echo "Get exported devices from localhost - expect to see none";
119src/usbip list -r localhost;
120echo "=============================================================="
121
122echo "List imported devices - expect to see none";
123src/usbip port;
124echo "=============================================================="
125
126echo "Import devices from localhost - should fail with no devices"
127src/usbip attach -r localhost -b $busid;
128echo "=============================================================="
129
130echo "bind devices";
131src/usbip bind -b $busid;
132echo "=============================================================="
133
134echo "List imported devices - expect to see exported devices";
135src/usbip list -r localhost;
136echo "=============================================================="
137
138echo "List imported devices - expect to see none";
139src/usbip port;
140echo "=============================================================="
141
142echo "Import devices from localhost - should work"
143src/usbip attach -r localhost -b $busid;
144echo "=============================================================="
145
146echo "List imported devices - expect to see imported devices";
147src/usbip port;
148echo "=============================================================="
149
150echo "Import devices from localhost - expect already imported messages"
151src/usbip attach -r localhost -b $busid;
152echo "=============================================================="
153
154echo "Un-import devices";
155src/usbip detach -p 00;
156src/usbip detach -p 01;
157echo "=============================================================="
158
159echo "List imported devices - expect to see none";
160src/usbip port;
161echo "=============================================================="
162
163echo "Un-import devices - expect no devices to detach messages";
164src/usbip detach -p 00;
165src/usbip detach -p 01;
166echo "=============================================================="
167
168echo "Detach invalid port tests - expect invalid port error message";
169src/usbip detach -p 100;
170echo "=============================================================="
171
172echo "Expect to see export-able devices";
173src/usbip list -l;
174echo "=============================================================="
175
176echo "Remove usbip_host module";
177rmmod usbip_host;
178
179echo "Run lsusb - bound devices should be rebound to original drivers"
180lsusb -t;
181echo "=============================================================="
182
183echo "Run bind without usbip_host - expect fail"
184src/usbip bind -b $busid;
185echo "=============================================================="
186
187echo "Run lsusb - devices that failed to bind aren't bound to any driver"
188lsusb -t;
189echo "=============================================================="
190
191echo "modprobe usbip_host - does it work?"
192/sbin/modprobe usbip_host
193echo "Should see -busid- is not in match_busid table... skip! dmesg"
194echo "=============================================================="
195dmesg | grep "is not in match_busid table"
196echo "=============================================================="
197
198echo $test_end_msg