hcd-tests.sh 6.0 KB

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