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

Commit 5df06031 authored by Scott James Remnant's avatar Scott James Remnant
Browse files

Add -s <specific device> to run_unit_tests

For the developer with more than one Android or Brillo device plugged
into their workstation at once.

Change-Id: Ice273564f2debdc0708ce473be6119ff2ae33f39
parent 8a79a41d
Loading
Loading
Loading
Loading
+37 −9
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ known_tests=(
)

usage() {
  echo "Usage: $0 [--all|--help|<test names>]"
  echo "Usage: $0 [-s <specific device> ][--all|--help|<test names>]"
  echo ""
  echo "Known test names:"

@@ -21,14 +21,17 @@ usage() {
}

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

  failed_tests=''
  for name in $*
  do
    echo "--- $name ---"
    echo "pushing..."
    adb push {$ANDROID_PRODUCT_OUT,}/data/nativetest/$name/$name
    $adb push {$ANDROID_PRODUCT_OUT,}/data/nativetest/$name/$name
    echo "running..."
    adb shell data/nativetest/$name/$name
    $adb shell data/nativetest/$name/$name
    if [ $? != 0 ]; then
      failed_tests="$failed_tests$CR!!! FAILED TEST: $name !!!";
    fi
@@ -39,11 +42,36 @@ run_tests() {
  fi
}

if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
tests=()
while [ $# -gt 0 ]; do
  case "$1" in
    -h|--help)
      usage
elif [ $# -eq 0 ] || [ "$1" == "--all" ]; then
  run_tests ${known_tests[*]}
else
  run_tests $*
      exit 0
      ;;
    -s)
      shift
      if [ $# -eq 0 ]; then
        echo "error: no device specified" 1>&2
        usage
        exit 1
      fi
      device="$1"
      shift
      ;;
    --all)
      tests+=( ${known_tests[*]} )
      shift
      ;;
    *)
      tests+=( $1 )
      shift
      ;;
  esac
done

if [ ${#tests[*]} -eq 0 ]; then
  run_tests "$device" ${known_tests[*]}
else
  run_tests "$device" ${tests[*]}
fi