Home | History | Annotate | Download | only in skqp
      1 #! /bin/sh
      2 # Copyright 2018 Google LLC.
      3 # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
      4 
      5 # If you have more than one device attached, run `adb devices -l` and then set
      6 # the ANDROID_SERIAL environment variable to the correct serial number.
      7 
      8 APK="$1"
      9 shift
     10 
     11 if ! [ -f "$APK" ]; then
     12     cat >&2 <<- EOM
     13 
     14 	Usage:
     15 	  $0 SKQP_APK_FILE_PATH [OPTIONAL_TESTS_TO_RUN...]
     16 
     17 	e.g.:
     18 	  $0 skqp-universal-debug.apk
     19 	or:
     20 	  $0 skqp-universal-debug.apk vk_hairmodes gles_gammatext gles_aarectmodes
     21 
     22 	EOM
     23     exit 1
     24 fi
     25 
     26 ARGS=''
     27 if [ "$#" -gt 0 ]; then
     28     ARGS="-e class org.skia.skqp.SkQPRunner#${1}"
     29     shift
     30     for arg; do
     31         ARGS="${ARGS},org.skia.skqp.SkQPRunner#${arg}"
     32     done
     33 fi
     34 
     35 TDIR="$(mktemp -d "${TMPDIR:-/tmp}/skqp_report.XXXXXXXXXX")"
     36 
     37 adb install -r "$APK" || exit 2
     38 adb logcat -c
     39 
     40 adb logcat TestRunner org.skia.skqp skia DEBUG "*:S" | tee "${TDIR}/logcat.txt" &
     41 LOGCAT_PID=$!
     42 
     43 ADBSHELL_PID=''
     44 trap 'kill $LOGCAT_PID; kill $ADBSHELL_PID' INT
     45 
     46 printf '\n%s\n\n' "adb shell am instrument $ARGS -w org.skia.skqp"
     47 adb shell am instrument $ARGS -w org.skia.skqp \
     48     >  "${TDIR}/stdout.txt" \
     49     2> "${TDIR}/stderr.txt" &
     50 ADBSHELL_PID=$!
     51 
     52 wait $ADBSHELL_PID
     53 trap - INT
     54 kill $LOGCAT_PID
     55 
     56 printf '\nTEST OUTPUT IS IN: "%s"\n\n' "$TDIR"
     57 
     58 SED_CMD='s/^.* org.skia.skqp: output written to "\([^"]*\)".*$/\1/p'
     59 ODIR="$(sed -n "$SED_CMD" "${TDIR}/logcat.txt" | head -1)"
     60 
     61 if ! adb shell "test -d '$ODIR'" ; then
     62     echo 'missing output :('
     63     exit 3
     64 fi
     65 
     66 odir_basename="$(basename "$ODIR")"
     67 
     68 adb pull "${ODIR}" "${TDIR}/${odir_basename}"
     69 
     70 REPORT="${TDIR}/${odir_basename}/report.html"
     71 
     72 if [ -f "$REPORT" ]; then
     73     grep 'f(.*;' "$REPORT"
     74     echo "$REPORT"
     75     "$(dirname "$0")"/../../bin/sysopen "$REPORT"
     76 else
     77     echo "$TDIR"
     78 fi
     79