2 # SPDX-License-Identifier: GPL-2.0
4 # Kselftest framework requirement - SKIP code is 4.
7 usage
() { echo "usbip_test.sh -b <busid> -p <usbip tools path>"; exit 1; }
9 while getopts "h:b:p:" arg
; do
27 if [ -z "${busid}" ]; then
31 echo "Running USB over IP Testing on $busid";
33 test_end_msg
="End of USB over IP Testing on $busid"
35 if [ $UID != 0 ]; then
36 echo "Please run usbip_test as root [SKIP]"
41 echo "Load usbip_host module"
42 if ! /sbin
/modprobe
-q -n usbip_host
; then
43 echo "usbip_test: module usbip_host is not found [SKIP]"
48 if /sbin
/modprobe
-q usbip_host
; then
49 echo "usbip_test: module usbip_host is loaded [OK]"
51 echo "usbip_test: module usbip_host failed to load [FAIL]"
56 echo "Load vhci_hcd module"
57 if /sbin
/modprobe
-q vhci_hcd
; then
58 echo "usbip_test: module vhci_hcd is loaded [OK]"
60 echo "usbip_test: module vhci_hcd failed to load [FAIL]"
64 echo "=============================================================="
68 if [ ! -f src
/usbip
]; then
69 echo "Please build usbip tools"
74 echo "Expect to see export-able devices";
76 echo "=============================================================="
78 echo "Run lsusb to see all usb devices"
80 echo "=============================================================="
84 echo "Get exported devices from localhost - expect to see none";
85 src
/usbip list
-r localhost
;
86 echo "=============================================================="
89 src
/usbip
bind -b $busid;
90 echo "=============================================================="
92 echo "Run lsusb - bound devices should be under usbip_host control"
94 echo "=============================================================="
96 echo "bind devices - expect already bound messages"
97 src
/usbip
bind -b $busid;
98 echo "=============================================================="
100 echo "Get exported devices from localhost - expect to see exported devices";
101 src
/usbip list
-r localhost
;
102 echo "=============================================================="
104 echo "unbind devices";
105 src
/usbip unbind
-b $busid;
106 echo "=============================================================="
108 echo "Run lsusb - bound devices should be rebound to original drivers"
110 echo "=============================================================="
112 echo "unbind devices - expect no devices bound message";
113 src
/usbip unbind
-b $busid;
114 echo "=============================================================="
116 echo "Get exported devices from localhost - expect to see none";
117 src
/usbip list
-r localhost
;
118 echo "=============================================================="
120 echo "List imported devices - expect to see none";
122 echo "=============================================================="
124 echo "Import devices from localhost - should fail with no devices"
125 src
/usbip attach
-r localhost
-b $busid;
126 echo "=============================================================="
129 src
/usbip
bind -b $busid;
130 echo "=============================================================="
132 echo "List imported devices - expect to see exported devices";
133 src
/usbip list
-r localhost
;
134 echo "=============================================================="
136 echo "List imported devices - expect to see none";
138 echo "=============================================================="
140 echo "Import devices from localhost - should work"
141 src
/usbip attach
-r localhost
-b $busid;
142 echo "=============================================================="
144 echo "List imported devices - expect to see imported devices";
146 echo "=============================================================="
148 echo "Import devices from localhost - expect already imported messages"
149 src
/usbip attach
-r localhost
-b $busid;
150 echo "=============================================================="
152 echo "Un-import devices";
153 src
/usbip detach
-p 00;
154 src
/usbip detach
-p 01;
155 echo "=============================================================="
157 echo "List imported devices - expect to see none";
159 echo "=============================================================="
161 echo "Un-import devices - expect no devices to detach messages";
162 src
/usbip detach
-p 00;
163 src
/usbip detach
-p 01;
164 echo "=============================================================="
166 echo "Detach invalid port tests - expect invalid port error message";
167 src
/usbip detach
-p 100;
168 echo "=============================================================="
170 echo "Expect to see export-able devices";
172 echo "=============================================================="
174 echo "Remove usbip_host module";
177 echo "Run lsusb - bound devices should be rebound to original drivers"
179 echo "=============================================================="
181 echo "Run bind without usbip_host - expect fail"
182 src
/usbip
bind -b $busid;
183 echo "=============================================================="
185 echo "Run lsusb - devices that failed to bind aren't bound to any driver"
187 echo "=============================================================="
189 echo "modprobe usbip_host - does it work?"
190 /sbin
/modprobe usbip_host
191 echo "Should see -busid- is not in match_busid table... skip! dmesg"
192 echo "=============================================================="
193 dmesg |
grep "is not in match_busid table"
194 echo "=============================================================="