1cb93a386Sopenharmony_ci#! /bin/sh
2cb93a386Sopenharmony_ci# Copyright 2019 Google LLC.
3cb93a386Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
4cb93a386Sopenharmony_ci# found in the LICENSE file.
5cb93a386Sopenharmony_ci
6cb93a386Sopenharmony_ci# Notes:
7cb93a386Sopenharmony_ci#
8cb93a386Sopenharmony_ci#   You may need to run as root for docker permissions.
9cb93a386Sopenharmony_ci#
10cb93a386Sopenharmony_ci#   The SKQP_ARGS environment variable affects this script.
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_ciif ! [ -f "$1" ] ; then
13cb93a386Sopenharmony_ci  echo "Usage:  $0 SKQP_APK_FILE_PATH" >&2
14cb93a386Sopenharmony_ci  exit 1
15cb93a386Sopenharmony_cifi
16cb93a386Sopenharmony_ci
17cb93a386Sopenharmony_ciAPK_DIR="$(cd "$(dirname "$1")"; pwd)"
18cb93a386Sopenharmony_ciAPK_FILE="$(basename "$1")"
19cb93a386Sopenharmony_ciDST="$(mktemp -d "${TMPDIR:-/tmp}/skqp_emulated_test.XXXXXXXXXX")"
20cb93a386Sopenharmony_ciSED_CMD='s/^.* org.skia.skqp: output written to "\([^"]*\)".*$/\1/p'
21cb93a386Sopenharmony_ciSKQP="$(cd $(dirname "$0"); pwd)"
22cb93a386Sopenharmony_ci
23cb93a386Sopenharmony_ciset -x
24cb93a386Sopenharmony_ci
25cb93a386Sopenharmony_cicd "${SKQP}/../../infra/skqp/docker"
26cb93a386Sopenharmony_ci
27cb93a386Sopenharmony_cidocker build -t android-skqp ./android-skqp/ > "$DST"/docker-build || exit 2
28cb93a386Sopenharmony_ci
29cb93a386Sopenharmony_cidocker run --privileged --rm -d \
30cb93a386Sopenharmony_ci  --name android_em \
31cb93a386Sopenharmony_ci  --env=DEVICE="Samsung Galaxy S6" \
32cb93a386Sopenharmony_ci  --env=SKQP_SLEEP="30" \
33cb93a386Sopenharmony_ci  --env=SKQP_ARGS="$SKQP_ARGS" \
34cb93a386Sopenharmony_ci  --volume="$DST":/DST \
35cb93a386Sopenharmony_ci  --volume="$APK_DIR":/APK:ro \
36cb93a386Sopenharmony_ci  --volume="$SKQP":/SKQP:ro \
37cb93a386Sopenharmony_ci  android-skqp > "$DST"/docker-run || exit 3
38cb93a386Sopenharmony_ci
39cb93a386Sopenharmony_cidocker exec android_em sh "/SKQP/run_apk.sh" "/APK/$APK_FILE" "/DST"
40cb93a386Sopenharmony_ci
41cb93a386Sopenharmony_cidocker kill android_em
42cb93a386Sopenharmony_ci
43cb93a386Sopenharmony_ci"${SKQP}/../../bin/sysopen" "$DST"/skqp_report_*/report.html
44