#!/bin/sh1#2# test types can be passed on the command line:3#4# - control: any device can do this5# - out, in: out needs 'bulk sink' firmware, in needs 'bulk src'6# - iso-out, iso-in: out needs 'iso sink' firmware, in needs 'iso src'7# - halt: needs bulk sink+src, tests halt set/clear from host8# - unlink: needs bulk sink and/or src, test HCD unlink processing9# - loop: needs firmware that will buffer N transfers10#11# run it for hours, days, weeks.12#1314#15# this default provides a steady test load for a bulk device16#17TYPES='control out in'18#TYPES='control out in halt'1920#21# to test HCD code22#23# - include unlink tests24# - add some ${RANDOM}ness25# - connect several devices concurrently (same HC)26# - keep HC's IRQ lines busy with unrelated traffic (IDE, net, ...)27# - add other concurrent system loads28#2930declare -i COUNT BUFLEN3132COUNT=5000033BUFLEN=20483435# NOTE: the 'in' and 'out' cases are usually bulk, but can be36# set up to use interrupt transfers by 'usbtest' module options373839if [ "$DEVICE" = "" ]; then40echo "testing ALL recognized usbtest devices"41echo ""42TEST_ARGS="-a"43else44TEST_ARGS=""45fi4647do_test ()48{49if ! ./testusb $TEST_ARGS -s $BUFLEN -c $COUNT $* 2>/dev/null50then51echo "FAIL"52exit 153fi54}5556ARGS="$*"5758if [ "$ARGS" = "" ];59then60ARGS="$TYPES"61fi6263# FIXME use /sys/bus/usb/device/$THIS/bConfigurationValue to64# check and change configs6566CONFIG=''6768check_config ()69{70if [ "$CONFIG" = "" ]; then71CONFIG=$172echo "assuming $CONFIG configuration"73return74fi75if [ "$CONFIG" = $1 ]; then76return77fi7879echo "** device must be in $1 config, but it's $CONFIG instead"80exit 181}828384echo "TESTING: $ARGS"8586while : true87do88echo $(date)8990for TYPE in $ARGS91do92# restore defaults93COUNT=500094BUFLEN=20489596# FIXME automatically multiply COUNT by 10 when97# /sys/bus/usb/device/$THIS/speed == "480"9899# COUNT=50000100101case $TYPE in102control)103# any device, in any configuration, can use this.104echo '** Control test cases:'105106echo "test 9: ch9 postconfig"107do_test -t 9 -c 5000108echo "test 10: control queueing"109do_test -t 10 -c 5000110111# this relies on some vendor-specific commands112echo "test 14: control writes"113do_test -t 14 -c 15000 -s 256 -v 1114115echo "test 21: control writes, unaligned"116do_test -t 21 -c 100 -s 256 -v 1117118;;119120out)121check_config sink-src122echo '** Host Write (OUT) test cases:'123124echo "test 1: $COUNT transfers, same size"125do_test -t 1126echo "test 3: $COUNT transfers, variable/short size"127do_test -t 3 -v 421128129COUNT=100130echo "test 17: $COUNT transfers, unaligned DMA map by core"131do_test -t 17132133echo "test 19: $COUNT transfers, unaligned DMA map by usb_alloc_coherent"134do_test -t 19135136COUNT=2000137echo "test 5: $COUNT scatterlists, same size entries"138do_test -t 5139140# try to trigger short OUT processing bugs141echo "test 7a: $COUNT scatterlists, variable size/short entries"142do_test -t 7 -v 579143BUFLEN=4096144echo "test 7b: $COUNT scatterlists, variable size/bigger entries"145do_test -t 7 -v 41146BUFLEN=64147echo "test 7c: $COUNT scatterlists, variable size/micro entries"148do_test -t 7 -v 63149;;150151iso-out)152check_config sink-src153echo '** Host ISOCHRONOUS Write (OUT) test cases:'154155# at peak iso transfer rates:156# - usb 2.0 high bandwidth, this is one frame.157# - usb 1.1, it's twenty-four frames.158BUFLEN=24500159160COUNT=1000161162# COUNT=10000163164echo "test 15: $COUNT transfers, same size"165# do_test -t 15 -g 3 -v 0166BUFLEN=32768167do_test -t 15 -g 8 -v 0168169# FIXME it'd make sense to have an iso OUT test issuing170# short writes on more packets than the last one171172COUNT=100173echo "test 22: $COUNT transfers, non aligned"174do_test -t 22 -g 8 -v 0175176;;177178in)179check_config sink-src180echo '** Host Read (IN) test cases:'181182# NOTE: these "variable size" reads are just multiples183# of 512 bytes, no EOVERFLOW testing is done yet184185echo "test 2: $COUNT transfers, same size"186do_test -t 2187echo "test 4: $COUNT transfers, variable size"188do_test -t 4189190COUNT=100191echo "test 18: $COUNT transfers, unaligned DMA map by core"192do_test -t 18193194echo "test 20: $COUNT transfers, unaligned DMA map by usb_alloc_coherent"195do_test -t 20196197COUNT=2000198echo "test 6: $COUNT scatterlists, same size entries"199do_test -t 6200echo "test 8: $COUNT scatterlists, variable size entries"201do_test -t 8202;;203204iso-in)205check_config sink-src206echo '** Host ISOCHRONOUS Read (IN) test cases:'207208# at peak iso transfer rates:209# - usb 2.0 high bandwidth, this is one frame.210# - usb 1.1, it's twenty-four frames.211BUFLEN=24500212213COUNT=1000214215# COUNT=10000216217echo "test 16: $COUNT transfers, same size"218# do_test -t 16 -g 3 -v 0219BUFLEN=32768220do_test -t 16 -g 8 -v 0221222# FIXME since iso expects faults, it'd make sense223# to have an iso IN test issuing short reads ...224225COUNT=100226echo "test 23: $COUNT transfers, unaligned"227do_test -t 23 -g 8 -v 0228229;;230231halt)232# NOTE: sometimes hardware doesn't cooperate well with halting233# endpoints from the host side. so long as mass-storage class234# firmware can halt them from the device, don't worry much if235# you can't make this test work on your device.236COUNT=2000237echo "test 13: $COUNT halt set/clear"238do_test -t 13239;;240241unlink)242COUNT=2000243echo "test 11: $COUNT read unlinks"244do_test -t 11245246echo "test 12: $COUNT write unlinks"247do_test -t 12248;;249250loop)251# defaults need too much buffering for ez-usb devices252BUFLEN=2048253COUNT=32254255# modprobe g_zero qlen=$COUNT buflen=$BUFLEN loopdefault256check_config loopback257258# FIXME someone needs to write and merge a version of this259260echo "write $COUNT buffers of $BUFLEN bytes, read them back"261262echo "write $COUNT variable size buffers, read them back"263264;;265266*)267echo "Don't understand test type $TYPE"268exit 1;269esac270echo ''271done272done273274# vim: sw=4275276277