Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7744ec61 authored by Scott James Remnant's avatar Scott James Remnant
Browse files

Add iterations option to run_unit_tests

e.g. ./run_unit_tests.sh -i 100 net_test_osi.EagerReaderTest.test_large_data_multibyte

Tests are reported as failed if they fail in one or more of the iterations,
and will report a count of failures. Useful for smoking out flakey tests.

Change-Id: Ibb1c1d4c3023d59782945b8f6d9bde06bfe8c589
parent b0a4085f
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ known_tests=(

usage() {
  echo "Usage: $0 --help"
  echo "       $0 [-s <specific device>] [--all] [<test name>[.<filter>] ...] [--<arg> ...]"
  echo "       $0 [-i <iterations>] [-s <specific device>] [--all] [<test name>[.<filter>] ...] [--<arg> ...]"
  echo
  echo "Unknown long arguments are passed to the test."
  echo
@@ -23,6 +23,7 @@ usage() {
  done
}

iterations=1
device=
tests=()
test_args=()
@@ -32,6 +33,16 @@ while [ $# -gt 0 ]; do
      usage
      exit 0
      ;;
    -i)
      shift
      if [ $# -eq 0 ]; then
        echo "error: number of iterations expected" 1>&2
        usage
        exit 1
      fi
      iterations=$(( $1 ))
      shift
      ;;
    -s)
      shift
      if [ $# -eq 0 ]; then
@@ -74,9 +85,14 @@ do
  echo "pushing..."
  $adb push {$ANDROID_PRODUCT_OUT,}/data/nativetest/$name/$name
  echo "running..."
  $adb shell data/nativetest/$name/$name${filter:+ "--gtest_filter=${filter}"} ${test_args[*]}
  if [ $? != 0 ]; then
    failed_tests="$failed_tests$CR!!! FAILED TEST: $name !!!";
  failed_count=0
  for i in $(seq 1 ${iterations})
  do
    $adb shell data/nativetest/$name/$name${filter:+ "--gtest_filter=${filter}"} ${test_args[*]} || failed_count=$(( $failed_count + 1 ))
  done

  if [ $failed_count != 0 ]; then
    failed_tests="$failed_tests$CR!!! FAILED TEST: $name ${failed_count}/${iterations} !!!";
  fi
done