run-all.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/bin/sh
  2. errors=0
  3. umask 0002
  4. DATE="$(date +%s)"
  5. unset LOGBASEDIR
  6. if [ -z "$LOGDIR" ]; then
  7. LOGBASEDIR=logs
  8. LOGDIR=$LOGBASEDIR/$DATE
  9. mkdir -p $LOGDIR
  10. fi
  11. export LOGDIR
  12. if [ -z "$DBFILE" ]; then
  13. DB=""
  14. else
  15. DB="-S $DBFILE --commit $(git rev-parse HEAD)"
  16. if [ -n "$BUILD" ]; then
  17. DB="$DB -b $BUILD"
  18. fi
  19. if [ "$PREFILL_DB" = "y" ] ; then
  20. DB="$DB --prefill-tests"
  21. fi
  22. fi
  23. usage()
  24. {
  25. echo "$0 [-v | --valgrind | valgrind] [-t | --trace | trace]"
  26. echo "\t[-n <num> | --channels <num>] [-B | --build]"
  27. echo "\t[-c | --codecov ] [run-tests.py parameters]"
  28. exit 1
  29. }
  30. unset VALGRIND
  31. unset TRACE
  32. unset TRACE_ARGS
  33. unset RUN_TEST_ARGS
  34. unset BUILD
  35. unset BUILD_ARGS
  36. unset CODECOV
  37. while [ "$1" != "" ]; do
  38. case $1 in
  39. -v | --valgrind | valgrind)
  40. shift
  41. echo "$0: using valgrind"
  42. VALGRIND=valgrind
  43. ;;
  44. -t | --trace | trace)
  45. shift
  46. echo "$0: using Trace"
  47. TRACE=trace
  48. ;;
  49. -n | --channels)
  50. shift
  51. NUM_CH=$1
  52. shift
  53. echo "$0: using channels=$NUM_CH"
  54. ;;
  55. -B | --build)
  56. shift
  57. echo "$0: build before running tests"
  58. BUILD=build
  59. ;;
  60. -c | --codecov)
  61. shift
  62. echo "$0: using code coverage"
  63. CODECOV=lcov
  64. BUILD_ARGS=-c
  65. ;;
  66. -h | --help)
  67. usage
  68. ;;
  69. *)
  70. RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
  71. shift
  72. ;;
  73. esac
  74. done
  75. if [ ! -z "$RUN_TEST_ARGS" ]; then
  76. echo "$0: passing the following args to run-tests.py: $RUN_TEST_ARGS"
  77. fi
  78. unset SUFFIX
  79. if [ ! -z "$BUILD" ]; then
  80. SUFFIX=-build
  81. fi
  82. if [ ! -z "$VALGRIND" ]; then
  83. SUFFIX=$SUFFIX-valgrind
  84. fi
  85. if [ ! -z "$TRACE" ]; then
  86. SUFFIX=$SUFFIX-trace
  87. TRACE_ARGS="-T"
  88. fi
  89. if [ ! -z "$CODECOV" ]; then
  90. SUFFIX=$SUFFIX-codecov
  91. fi
  92. if [ ! -z "$BUILD" ]; then
  93. echo "Building with args=$BUILD_ARGS"
  94. if ! ./build.sh $BUILD_ARGS; then
  95. echo "Failed building components"
  96. exit 1
  97. fi
  98. fi
  99. if ! ./start.sh $VALGRIND $TRACE channels=$NUM_CH; then
  100. if ! [ -z "$LOGBASEDIR" ] ; then
  101. echo "Could not start test environment" > $LOGDIR/run
  102. fi
  103. exit 1
  104. fi
  105. sudo ./run-tests.py -D --logdir "$LOGDIR" $TRACE_ARGS -q $DB $RUN_TEST_ARGS || errors=1
  106. ./stop.sh
  107. if [ ! -z "$VALGRIND" ] ; then
  108. failures=`grep "ERROR SUMMARY" $LOGDIR/valgrind-* | grep -v " 0 errors" | wc -l`
  109. if [ $failures -gt 0 ]; then
  110. echo "Mark as failed due to valgrind errors"
  111. errors=1
  112. fi
  113. fi
  114. if [ ! -z "$CODECOV" ] ; then
  115. lcov -q --capture --directory ../../wpa_supplicant --output-file $LOGDIR/wpas_lcov.info
  116. genhtml -q $LOGDIR/wpas_lcov.info --output-directory $LOGDIR/wpas_lcov
  117. lcov -q --capture --directory ../../hostapd --output-file $LOGDIR/hostapd_lcov.info
  118. genhtml -q $LOGDIR/hostapd_lcov.info --output-directory $LOGDIR/hostapd_lcov
  119. fi
  120. if [ $errors -gt 0 ]; then
  121. tar czf /tmp/hwsim-tests-$DATE-FAILED$SUFFIX.tar.gz $LOGDIR/
  122. exit 1
  123. fi
  124. echo "ALL-PASSED"