Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 #
0004 # test types can be passed on the command line:
0005 #
0006 # - control: any device can do this
0007 # - out, in:  out needs 'bulk sink' firmware, in needs 'bulk src'
0008 # - iso-out, iso-in:  out needs 'iso sink' firmware, in needs 'iso src'
0009 # - halt: needs bulk sink+src, tests halt set/clear from host
0010 # - unlink: needs bulk sink and/or src, test HCD unlink processing
0011 # - loop: needs firmware that will buffer N transfers
0012 #
0013 # run it for hours, days, weeks.
0014 #
0015 
0016 #
0017 # this default provides a steady test load for a bulk device
0018 #
0019 TYPES='control out in'
0020 #TYPES='control out in halt'
0021 
0022 #
0023 # to test HCD code
0024 #
0025 #  - include unlink tests
0026 #  - add some ${RANDOM}ness
0027 #  - connect several devices concurrently (same HC)
0028 #  - keep HC's IRQ lines busy with unrelated traffic (IDE, net, ...)
0029 #  - add other concurrent system loads
0030 #
0031 
0032 declare -i COUNT BUFLEN
0033 
0034 COUNT=50000
0035 BUFLEN=2048
0036 
0037 # NOTE:  the 'in' and 'out' cases are usually bulk, but can be
0038 # set up to use interrupt transfers by 'usbtest' module options
0039 
0040 
0041 if [ "$DEVICE" = "" ]; then
0042         echo "testing ALL recognized usbtest devices"
0043         echo ""
0044         TEST_ARGS="-a"
0045 else
0046         TEST_ARGS=""
0047 fi
0048 
0049 do_test ()
0050 {
0051     if ! ./testusb $TEST_ARGS -s $BUFLEN -c $COUNT $* 2>/dev/null
0052     then
0053         echo "FAIL"
0054         exit 1
0055     fi
0056 }
0057 
0058 ARGS="$*"
0059 
0060 if [ "$ARGS" = "" ];
0061 then
0062     ARGS="$TYPES"
0063 fi
0064 
0065 # FIXME use /sys/bus/usb/device/$THIS/bConfigurationValue to
0066 # check and change configs
0067 
0068 CONFIG=''
0069 
0070 check_config ()
0071 {
0072     if [ "$CONFIG" = "" ]; then
0073         CONFIG=$1
0074         echo "assuming $CONFIG configuration"
0075         return
0076     fi
0077     if [ "$CONFIG" = $1 ]; then
0078         return
0079     fi
0080 
0081     echo "** device must be in $1 config, but it's $CONFIG instead"
0082     exit 1
0083 }
0084 
0085 
0086 echo "TESTING:  $ARGS"
0087 
0088 while : true
0089 do
0090     echo $(date)
0091 
0092     for TYPE in $ARGS
0093     do
0094         # restore defaults
0095         COUNT=5000
0096         BUFLEN=2048
0097 
0098         # FIXME automatically multiply COUNT by 10 when
0099         # /sys/bus/usb/device/$THIS/speed == "480"
0100 
0101 #       COUNT=50000
0102 
0103         case $TYPE in
0104         control)
0105             # any device, in any configuration, can use this.
0106             echo '** Control test cases:'
0107 
0108             echo "test 9: ch9 postconfig"
0109             do_test -t 9 -c 5000
0110             echo "test 10: control queueing"
0111             do_test -t 10 -c 5000
0112 
0113             # this relies on some vendor-specific commands
0114             echo "test 14: control writes"
0115             do_test -t 14 -c 15000 -s 256 -v 1
0116 
0117             echo "test 21: control writes, unaligned"
0118             do_test -t 21 -c 100 -s 256 -v 1
0119 
0120             ;;
0121 
0122         out)
0123             check_config sink-src
0124             echo '** Host Write (OUT) test cases:'
0125 
0126             echo "test 1: $COUNT transfers, same size"
0127             do_test -t 1
0128             echo "test 3: $COUNT transfers, variable/short size"
0129             do_test -t 3 -v 421
0130 
0131             COUNT=100
0132             echo "test 17: $COUNT transfers, unaligned DMA map by core"
0133             do_test -t 17
0134 
0135             echo "test 19: $COUNT transfers, unaligned DMA map by usb_alloc_coherent"
0136             do_test -t 19
0137 
0138             COUNT=2000
0139             echo "test 5: $COUNT scatterlists, same size entries"
0140             do_test -t 5
0141 
0142             # try to trigger short OUT processing bugs
0143             echo "test 7a: $COUNT scatterlists, variable size/short entries"
0144             do_test -t 7 -v 579
0145             BUFLEN=4096
0146             echo "test 7b: $COUNT scatterlists, variable size/bigger entries"
0147             do_test -t 7 -v 41
0148             BUFLEN=64
0149             echo "test 7c: $COUNT scatterlists, variable size/micro entries"
0150             do_test -t 7 -v 63
0151             ;;
0152 
0153         iso-out)
0154             check_config sink-src
0155             echo '** Host ISOCHRONOUS Write (OUT) test cases:'
0156 
0157             # at peak iso transfer rates:
0158             # - usb 2.0 high bandwidth, this is one frame.
0159             # - usb 1.1, it's twenty-four frames.
0160             BUFLEN=24500
0161 
0162             COUNT=1000
0163 
0164 # COUNT=10000
0165 
0166             echo "test 15: $COUNT transfers, same size"
0167             # do_test -t 15 -g 3 -v 0
0168             BUFLEN=32768
0169             do_test -t 15 -g 8 -v 0
0170 
0171             # FIXME it'd make sense to have an iso OUT test issuing
0172             # short writes on more packets than the last one
0173 
0174             COUNT=100
0175             echo "test 22: $COUNT transfers, non aligned"
0176             do_test -t 22 -g 8 -v 0
0177 
0178             ;;
0179 
0180         in)
0181             check_config sink-src
0182             echo '** Host Read (IN) test cases:'
0183 
0184             # NOTE:  these "variable size" reads are just multiples
0185             # of 512 bytes, no EOVERFLOW testing is done yet
0186 
0187             echo "test 2: $COUNT transfers, same size"
0188             do_test -t 2
0189             echo "test 4: $COUNT transfers, variable size"
0190             do_test -t 4
0191 
0192             COUNT=100
0193             echo "test 18: $COUNT transfers, unaligned DMA map by core"
0194             do_test -t 18
0195 
0196             echo "test 20: $COUNT transfers, unaligned DMA map by usb_alloc_coherent"
0197             do_test -t 20
0198 
0199             COUNT=2000
0200             echo "test 6: $COUNT scatterlists, same size entries"
0201             do_test -t 6
0202             echo "test 8: $COUNT scatterlists, variable size entries"
0203             do_test -t 8
0204             ;;
0205 
0206         iso-in)
0207             check_config sink-src
0208             echo '** Host ISOCHRONOUS Read (IN) test cases:'
0209 
0210             # at peak iso transfer rates:
0211             # - usb 2.0 high bandwidth, this is one frame.
0212             # - usb 1.1, it's twenty-four frames.
0213             BUFLEN=24500
0214 
0215             COUNT=1000
0216 
0217 # COUNT=10000
0218 
0219             echo "test 16: $COUNT transfers, same size"
0220             # do_test -t 16 -g 3 -v 0
0221             BUFLEN=32768
0222             do_test -t 16 -g 8 -v 0
0223 
0224             # FIXME since iso expects faults, it'd make sense
0225             # to have an iso IN test issuing short reads ...
0226 
0227             COUNT=100
0228             echo "test 23: $COUNT transfers, unaligned"
0229             do_test -t 23 -g 8 -v 0
0230 
0231             ;;
0232 
0233         halt)
0234             # NOTE:  sometimes hardware doesn't cooperate well with halting
0235             # endpoints from the host side.  so long as mass-storage class
0236             # firmware can halt them from the device, don't worry much if
0237             # you can't make this test work on your device.
0238             COUNT=2000
0239             echo "test 13: $COUNT halt set/clear"
0240             do_test -t 13
0241             ;;
0242 
0243         unlink)
0244             COUNT=2000
0245             echo "test 11: $COUNT read unlinks"
0246             do_test -t 11
0247 
0248             echo "test 12: $COUNT write unlinks"
0249             do_test -t 12
0250             ;;
0251 
0252         loop)
0253             # defaults need too much buffering for ez-usb devices
0254             BUFLEN=2048
0255             COUNT=32
0256 
0257             # modprobe g_zero qlen=$COUNT buflen=$BUFLEN loopdefault
0258             check_config loopback
0259 
0260             # FIXME someone needs to write and merge a version of this
0261 
0262             echo "write $COUNT buffers of $BUFLEN bytes, read them back"
0263 
0264             echo "write $COUNT variable size buffers, read them back"
0265 
0266             ;;
0267 
0268         *)
0269             echo "Don't understand test type $TYPE"
0270             exit 1;
0271         esac
0272         echo ''
0273     done
0274 done