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

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

Pass unknown run_unit_tests long arguments to tests

e.g. ./run_unit_tests.sh --v=2
     ./run_unit_tests.sh --gtest_filter=*Advertise*

Change-Id: I63e7549d850a15107ca56333868cc8ccd3eeb893
parent a44a5648
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -10,8 +10,11 @@ known_tests=(
)

usage() {
  echo "Usage: $0 [-s <specific device> ][--all|--help|<test name>[.<filter>] ...]"
  echo ""
  echo "Usage: $0 --help"
  echo "       $0 [-s <specific device>] [--all] [<test name>[.<filter>] ...] [--<arg> ...]"
  echo
  echo "Unknown long arguments are passed to the test."
  echo
  echo "Known test names:"

  for name in ${known_tests[*]}
@@ -24,6 +27,17 @@ 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
@@ -35,7 +49,7 @@ run_tests() {
    echo "pushing..."
    $adb push {$ANDROID_PRODUCT_OUT,}/data/nativetest/$name/$name
    echo "running..."
    $adb shell data/nativetest/$name/$name${filter:+ "--gtest_filter=${filter}"}
    $adb shell data/nativetest/$name/$name${filter:+ "--gtest_filter=${filter}"} ${test_args[*]}
    if [ $? != 0 ]; then
      failed_tests="$failed_tests$CR!!! FAILED TEST: $name !!!";
    fi
@@ -49,6 +63,7 @@ run_tests() {
}

tests=()
test_args=()
while [ $# -gt 0 ]; do
  case "$1" in
    -h|--help)
@@ -69,6 +84,10 @@ while [ $# -gt 0 ]; do
      tests+=( ${known_tests[*]} )
      shift
      ;;
    --*)
      test_args+=( "$1" )
      shift
      ;;
    *)
      tests+=( $1 )
      shift
@@ -77,7 +96,7 @@ while [ $# -gt 0 ]; do
done

if [ ${#tests[*]} -eq 0 ]; then
  run_tests "$device" ${known_tests[*]} || exit 1
else
  run_tests "$device" ${tests[*]} || exit 1
  tests+=( ${known_tests[*]} )
fi

run_tests "$device" ${test_args[*]} -- ${tests[*]} || exit 1