aboutsummaryrefslogtreecommitdiffstats
path: root/tools/usb
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2011-01-16 13:17:16 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-01-22 22:42:13 -0500
commitc17d936e05a186ce5bce2acf2d58a4172df7f435 (patch)
treec891c4d544ef5fdf8d41d9a3cc557f1682f75b79 /tools/usb
parent084fb206a91f72b22c4e2f41709730a81e3e0de6 (diff)
USB: usbtest - add shell script to test HCDs
This patch just adds the script available at http://www.linux-usb.org/usbtest/test.sh as is. Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'tools/usb')
-rw-r--r--tools/usb/hcd-tests.sh249
1 files changed, 249 insertions, 0 deletions
diff --git a/tools/usb/hcd-tests.sh b/tools/usb/hcd-tests.sh
new file mode 100644
index 000000000000..d212192d58bc
--- /dev/null
+++ b/tools/usb/hcd-tests.sh
@@ -0,0 +1,249 @@
1#!/bin/sh
2#
3# test types can be passed on the command line:
4#
5# - control: any device can do this
6# - out, in: out needs 'bulk sink' firmware, in needs 'bulk src'
7# - iso-out, iso-in: out needs 'iso sink' firmware, in needs 'iso src'
8# - halt: needs bulk sink+src, tests halt set/clear from host
9# - unlink: needs bulk sink and/or src, test HCD unlink processing
10# - loop: needs firmware that will buffer N transfers
11#
12# run it for hours, days, weeks.
13#
14
15#
16# this default provides a steady test load for a bulk device
17#
18TYPES='control out in'
19#TYPES='control out in halt'
20
21#
22# to test HCD code
23#
24# - include unlink tests
25# - add some ${RANDOM}ness
26# - connect several devices concurrently (same HC)
27# - keep HC's IRQ lines busy with unrelated traffic (IDE, net, ...)
28# - add other concurrent system loads
29#
30
31declare -i COUNT BUFLEN
32
33COUNT=50000
34BUFLEN=2048
35
36# NOTE: the 'in' and 'out' cases are usually bulk, but can be
37# set up to use interrupt transfers by 'usbtest' module options
38
39
40if [ "$DEVICE" = "" ]; then
41 echo "testing ALL recognized usbtest devices"
42 echo ""
43 TEST_ARGS="-a"
44else
45 TEST_ARGS=""
46fi
47
48do_test ()
49{
50 if ! ./testusb $TEST_ARGS -s $BUFLEN -c $COUNT $* 2>/dev/null
51 then
52 echo "FAIL"
53 exit 1
54 fi
55}
56
57ARGS="$*"
58
59if [ "$ARGS" = "" ];
60then
61 ARGS="$TYPES"
62fi
63
64# FIXME use /sys/bus/usb/device/$THIS/bConfigurationValue to
65# check and change configs
66
67CONFIG=''
68
69check_config ()
70{
71 if [ "$CONFIG" = "" ]; then
72 CONFIG=$1
73 echo "assuming $CONFIG configuration"
74 return
75 fi
76 if [ "$CONFIG" = $1 ]; then
77 return
78 fi
79
80 echo "** device must be in $1 config, but it's $CONFIG instead"
81 exit 1
82}
83
84
85echo "TESTING: $ARGS"
86
87while : true
88do
89 echo $(date)
90
91 for TYPE in $ARGS
92 do
93 # restore defaults
94 COUNT=5000
95 BUFLEN=2048
96
97 # FIXME automatically multiply COUNT by 10 when
98 # /sys/bus/usb/device/$THIS/speed == "480"
99
100# COUNT=50000
101
102 case $TYPE in
103 control)
104 # any device, in any configuration, can use this.
105 echo '** Control test cases:'
106
107 echo "test 9: ch9 postconfig"
108 do_test -t 9 -c 5000
109 echo "test 10: control queueing"
110 do_test -t 10 -c 5000
111
112 # this relies on some vendor-specific commands
113 echo "test 14: control writes"
114 do_test -t 14 -c 15000 -s 256 -v 1
115 ;;
116
117 out)
118 check_config sink-src
119 echo '** Host Write (OUT) test cases:'
120
121 echo "test 1: $COUNT transfers, same size"
122 do_test -t 1
123 echo "test 3: $COUNT transfers, variable/short size"
124 do_test -t 3 -v 421
125
126 COUNT=2000
127 echo "test 5: $COUNT scatterlists, same size entries"
128 do_test -t 5
129
130 # try to trigger short OUT processing bugs
131 echo "test 7a: $COUNT scatterlists, variable size/short entries"
132 do_test -t 7 -v 579
133 BUFLEN=4096
134 echo "test 7b: $COUNT scatterlists, variable size/bigger entries"
135 do_test -t 7 -v 41
136 BUFLEN=64
137 echo "test 7c: $COUNT scatterlists, variable size/micro entries"
138 do_test -t 7 -v 63
139 ;;
140
141 iso-out)
142 check_config sink-src
143 echo '** Host ISOCHRONOUS Write (OUT) test cases:'
144
145 # at peak iso transfer rates:
146 # - usb 2.0 high bandwidth, this is one frame.
147 # - usb 1.1, it's twenty-four frames.
148 BUFLEN=24500
149
150 COUNT=1000
151
152# COUNT=10000
153
154 echo "test 15: $COUNT transfers, same size"
155 # do_test -t 15 -g 3 -v 0
156 BUFLEN=32768
157 do_test -t 15 -g 8 -v 0
158
159 # FIXME it'd make sense to have an iso OUT test issuing
160 # short writes on more packets than the last one
161
162 ;;
163
164 in)
165 check_config sink-src
166 echo '** Host Read (IN) test cases:'
167
168 # NOTE: these "variable size" reads are just multiples
169 # of 512 bytes, no EOVERFLOW testing is done yet
170
171 echo "test 2: $COUNT transfers, same size"
172 do_test -t 2
173 echo "test 4: $COUNT transfers, variable size"
174 do_test -t 4
175
176 COUNT=2000
177 echo "test 6: $COUNT scatterlists, same size entries"
178 do_test -t 6
179 echo "test 8: $COUNT scatterlists, variable size entries"
180 do_test -t 8
181 ;;
182
183 iso-in)
184 check_config sink-src
185 echo '** Host ISOCHRONOUS Read (IN) test cases:'
186
187 # at peak iso transfer rates:
188 # - usb 2.0 high bandwidth, this is one frame.
189 # - usb 1.1, it's twenty-four frames.
190 BUFLEN=24500
191
192 COUNT=1000
193
194# COUNT=10000
195
196 echo "test 16: $COUNT transfers, same size"
197 # do_test -t 16 -g 3 -v 0
198 BUFLEN=32768
199 do_test -t 16 -g 8 -v 0
200
201 # FIXME since iso expects faults, it'd make sense
202 # to have an iso IN test issuing short reads ...
203
204 ;;
205
206 halt)
207 # NOTE: sometimes hardware doesn't cooperate well with halting
208 # endpoints from the host side. so long as mass-storage class
209 # firmware can halt them from the device, don't worry much if
210 # you can't make this test work on your device.
211 COUNT=2000
212 echo "test 13: $COUNT halt set/clear"
213 do_test -t 13
214 ;;
215
216 unlink)
217 COUNT=2000
218 echo "test 11: $COUNT read unlinks"
219 do_test -t 11
220
221 echo "test 12: $COUNT write unlinks"
222 do_test -t 12
223 ;;
224
225 loop)
226 # defaults need too much buffering for ez-usb devices
227 BUFLEN=2048
228 COUNT=32
229
230 # modprobe g_zero qlen=$COUNT buflen=$BUFLEN loopdefault
231 check_config loopback
232
233 # FIXME someone needs to write and merge a version of this
234
235 echo "write $COUNT buffers of $BUFLEN bytes, read them back"
236
237 echo "write $COUNT variable size buffers, read them back"
238
239 ;;
240
241 *)
242 echo "Don't understand test type $TYPE"
243 exit 1;
244 esac
245 echo ''
246 done
247done
248
249# vim: sw=4