#!/bin/sh # # test types can be passed on the command line: # # - control: any device can do this # - out, in: out needs 'bulk sink' firmware, in needs 'bulk src' # - iso-out, iso-in: out needs 'iso sink' firmware, in needs 'iso src' # - halt: needs bulk sink+src, tests halt set/clear from host # - unlink: needs bulk sink and/or src, test HCD unlink processing # - loop: needs firmware that will buffer N transfers # # run it for hours, days, weeks. # # # this default provides a steady test load for a bulk device # global TYPES := ''control out in'TODO ' #TYPES='control out in halt' # # to test HCD code # # - include unlink tests # - add some ${RANDOM}ness # - connect several devices concurrently (same HC) # - keep HC's IRQ lines busy with unrelated traffic (IDE, net, ...) # - add other concurrent system loads # declare -i COUNT = '', BUFLEN = '' global COUNT := '50000' global BUFLEN := '2048' # NOTE: the 'in' and 'out' cases are usually bulk, but can be # set up to use interrupt transfers by 'usbtest' module options if test $DEVICE = "" { echo "testing ALL recognized usbtest devices" echo "" global TEST_ARGS := '"-a'" } else { global TEST_ARGS := ''"" } proc do_test { if ! ./testusb $TEST_ARGS -s $BUFLEN -c $COUNT $ifsjoin(Argv) !2 >/dev/null { echo "FAIL" exit 1 } } global ARGS := "$ifsjoin(Argv)" if test $ARGS = "" { global ARGS := $TYPES } # FIXME use /sys/bus/usb/device/$THIS/bConfigurationValue to # check and change configs global CONFIG := '''' proc check_config { if test $CONFIG = "" { global CONFIG := $1 echo "assuming $CONFIG configuration" return } if test $CONFIG = $1 { return } echo "** device must be in $1 config, but it's $CONFIG instead" exit 1 } echo "TESTING: $ARGS" while : true { echo $[date] for TYPE in [$ARGS] { # restore defaults global COUNT := '5000' global BUFLEN := '2048' # FIXME automatically multiply COUNT by 10 when # /sys/bus/usb/device/$THIS/speed == "480" # COUNT=50000 matchstr $TYPE { control { # any device, in any configuration, can use this. echo '** Control test cases:' echo "test 9: ch9 postconfig" do_test -t 9 -c 5000 echo "test 10: control queueing" do_test -t 10 -c 5000 # this relies on some vendor-specific commands echo "test 14: control writes" do_test -t 14 -c 15000 -s 256 -v 1 echo "test 21: control writes, unaligned" do_test -t 21 -c 100 -s 256 -v 1 } out { check_config sink-src echo '** Host Write (OUT) test cases:' echo "test 1: $COUNT transfers, same size" do_test -t 1 echo "test 3: $COUNT transfers, variable/short size" do_test -t 3 -v 421 global COUNT := '100' echo "test 17: $COUNT transfers, unaligned DMA map by core" do_test -t 17 echo "test 19: $COUNT transfers, unaligned DMA map by usb_alloc_coherent" do_test -t 19 global COUNT := '2000' echo "test 5: $COUNT scatterlists, same size entries" do_test -t 5 # try to trigger short OUT processing bugs echo "test 7a: $COUNT scatterlists, variable size/short entries" do_test -t 7 -v 579 global BUFLEN := '4096' echo "test 7b: $COUNT scatterlists, variable size/bigger entries" do_test -t 7 -v 41 global BUFLEN := '64' echo "test 7c: $COUNT scatterlists, variable size/micro entries" do_test -t 7 -v 63 } iso-out { check_config sink-src echo '** Host ISOCHRONOUS Write (OUT) test cases:' # at peak iso transfer rates: # - usb 2.0 high bandwidth, this is one frame. # - usb 1.1, it's twenty-four frames. global BUFLEN := '24500' global COUNT := '1000' # COUNT=10000 echo "test 15: $COUNT transfers, same size" # do_test -t 15 -g 3 -v 0 global BUFLEN := '32768' do_test -t 15 -g 8 -v 0 # FIXME it'd make sense to have an iso OUT test issuing # short writes on more packets than the last one global COUNT := '100' echo "test 22: $COUNT transfers, non aligned" do_test -t 22 -g 8 -v 0 } in { check_config sink-src echo '** Host Read (IN) test cases:' # NOTE: these "variable size" reads are just multiples # of 512 bytes, no EOVERFLOW testing is done yet echo "test 2: $COUNT transfers, same size" do_test -t 2 echo "test 4: $COUNT transfers, variable size" do_test -t 4 global COUNT := '100' echo "test 18: $COUNT transfers, unaligned DMA map by core" do_test -t 18 echo "test 20: $COUNT transfers, unaligned DMA map by usb_alloc_coherent" do_test -t 20 global COUNT := '2000' echo "test 6: $COUNT scatterlists, same size entries" do_test -t 6 echo "test 8: $COUNT scatterlists, variable size entries" do_test -t 8 } iso-in { check_config sink-src echo '** Host ISOCHRONOUS Read (IN) test cases:' # at peak iso transfer rates: # - usb 2.0 high bandwidth, this is one frame. # - usb 1.1, it's twenty-four frames. global BUFLEN := '24500' global COUNT := '1000' # COUNT=10000 echo "test 16: $COUNT transfers, same size" # do_test -t 16 -g 3 -v 0 global BUFLEN := '32768' do_test -t 16 -g 8 -v 0 # FIXME since iso expects faults, it'd make sense # to have an iso IN test issuing short reads ... global COUNT := '100' echo "test 23: $COUNT transfers, unaligned" do_test -t 23 -g 8 -v 0 } halt { # NOTE: sometimes hardware doesn't cooperate well with halting # endpoints from the host side. so long as mass-storage class # firmware can halt them from the device, don't worry much if # you can't make this test work on your device. global COUNT := '2000' echo "test 13: $COUNT halt set/clear" do_test -t 13 } unlink { global COUNT := '2000' echo "test 11: $COUNT read unlinks" do_test -t 11 echo "test 12: $COUNT write unlinks" do_test -t 12 } loop { # defaults need too much buffering for ez-usb devices global BUFLEN := '2048' global COUNT := '32' # modprobe g_zero qlen=$COUNT buflen=$BUFLEN loopdefault check_config loopback # FIXME someone needs to write and merge a version of this echo "write $COUNT buffers of $BUFLEN bytes, read them back" echo "write $COUNT variable size buffers, read them back" } * { echo "Don't understand test type $TYPE" exit 1; } } echo '' } } # vim: sw=4 (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TYPES) op: Equal rhs: {(SQ <"control out in">)} spids: [49] ) ] spids: [49] ) (Assignment keyword: Assign_Declare flags: ["'-i'"] pairs: [ (assign_pair lhs:(LhsName name:COUNT) op:Equal spids:[90]) (assign_pair lhs:(LhsName name:BUFLEN) op:Equal spids:[92]) ] spids: [86] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:COUNT) op:Equal rhs:{(50000)} spids:[95])] spids: [95] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:BUFLEN) op:Equal rhs:{(2048)} spids:[98])] spids: [98] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$DEVICE"))} {(Lit_Other "=")} {(DQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ("testing ALL recognized usbtest devices"))}) (C {(echo)} {(DQ )}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:TEST_ARGS) op:Equal rhs:{(DQ (-a))} spids:[142])] spids: [142] ) ] spids: [-1 126] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:TEST_ARGS) op:Equal rhs:{(DQ )} spids:[150])] spids: [150] ) ] spids: [147 154] ) (FuncDef name: do_test body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Pipeline children: [ (SimpleCommand words: [ {(./testusb)} {($ VSub_Name "$TEST_ARGS")} {(-s)} {($ VSub_Name "$BUFLEN")} {(-c)} {($ VSub_Name "$COUNT")} {($ VSub_Star "$*")} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [183] ) ] ) ] negated: True ) ] action: [(C {(echo)} {(DQ (FAIL))}) (C {(exit)} {(1)})] spids: [-1 187] ) ] spids: [-1 202] ) ] spids: [162] ) spids: [157 161] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ARGS) op: Equal rhs: {(DQ ($ VSub_Star "$*"))} spids: [207] ) ] spids: [207] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$ARGS"))} {(Lit_Other "=")} {(DQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ARGS) op: Equal rhs: {(DQ ($ VSub_Name "$TYPES"))} spids: [232] ) ] spids: [232] ) ] spids: [-1 229] ) ] spids: [-1 237] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:CONFIG) op:Equal rhs:{(SQ )} spids:[247])] spids: [247] ) (FuncDef name: check_config body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$CONFIG"))} {(Lit_Other "=")} {(DQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CONFIG) op: Equal rhs: {($ VSub_Number "$1")} spids: [279] ) ] spids: [279] ) (C {(echo)} {(DQ ("assuming ") ($ VSub_Name "$CONFIG") (" configuration"))}) (ControlFlow token:) ] spids: [-1 276] ) ] spids: [-1 295] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$CONFIG"))} {(Lit_Other "=")} {($ VSub_Number "$1")} {(Lit_Other "]")} ) terminator: ) ] action: [(ControlFlow token:)] spids: [-1 313] ) ] spids: [-1 319] ) (C {(echo)} { (DQ ("** device must be in ") ($ VSub_Number "$1") (" config, but it's ") ($ VSub_Name "$CONFIG") (" instead") ) } ) (C {(exit)} {(1)}) ] spids: [257] ) spids: [252 256] ) (C {(echo)} {(DQ ("TESTING: ") ($ VSub_Name "$ARGS"))}) (While cond: [(C {(Lit_Other ":")} {(true)})] body: (DoGroup children: [ (C {(echo)} { (CommandSubPart command_list: (CommandList children:[(C {(date)})]) left_token: spids: [361 363] ) } ) (ForEach iter_name: TYPE iter_words: [{($ VSub_Name "$ARGS")}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(5000)} spids: [383] ) ] spids: [383] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUFLEN) op: Equal rhs: {(2048)} spids: [387] ) ] spids: [387] ) (Case to_match: {($ VSub_Name "$TYPE")} arms: [ (case_arm pat_list: [{(control)}] action: [ (C {(echo)} {(SQ <"** Control test cases:">)}) (C {(echo)} {(DQ ("test 9: ch9 postconfig"))}) (C {(do_test)} {(-t)} {(9)} {(-c)} {(5000)}) (C {(echo)} {(DQ ("test 10: control queueing"))}) (C {(do_test)} {(-t)} {(10)} {(-c)} {(5000)}) (C {(echo)} {(DQ ("test 14: control writes"))}) (C {(do_test)} {(-t)} {(14)} {(-c)} {(15000)} {(-s)} {(256)} {(-v)} {(1)}) (C {(echo)} {(DQ ("test 21: control writes, unaligned"))}) (C {(do_test)} {(-t)} {(21)} {(-c)} {(100)} {(-s)} {(256)} {(-v)} {(1)}) ] spids: [412 413 523 -1] ) (case_arm pat_list: [{(out)}] action: [ (C {(check_config)} {(sink-src)}) (C {(echo)} {(SQ <"** Host Write (OUT) test cases:">)}) (C {(echo)} {(DQ ("test 1: ") ($ VSub_Name "$COUNT") (" transfers, same size"))} ) (C {(do_test)} {(-t)} {(1)}) (C {(echo)} { (DQ ("test 3: ") ($ VSub_Name "$COUNT") (" transfers, variable/short size") ) } ) (C {(do_test)} {(-t)} {(3)} {(-v)} {(421)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(100)} spids: [581] ) ] spids: [581] ) (C {(echo)} { (DQ ("test 17: ") ($ VSub_Name "$COUNT") (" transfers, unaligned DMA map by core") ) } ) (C {(do_test)} {(-t)} {(17)}) (C {(echo)} { (DQ ("test 19: ") ($ VSub_Name "$COUNT") (" transfers, unaligned DMA map by usb_alloc_coherent") ) } ) (C {(do_test)} {(-t)} {(19)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(2000)} spids: [619] ) ] spids: [619] ) (C {(echo)} { (DQ ("test 5: ") ($ VSub_Name "$COUNT") (" scatterlists, same size entries") ) } ) (C {(do_test)} {(-t)} {(5)}) (C {(echo)} { (DQ ("test 7a: ") ($ VSub_Name "$COUNT") (" scatterlists, variable size/short entries") ) } ) (C {(do_test)} {(-t)} {(7)} {(-v)} {(579)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUFLEN) op: Equal rhs: {(4096)} spids: [664] ) ] spids: [664] ) (C {(echo)} { (DQ ("test 7b: ") ($ VSub_Name "$COUNT") (" scatterlists, variable size/bigger entries") ) } ) (C {(do_test)} {(-t)} {(7)} {(-v)} {(41)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUFLEN) op: Equal rhs: {(64)} spids: [688] ) ] spids: [688] ) (C {(echo)} { (DQ ("test 7c: ") ($ VSub_Name "$COUNT") (" scatterlists, variable size/micro entries") ) } ) (C {(do_test)} {(-t)} {(7)} {(-v)} {(63)}) ] spids: [527 528 712 -1] ) (case_arm pat_list: [{(iso-out)}] action: [ (C {(check_config)} {(sink-src)}) (C {(echo)} {(SQ <"** Host ISOCHRONOUS Write (OUT) test cases:">)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUFLEN) op: Equal rhs: {(24500)} spids: [745] ) ] spids: [745] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(1000)} spids: [750] ) ] spids: [750] ) (C {(echo)} {(DQ ("test 15: ") ($ VSub_Name "$COUNT") (" transfers, same size"))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUFLEN) op: Equal rhs: {(32768)} spids: [772] ) ] spids: [772] ) (C {(do_test)} {(-t)} {(15)} {(-g)} {(8)} {(-v)} {(0)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(100)} spids: [801] ) ] spids: [801] ) (C {(echo)} {(DQ ("test 22: ") ($ VSub_Name "$COUNT") (" transfers, non aligned"))} ) (C {(do_test)} {(-t)} {(22)} {(-g)} {(8)} {(-v)} {(0)}) ] spids: [716 717 830 -1] ) (case_arm pat_list: [{(KW_In in)}] action: [ (C {(check_config)} {(sink-src)}) (C {(echo)} {(SQ <"** Host Read (IN) test cases:">)}) (C {(echo)} {(DQ ("test 2: ") ($ VSub_Name "$COUNT") (" transfers, same size"))} ) (C {(do_test)} {(-t)} {(2)}) (C {(echo)} { (DQ ("test 4: ") ($ VSub_Name "$COUNT") (" transfers, variable size")) } ) (C {(do_test)} {(-t)} {(4)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(100)} spids: [893] ) ] spids: [893] ) (C {(echo)} { (DQ ("test 18: ") ($ VSub_Name "$COUNT") (" transfers, unaligned DMA map by core") ) } ) (C {(do_test)} {(-t)} {(18)}) (C {(echo)} { (DQ ("test 20: ") ($ VSub_Name "$COUNT") (" transfers, unaligned DMA map by usb_alloc_coherent") ) } ) (C {(do_test)} {(-t)} {(20)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(2000)} spids: [931] ) ] spids: [931] ) (C {(echo)} { (DQ ("test 6: ") ($ VSub_Name "$COUNT") (" scatterlists, same size entries") ) } ) (C {(do_test)} {(-t)} {(6)}) (C {(echo)} { (DQ ("test 8: ") ($ VSub_Name "$COUNT") (" scatterlists, variable size entries") ) } ) (C {(do_test)} {(-t)} {(8)}) ] spids: [834 835 967 -1] ) (case_arm pat_list: [{(iso-in)}] action: [ (C {(check_config)} {(sink-src)}) (C {(echo)} {(SQ <"** Host ISOCHRONOUS Read (IN) test cases:">)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUFLEN) op: Equal rhs: {(24500)} spids: [1000] ) ] spids: [1000] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(1000)} spids: [1005] ) ] spids: [1005] ) (C {(echo)} {(DQ ("test 16: ") ($ VSub_Name "$COUNT") (" transfers, same size"))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUFLEN) op: Equal rhs: {(32768)} spids: [1027] ) ] spids: [1027] ) (C {(do_test)} {(-t)} {(16)} {(-g)} {(8)} {(-v)} {(0)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(100)} spids: [1056] ) ] spids: [1056] ) (C {(echo)} {(DQ ("test 23: ") ($ VSub_Name "$COUNT") (" transfers, unaligned"))} ) (C {(do_test)} {(-t)} {(23)} {(-g)} {(8)} {(-v)} {(0)}) ] spids: [971 972 1085 -1] ) (case_arm pat_list: [{(halt)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(2000)} spids: [1109] ) ] spids: [1109] ) (C {(echo)} {(DQ ("test 13: ") ($ VSub_Name "$COUNT") (" halt set/clear"))}) (C {(do_test)} {(-t)} {(13)}) ] spids: [1089 1090 1129 -1] ) (case_arm pat_list: [{(unlink)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(2000)} spids: [1137] ) ] spids: [1137] ) (C {(echo)} {(DQ ("test 11: ") ($ VSub_Name "$COUNT") (" read unlinks"))}) (C {(do_test)} {(-t)} {(11)}) (C {(echo)} {(DQ ("test 12: ") ($ VSub_Name "$COUNT") (" write unlinks"))}) (C {(do_test)} {(-t)} {(12)}) ] spids: [1133 1134 1174 -1] ) (case_arm pat_list: [{(loop)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUFLEN) op: Equal rhs: {(2048)} spids: [1186] ) ] spids: [1186] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COUNT) op: Equal rhs: {(32)} spids: [1190] ) ] spids: [1190] ) (C {(check_config)} {(loopback)}) (C {(echo)} { (DQ ("write ") ($ VSub_Name "$COUNT") (" buffers of ") ($ VSub_Name "$BUFLEN") (" bytes, read them back") ) } ) (C {(echo)} { (DQ ("write ") ($ VSub_Name "$COUNT") (" variable size buffers, read them back") ) } ) ] spids: [1178 1179 1232 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(echo)} {(DQ ("Don't understand test type ") ($ VSub_Name "$TYPE"))}) (Sentence child: (C {(exit)} {(1)}) terminator: ) ] spids: [1236 1237 -1 1254] ) ] spids: [405 409 1254] ) (C {(echo)} {(SQ )}) ] spids: [376 1263] ) spids: [372 -1] ) ] spids: [356 1265] ) ) ] )