brintos

brintos / linux-shallow public Read only

0
0
Text · 6.1 KiB · 73f914d Raw
275 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: GPL-2.03#4# test types can be passed on the command line:5#6# - control: any device can do this7# - 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 host10# - unlink: needs bulk sink and/or src, test HCD unlink processing11# - loop: needs firmware that will buffer N transfers12#13# run it for hours, days, weeks.14#15 16#17# this default provides a steady test load for a bulk device18#19TYPES='control out in'20#TYPES='control out in halt'21 22#23# to test HCD code24#25#  - include unlink tests26#  - add some ${RANDOM}ness27#  - connect several devices concurrently (same HC)28#  - keep HC's IRQ lines busy with unrelated traffic (IDE, net, ...)29#  - add other concurrent system loads30#31 32declare -i COUNT BUFLEN33 34COUNT=5000035BUFLEN=204836 37# NOTE:  the 'in' and 'out' cases are usually bulk, but can be38# set up to use interrupt transfers by 'usbtest' module options39 40 41if [ "$DEVICE" = "" ]; then42	echo "testing ALL recognized usbtest devices"43	echo ""44	TEST_ARGS="-a"45else46	TEST_ARGS=""47fi48 49do_test ()50{51    if ! ./testusb $TEST_ARGS -s $BUFLEN -c $COUNT $* 2>/dev/null52    then53	echo "FAIL"54	exit 155    fi56}57 58ARGS="$*"59 60if [ "$ARGS" = "" ];61then62    ARGS="$TYPES"63fi64 65# FIXME use /sys/bus/usb/device/$THIS/bConfigurationValue to66# check and change configs67 68CONFIG=''69 70check_config ()71{72    if [ "$CONFIG" = "" ]; then73	CONFIG=$174	echo "assuming $CONFIG configuration"75	return76    fi77    if [ "$CONFIG" = $1 ]; then78	return79    fi80 81    echo "** device must be in $1 config, but it's $CONFIG instead"82    exit 183}84 85 86echo "TESTING:  $ARGS"87 88while : true89do90    echo $(date)91 92    for TYPE in $ARGS93    do94	# restore defaults95	COUNT=500096	BUFLEN=204897 98	# FIXME automatically multiply COUNT by 10 when99	# /sys/bus/usb/device/$THIS/speed == "480"100 101#	COUNT=50000102 103	case $TYPE in104	control)105	    # any device, in any configuration, can use this.106	    echo '** Control test cases:'107 108	    echo "test 9: ch9 postconfig"109	    do_test -t 9 -c 5000110	    echo "test 10: control queueing"111	    do_test -t 10 -c 5000112 113	    # this relies on some vendor-specific commands114	    echo "test 14: control writes"115	    do_test -t 14 -c 15000 -s 256 -v 1116 117	    echo "test 21: control writes, unaligned"118	    do_test -t 21 -c 100 -s 256 -v 1119 120	    ;;121 122	out)123	    check_config sink-src124	    echo '** Host Write (OUT) test cases:'125 126	    echo "test 1: $COUNT transfers, same size"127	    do_test -t 1128	    echo "test 3: $COUNT transfers, variable/short size"129	    do_test -t 3 -v 421130 131	    COUNT=100132	    echo "test 17: $COUNT transfers, unaligned DMA map by core"133	    do_test -t 17134 135	    echo "test 19: $COUNT transfers, unaligned DMA map by usb_alloc_coherent"136	    do_test -t 19137 138	    COUNT=2000139	    echo "test 5: $COUNT scatterlists, same size entries"140	    do_test -t 5141 142	    # try to trigger short OUT processing bugs143	    echo "test 7a: $COUNT scatterlists, variable size/short entries"144	    do_test -t 7 -v 579145	    BUFLEN=4096146	    echo "test 7b: $COUNT scatterlists, variable size/bigger entries"147	    do_test -t 7 -v 41148	    BUFLEN=64149	    echo "test 7c: $COUNT scatterlists, variable size/micro entries"150	    do_test -t 7 -v 63151	    ;;152 153	iso-out)154	    check_config sink-src155	    echo '** Host ISOCHRONOUS Write (OUT) test cases:'156 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.160	    BUFLEN=24500161 162	    COUNT=1000163 164# COUNT=10000165 166	    echo "test 15: $COUNT transfers, same size"167	    # do_test -t 15 -g 3 -v 0168	    BUFLEN=32768169	    do_test -t 15 -g 8 -v 0170 171	    # FIXME it'd make sense to have an iso OUT test issuing172	    # short writes on more packets than the last one173 174	    COUNT=100175	    echo "test 22: $COUNT transfers, non aligned"176	    do_test -t 22 -g 8 -v 0177 178	    ;;179 180	in)181	    check_config sink-src182	    echo '** Host Read (IN) test cases:'183 184	    # NOTE:  these "variable size" reads are just multiples185	    # of 512 bytes, no EOVERFLOW testing is done yet186 187	    echo "test 2: $COUNT transfers, same size"188	    do_test -t 2189	    echo "test 4: $COUNT transfers, variable size"190	    do_test -t 4191 192	    COUNT=100193	    echo "test 18: $COUNT transfers, unaligned DMA map by core"194	    do_test -t 18195 196	    echo "test 20: $COUNT transfers, unaligned DMA map by usb_alloc_coherent"197	    do_test -t 20198 199	    COUNT=2000200	    echo "test 6: $COUNT scatterlists, same size entries"201	    do_test -t 6202	    echo "test 8: $COUNT scatterlists, variable size entries"203	    do_test -t 8204	    ;;205 206	iso-in)207	    check_config sink-src208	    echo '** Host ISOCHRONOUS Read (IN) test cases:'209 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.213	    BUFLEN=24500214 215	    COUNT=1000216 217# COUNT=10000218 219	    echo "test 16: $COUNT transfers, same size"220	    # do_test -t 16 -g 3 -v 0221	    BUFLEN=32768222	    do_test -t 16 -g 8 -v 0223 224	    # FIXME since iso expects faults, it'd make sense225	    # to have an iso IN test issuing short reads ...226 227	    COUNT=100228	    echo "test 23: $COUNT transfers, unaligned"229	    do_test -t 23 -g 8 -v 0230 231	    ;;232 233	halt)234	    # NOTE:  sometimes hardware doesn't cooperate well with halting235	    # endpoints from the host side.  so long as mass-storage class236	    # firmware can halt them from the device, don't worry much if237	    # you can't make this test work on your device.238	    COUNT=2000239	    echo "test 13: $COUNT halt set/clear"240	    do_test -t 13241	    ;;242 243	unlink)244	    COUNT=2000245	    echo "test 11: $COUNT read unlinks"246	    do_test -t 11247 248	    echo "test 12: $COUNT write unlinks"249	    do_test -t 12250	    ;;251 252	loop)253	    # defaults need too much buffering for ez-usb devices254	    BUFLEN=2048255	    COUNT=32256 257	    # modprobe g_zero qlen=$COUNT buflen=$BUFLEN loopdefault258	    check_config loopback259 260	    # FIXME someone needs to write and merge a version of this261 262	    echo "write $COUNT buffers of $BUFLEN bytes, read them back"263 264	    echo "write $COUNT variable size buffers, read them back"265 266	    ;;267 268	*)269	    echo "Don't understand test type $TYPE"270	    exit 1;271	esac272	echo ''273    done274done275