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

Commit b0a4085f authored by Scott James Remnant's avatar Scott James Remnant
Browse files

Clean up run_unit_tests a little

Since run_tests() is only ever called once, and now has much more complex
arguments, it makes sense for it just to be the mainline of the script.

Change-Id: I64cef03212e76b0058f80e0d9450ed6cf607b9ed
parent 92108756
Loading
Loading
Loading
Loading
+26 −40
Original line number Diff line number Diff line
@@ -23,45 +23,7 @@ usage() {
  done
}

run_tests() {
  adb="adb${1:+ -s $1}"
  shift

  test_args=()
  for arg
  do
    shift
    if [ "$arg" == "--" ]; then
      break
    else
      test_args+=( "$arg" )
    fi
  done

  failed_tests=''
  for spec in $*
  do
    name="${spec%%.*}"
    if [ "${name}" != "${spec}" ]; then
      filter="${spec#*.}"
    fi
    echo "--- $name ---"
    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 !!!";
    fi
  done

  if [ "$failed_tests" != "" ]; then
    echo "$failed_tests";
    return 1
  fi
  return 0
}

device=
tests=()
test_args=()
while [ $# -gt 0 ]; do
@@ -99,4 +61,28 @@ if [ ${#tests[*]} -eq 0 ]; then
  tests+=( ${known_tests[*]} )
fi

run_tests "$device" ${test_args[*]} -- ${tests[*]} || exit 1
adb="adb${device:+ -s $device}"

failed_tests=''
for spec in ${tests[*]}
do
  name="${spec%%.*}"
  if [ "${name}" != "${spec}" ]; then
    filter="${spec#*.}"
  fi
  echo "--- $name ---"
  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 !!!";
  fi
done

if [ "$failed_tests" != "" ]; then
  echo "$failed_tests";
  exit 1
fi

exit 0