loopback-test.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #! /bin/bash
  2. TESTS_PATH="`dirname \"$0\"`"
  3. TESTS_PATH="`( cd \"$TESTS_PATH\" && pwd )`"
  4. function pci {
  5. PCILIB_PATH=$TESTS_PATH/..
  6. LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
  7. }
  8. function compare {
  9. PCILIB_PATH=$TESTS_PATH/..
  10. LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/apps/compare_to_value $*
  11. }
  12. #size=`expr 1024 "*" 1024`
  13. size=`expr 1024 "*" 1`
  14. multiplier=2
  15. wait=0
  16. /root/pcitool/tests/ipecamera/frame.sh &> /dev/null
  17. rm -f bench.out
  18. pci --stop-dma dma1
  19. pci --start-dma dma1
  20. pci -r dma1 -s 16777216 --multipacket -o /dev/null &> /dev/null
  21. pci -r dma1 -s 1024 -o /dev/null | grep -i "Error (62)" &> /dev/null
  22. if [ $? -ne 0 ]; then
  23. echo "There is data on dma..."
  24. exit
  25. fi
  26. failed=0
  27. send=0
  28. errors=0
  29. err_num=0
  30. print_iters=`expr 2 + 1024 '*' 100 / $size`
  31. read_size=`expr $multiplier '*' $size`
  32. echo "Starting..."
  33. i=1
  34. pci -w 0x9040 0x201
  35. while [ 1 ]; do
  36. if [ $wait -gt 0 ]; then
  37. pci -w 0x9040 0x1
  38. fi
  39. pci -w dma1 -s $size "*0x$i"
  40. rm -f /tmp/camera-test.out
  41. pci -r dma1 --wait --multipacket -s $read_size -o /tmp/camera-test.out -t 1000000 &> /dev/null
  42. if [ $wait -gt 0 ]; then
  43. wrdone=0
  44. while [ $wrdone -eq 0 ]; do
  45. # pci --list-dma-engines
  46. pci --list-dma-engines | grep "DMA1 S2C" | grep "SD" #&> /dev/null
  47. wrdone=$?
  48. done
  49. pci -w 0x9040 0x201
  50. fi
  51. res=`compare /tmp/camera-test.out $read_size "$i" 6 2 6`
  52. if [ $? -eq 0 ]; then
  53. err_cnt=`echo $res | cut -f 1 -d ' '`
  54. if [ "$err_cnt" -ne 0 ]; then
  55. pci -r dma1 --wait --multipacket -o /tmp/camera-test.out -t 1000000 &> /dev/null
  56. cp /tmp/camera-test.out /tmp/camera-test.out.$err_num
  57. err_num=$(($err_num + 1))
  58. fi
  59. byte_cnt=`echo $res | cut -f 3 -d ' '`
  60. send=$(($send + $byte_cnt * 4))
  61. errors=$(($errors + $err_cnt * 4))
  62. else
  63. failed=$(($failed + 1))
  64. fi
  65. i=$((i + 1))
  66. if [ $i -eq $print_iters ]; then
  67. echo "Data send: $send bytes, Errors: $errors bytes, Failed exchanges: $failed"
  68. # pci -r 0x9070 -s 4
  69. i=1
  70. fi
  71. done