2 # SPDX-License-Identifier: GPL-2.0
4 # test types can be passed on the command line:
6 # - control: any device can do this
7 # - out, in: out needs 'bulk sink' firmware, in needs 'bulk src'
8 # - iso-out, iso-in: out needs 'iso sink' firmware, in needs 'iso src'
9 # - halt: needs bulk sink+src, tests halt set/clear from host
10 # - unlink: needs bulk sink and/or src, test HCD unlink processing
11 # - loop: needs firmware that will buffer N transfers
13 # run it for hours, days, weeks.
17 # this default provides a steady test load for a bulk device
19 TYPES
='control out in'
20 #TYPES='control out in halt'
25 # - include unlink tests
26 # - add some ${RANDOM}ness
27 # - connect several devices concurrently (same HC)
28 # - keep HC's IRQ lines busy with unrelated traffic (IDE, net, ...)
29 # - add other concurrent system loads
32 declare -i COUNT BUFLEN
37 # NOTE: the 'in' and 'out' cases are usually bulk, but can be
38 # set up to use interrupt transfers by 'usbtest' module options
41 if [ "$DEVICE" = "" ]; then
42 echo "testing ALL recognized usbtest devices"
51 if ! .
/testusb
$TEST_ARGS -s $BUFLEN -c $COUNT $
* 2>/dev
/null
65 # FIXME use /sys/bus/usb/device/$THIS/bConfigurationValue to
66 # check and change configs
72 if [ "$CONFIG" = "" ]; then
74 echo "assuming $CONFIG configuration"
77 if [ "$CONFIG" = $1 ]; then
81 echo "** device must be in $1 config, but it's $CONFIG instead"
98 # FIXME automatically multiply COUNT by 10 when
99 # /sys/bus/usb/device/$THIS/speed == "480"
105 # any device, in any configuration, can use this.
106 echo '** Control test cases:'
108 echo "test 9: ch9 postconfig"
110 echo "test 10: control queueing"
111 do_test
-t 10 -c 5000
113 # this relies on some vendor-specific commands
114 echo "test 14: control writes"
115 do_test
-t 14 -c 15000 -s 256 -v 1
117 echo "test 21: control writes, unaligned"
118 do_test
-t 21 -c 100 -s 256 -v 1
123 check_config sink-src
124 echo '** Host Write (OUT) test cases:'
126 echo "test 1: $COUNT transfers, same size"
128 echo "test 3: $COUNT transfers, variable/short size"
132 echo "test 17: $COUNT transfers, unaligned DMA map by core"
135 echo "test 19: $COUNT transfers, unaligned DMA map by usb_alloc_coherent"
139 echo "test 5: $COUNT scatterlists, same size entries"
142 # try to trigger short OUT processing bugs
143 echo "test 7a: $COUNT scatterlists, variable size/short entries"
146 echo "test 7b: $COUNT scatterlists, variable size/bigger entries"
149 echo "test 7c: $COUNT scatterlists, variable size/micro entries"
154 check_config sink-src
155 echo '** Host ISOCHRONOUS Write (OUT) test cases:'
157 # at peak iso transfer rates:
158 # - usb 2.0 high bandwidth, this is one frame.
159 # - usb 1.1, it's twenty-four frames.
166 echo "test 15: $COUNT transfers, same size"
167 # do_test -t 15 -g 3 -v 0
169 do_test
-t 15 -g 8 -v 0
171 # FIXME it'd make sense to have an iso OUT test issuing
172 # short writes on more packets than the last one
175 echo "test 22: $COUNT transfers, non aligned"
176 do_test
-t 22 -g 8 -v 0
181 check_config sink-src
182 echo '** Host Read (IN) test cases:'
184 # NOTE: these "variable size" reads are just multiples
185 # of 512 bytes, no EOVERFLOW testing is done yet
187 echo "test 2: $COUNT transfers, same size"
189 echo "test 4: $COUNT transfers, variable size"
193 echo "test 18: $COUNT transfers, unaligned DMA map by core"
196 echo "test 20: $COUNT transfers, unaligned DMA map by usb_alloc_coherent"
200 echo "test 6: $COUNT scatterlists, same size entries"
202 echo "test 8: $COUNT scatterlists, variable size entries"
207 check_config sink-src
208 echo '** Host ISOCHRONOUS Read (IN) test cases:'
210 # at peak iso transfer rates:
211 # - usb 2.0 high bandwidth, this is one frame.
212 # - usb 1.1, it's twenty-four frames.
219 echo "test 16: $COUNT transfers, same size"
220 # do_test -t 16 -g 3 -v 0
222 do_test
-t 16 -g 8 -v 0
224 # FIXME since iso expects faults, it'd make sense
225 # to have an iso IN test issuing short reads ...
228 echo "test 23: $COUNT transfers, unaligned"
229 do_test
-t 23 -g 8 -v 0
234 # NOTE: sometimes hardware doesn't cooperate well with halting
235 # endpoints from the host side. so long as mass-storage class
236 # firmware can halt them from the device, don't worry much if
237 # you can't make this test work on your device.
239 echo "test 13: $COUNT halt set/clear"
245 echo "test 11: $COUNT read unlinks"
248 echo "test 12: $COUNT write unlinks"
253 # defaults need too much buffering for ez-usb devices
257 # modprobe g_zero qlen=$COUNT buflen=$BUFLEN loopdefault
258 check_config loopback
260 # FIXME someone needs to write and merge a version of this
262 echo "write $COUNT buffers of $BUFLEN bytes, read them back"
264 echo "write $COUNT variable size buffers, read them back"
269 echo "Don't understand test type $TYPE"