1 #!/bin/sh 1 #!/bin/sh 2 # SPDX-License-Identifier: GPL-2.0 2 # SPDX-License-Identifier: GPL-2.0 3 # 3 # 4 # test types can be passed on the command line 4 # test types can be passed on the command line: 5 # 5 # 6 # - control: any device can do this 6 # - control: any device can do this 7 # - out, in: out needs 'bulk sink' firmware, 7 # - out, in: out needs 'bulk sink' firmware, in needs 'bulk src' 8 # - iso-out, iso-in: out needs 'iso sink' fir 8 # - iso-out, iso-in: out needs 'iso sink' firmware, in needs 'iso src' 9 # - halt: needs bulk sink+src, tests halt set/ 9 # - halt: needs bulk sink+src, tests halt set/clear from host 10 # - unlink: needs bulk sink and/or src, test H 10 # - unlink: needs bulk sink and/or src, test HCD unlink processing 11 # - loop: needs firmware that will buffer N tr 11 # - loop: needs firmware that will buffer N transfers 12 # 12 # 13 # run it for hours, days, weeks. 13 # run it for hours, days, weeks. 14 # 14 # 15 15 16 # 16 # 17 # this default provides a steady test load for 17 # this default provides a steady test load for a bulk device 18 # 18 # 19 TYPES='control out in' 19 TYPES='control out in' 20 #TYPES='control out in halt' 20 #TYPES='control out in halt' 21 21 22 # 22 # 23 # to test HCD code 23 # to test HCD code 24 # 24 # 25 # - include unlink tests 25 # - include unlink tests 26 # - add some ${RANDOM}ness 26 # - add some ${RANDOM}ness 27 # - connect several devices concurrently (sam 27 # - connect several devices concurrently (same HC) 28 # - keep HC's IRQ lines busy with unrelated t 28 # - keep HC's IRQ lines busy with unrelated traffic (IDE, net, ...) 29 # - add other concurrent system loads 29 # - add other concurrent system loads 30 # 30 # 31 31 32 declare -i COUNT BUFLEN 32 declare -i COUNT BUFLEN 33 33 34 COUNT=50000 34 COUNT=50000 35 BUFLEN=2048 35 BUFLEN=2048 36 36 37 # NOTE: the 'in' and 'out' cases are usually 37 # NOTE: the 'in' and 'out' cases are usually bulk, but can be 38 # set up to use interrupt transfers by 'usbtes 38 # set up to use interrupt transfers by 'usbtest' module options 39 39 40 40 41 if [ "$DEVICE" = "" ]; then 41 if [ "$DEVICE" = "" ]; then 42 echo "testing ALL recognized usbtest d 42 echo "testing ALL recognized usbtest devices" 43 echo "" 43 echo "" 44 TEST_ARGS="-a" 44 TEST_ARGS="-a" 45 else 45 else 46 TEST_ARGS="" 46 TEST_ARGS="" 47 fi 47 fi 48 48 49 do_test () 49 do_test () 50 { 50 { 51 if ! ./testusb $TEST_ARGS -s $BUFLEN -c $C 51 if ! ./testusb $TEST_ARGS -s $BUFLEN -c $COUNT $* 2>/dev/null 52 then 52 then 53 echo "FAIL" 53 echo "FAIL" 54 exit 1 54 exit 1 55 fi 55 fi 56 } 56 } 57 57 58 ARGS="$*" 58 ARGS="$*" 59 59 60 if [ "$ARGS" = "" ]; 60 if [ "$ARGS" = "" ]; 61 then 61 then 62 ARGS="$TYPES" 62 ARGS="$TYPES" 63 fi 63 fi 64 64 65 # FIXME use /sys/bus/usb/device/$THIS/bConfigu 65 # FIXME use /sys/bus/usb/device/$THIS/bConfigurationValue to 66 # check and change configs 66 # check and change configs 67 67 68 CONFIG='' 68 CONFIG='' 69 69 70 check_config () 70 check_config () 71 { 71 { 72 if [ "$CONFIG" = "" ]; then 72 if [ "$CONFIG" = "" ]; then 73 CONFIG=$1 73 CONFIG=$1 74 echo "assuming $CONFIG configuration" 74 echo "assuming $CONFIG configuration" 75 return 75 return 76 fi 76 fi 77 if [ "$CONFIG" = $1 ]; then 77 if [ "$CONFIG" = $1 ]; then 78 return 78 return 79 fi 79 fi 80 80 81 echo "** device must be in $1 config, but 81 echo "** device must be in $1 config, but it's $CONFIG instead" 82 exit 1 82 exit 1 83 } 83 } 84 84 85 85 86 echo "TESTING: $ARGS" 86 echo "TESTING: $ARGS" 87 87 88 while : true 88 while : true 89 do 89 do 90 echo $(date) 90 echo $(date) 91 91 92 for TYPE in $ARGS 92 for TYPE in $ARGS 93 do 93 do 94 # restore defaults 94 # restore defaults 95 COUNT=5000 95 COUNT=5000 96 BUFLEN=2048 96 BUFLEN=2048 97 97 98 # FIXME automatically multiply COUNT b 98 # FIXME automatically multiply COUNT by 10 when 99 # /sys/bus/usb/device/$THIS/speed == " 99 # /sys/bus/usb/device/$THIS/speed == "480" 100 100 101 # COUNT=50000 101 # COUNT=50000 102 102 103 case $TYPE in 103 case $TYPE in 104 control) 104 control) 105 # any device, in any configuration 105 # any device, in any configuration, can use this. 106 echo '** Control test cases:' 106 echo '** Control test cases:' 107 107 108 echo "test 9: ch9 postconfig" 108 echo "test 9: ch9 postconfig" 109 do_test -t 9 -c 5000 109 do_test -t 9 -c 5000 110 echo "test 10: control queueing" 110 echo "test 10: control queueing" 111 do_test -t 10 -c 5000 111 do_test -t 10 -c 5000 112 112 113 # this relies on some vendor-speci 113 # this relies on some vendor-specific commands 114 echo "test 14: control writes" 114 echo "test 14: control writes" 115 do_test -t 14 -c 15000 -s 256 -v 1 115 do_test -t 14 -c 15000 -s 256 -v 1 116 116 117 echo "test 21: control writes, una 117 echo "test 21: control writes, unaligned" 118 do_test -t 21 -c 100 -s 256 -v 1 118 do_test -t 21 -c 100 -s 256 -v 1 119 119 120 ;; 120 ;; 121 121 122 out) 122 out) 123 check_config sink-src 123 check_config sink-src 124 echo '** Host Write (OUT) test cas 124 echo '** Host Write (OUT) test cases:' 125 125 126 echo "test 1: $COUNT transfers, sa 126 echo "test 1: $COUNT transfers, same size" 127 do_test -t 1 127 do_test -t 1 128 echo "test 3: $COUNT transfers, va 128 echo "test 3: $COUNT transfers, variable/short size" 129 do_test -t 3 -v 421 129 do_test -t 3 -v 421 130 130 131 COUNT=100 131 COUNT=100 132 echo "test 17: $COUNT transfers, u 132 echo "test 17: $COUNT transfers, unaligned DMA map by core" 133 do_test -t 17 133 do_test -t 17 134 134 135 echo "test 19: $COUNT transfers, u 135 echo "test 19: $COUNT transfers, unaligned DMA map by usb_alloc_coherent" 136 do_test -t 19 136 do_test -t 19 137 137 138 COUNT=2000 138 COUNT=2000 139 echo "test 5: $COUNT scatterlists, 139 echo "test 5: $COUNT scatterlists, same size entries" 140 do_test -t 5 140 do_test -t 5 141 141 142 # try to trigger short OUT process 142 # try to trigger short OUT processing bugs 143 echo "test 7a: $COUNT scatterlists 143 echo "test 7a: $COUNT scatterlists, variable size/short entries" 144 do_test -t 7 -v 579 144 do_test -t 7 -v 579 145 BUFLEN=4096 145 BUFLEN=4096 146 echo "test 7b: $COUNT scatterlists 146 echo "test 7b: $COUNT scatterlists, variable size/bigger entries" 147 do_test -t 7 -v 41 147 do_test -t 7 -v 41 148 BUFLEN=64 148 BUFLEN=64 149 echo "test 7c: $COUNT scatterlists 149 echo "test 7c: $COUNT scatterlists, variable size/micro entries" 150 do_test -t 7 -v 63 150 do_test -t 7 -v 63 151 ;; 151 ;; 152 152 153 iso-out) 153 iso-out) 154 check_config sink-src 154 check_config sink-src 155 echo '** Host ISOCHRONOUS Write (O 155 echo '** Host ISOCHRONOUS Write (OUT) test cases:' 156 156 157 # at peak iso transfer rates: 157 # at peak iso transfer rates: 158 # - usb 2.0 high bandwidth, this i 158 # - usb 2.0 high bandwidth, this is one frame. 159 # - usb 1.1, it's twenty-four fram 159 # - usb 1.1, it's twenty-four frames. 160 BUFLEN=24500 160 BUFLEN=24500 161 161 162 COUNT=1000 162 COUNT=1000 163 163 164 # COUNT=10000 164 # COUNT=10000 165 165 166 echo "test 15: $COUNT transfers, s 166 echo "test 15: $COUNT transfers, same size" 167 # do_test -t 15 -g 3 -v 0 167 # do_test -t 15 -g 3 -v 0 168 BUFLEN=32768 168 BUFLEN=32768 169 do_test -t 15 -g 8 -v 0 169 do_test -t 15 -g 8 -v 0 170 170 171 # FIXME it'd make sense to have an 171 # FIXME it'd make sense to have an iso OUT test issuing 172 # short writes on more packets tha 172 # short writes on more packets than the last one 173 173 174 COUNT=100 174 COUNT=100 175 echo "test 22: $COUNT transfers, n 175 echo "test 22: $COUNT transfers, non aligned" 176 do_test -t 22 -g 8 -v 0 176 do_test -t 22 -g 8 -v 0 177 177 178 ;; 178 ;; 179 179 180 in) 180 in) 181 check_config sink-src 181 check_config sink-src 182 echo '** Host Read (IN) test cases 182 echo '** Host Read (IN) test cases:' 183 183 184 # NOTE: these "variable size" rea 184 # NOTE: these "variable size" reads are just multiples 185 # of 512 bytes, no EOVERFLOW testi 185 # of 512 bytes, no EOVERFLOW testing is done yet 186 186 187 echo "test 2: $COUNT transfers, sa 187 echo "test 2: $COUNT transfers, same size" 188 do_test -t 2 188 do_test -t 2 189 echo "test 4: $COUNT transfers, va 189 echo "test 4: $COUNT transfers, variable size" 190 do_test -t 4 190 do_test -t 4 191 191 192 COUNT=100 192 COUNT=100 193 echo "test 18: $COUNT transfers, u 193 echo "test 18: $COUNT transfers, unaligned DMA map by core" 194 do_test -t 18 194 do_test -t 18 195 195 196 echo "test 20: $COUNT transfers, u 196 echo "test 20: $COUNT transfers, unaligned DMA map by usb_alloc_coherent" 197 do_test -t 20 197 do_test -t 20 198 198 199 COUNT=2000 199 COUNT=2000 200 echo "test 6: $COUNT scatterlists, 200 echo "test 6: $COUNT scatterlists, same size entries" 201 do_test -t 6 201 do_test -t 6 202 echo "test 8: $COUNT scatterlists, 202 echo "test 8: $COUNT scatterlists, variable size entries" 203 do_test -t 8 203 do_test -t 8 204 ;; 204 ;; 205 205 206 iso-in) 206 iso-in) 207 check_config sink-src 207 check_config sink-src 208 echo '** Host ISOCHRONOUS Read (IN 208 echo '** Host ISOCHRONOUS Read (IN) test cases:' 209 209 210 # at peak iso transfer rates: 210 # at peak iso transfer rates: 211 # - usb 2.0 high bandwidth, this i 211 # - usb 2.0 high bandwidth, this is one frame. 212 # - usb 1.1, it's twenty-four fram 212 # - usb 1.1, it's twenty-four frames. 213 BUFLEN=24500 213 BUFLEN=24500 214 214 215 COUNT=1000 215 COUNT=1000 216 216 217 # COUNT=10000 217 # COUNT=10000 218 218 219 echo "test 16: $COUNT transfers, s 219 echo "test 16: $COUNT transfers, same size" 220 # do_test -t 16 -g 3 -v 0 220 # do_test -t 16 -g 3 -v 0 221 BUFLEN=32768 221 BUFLEN=32768 222 do_test -t 16 -g 8 -v 0 222 do_test -t 16 -g 8 -v 0 223 223 224 # FIXME since iso expects faults, 224 # FIXME since iso expects faults, it'd make sense 225 # to have an iso IN test issuing s 225 # to have an iso IN test issuing short reads ... 226 226 227 COUNT=100 227 COUNT=100 228 echo "test 23: $COUNT transfers, u 228 echo "test 23: $COUNT transfers, unaligned" 229 do_test -t 23 -g 8 -v 0 229 do_test -t 23 -g 8 -v 0 230 230 231 ;; 231 ;; 232 232 233 halt) 233 halt) 234 # NOTE: sometimes hardware doesn' 234 # NOTE: sometimes hardware doesn't cooperate well with halting 235 # endpoints from the host side. s 235 # endpoints from the host side. so long as mass-storage class 236 # firmware can halt them from the 236 # firmware can halt them from the device, don't worry much if 237 # you can't make this test work on 237 # you can't make this test work on your device. 238 COUNT=2000 238 COUNT=2000 239 echo "test 13: $COUNT halt set/cle 239 echo "test 13: $COUNT halt set/clear" 240 do_test -t 13 240 do_test -t 13 241 ;; 241 ;; 242 242 243 unlink) 243 unlink) 244 COUNT=2000 244 COUNT=2000 245 echo "test 11: $COUNT read unlinks 245 echo "test 11: $COUNT read unlinks" 246 do_test -t 11 246 do_test -t 11 247 247 248 echo "test 12: $COUNT write unlink 248 echo "test 12: $COUNT write unlinks" 249 do_test -t 12 249 do_test -t 12 250 ;; 250 ;; 251 251 252 loop) 252 loop) 253 # defaults need too much buffering 253 # defaults need too much buffering for ez-usb devices 254 BUFLEN=2048 254 BUFLEN=2048 255 COUNT=32 255 COUNT=32 256 256 257 # modprobe g_zero qlen=$COUNT bufl 257 # modprobe g_zero qlen=$COUNT buflen=$BUFLEN loopdefault 258 check_config loopback 258 check_config loopback 259 259 260 # FIXME someone needs to write and 260 # FIXME someone needs to write and merge a version of this 261 261 262 echo "write $COUNT buffers of $BUF 262 echo "write $COUNT buffers of $BUFLEN bytes, read them back" 263 263 264 echo "write $COUNT variable size b 264 echo "write $COUNT variable size buffers, read them back" 265 265 266 ;; 266 ;; 267 267 268 *) 268 *) 269 echo "Don't understand test type $ 269 echo "Don't understand test type $TYPE" 270 exit 1; 270 exit 1; 271 esac 271 esac 272 echo '' 272 echo '' 273 done 273 done 274 done 274 done
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.