run_apk.sh 940 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #! /bin/sh
  2. # Copyright 2019 Google LLC.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Note:
  6. # The ANDROID_SERIAL, SKQP_ARGS, and SKQP_SLEEP environment variables affect
  7. # this script.
  8. if ! [ -f "$1" ] || ! [ -d "$2" ] ; then
  9. echo "Usage: $0 SKQP_APK_FILE_PATH RESULTS_DIRECTORY" >&2
  10. exit 1
  11. fi
  12. SED_CMD='s/^.* org.skia.skqp: output written to "\([^"]*\)".*$/\1/p'
  13. APK="$1"
  14. DST="$2"
  15. printf '\n\nAPK = "%s"\nDST = "%s"\n\n' "$APK" "$DST"
  16. set -x
  17. timeout 60 adb wait-for-device || exit 1
  18. sleep ${SKQP_SLEEP:-0}
  19. adb uninstall org.skia.skqp > /dev/null 2>&1
  20. adb install "$APK" || exit 1
  21. adb logcat -c
  22. adb shell am instrument $SKQP_ARGS -w org.skia.skqp 2>&1 | tee "$DST"/stdout
  23. adb logcat -d TestRunner org.skia.skqp skia DEBUG '*:S' > "$DST"/logcat
  24. ODIR="$(sed -n "$SED_CMD" "$DST"/logcat | head -1)"
  25. if adb shell "test -d '$ODIR'"; then adb pull "$ODIR" "$DST"; fi