1#!/bin/bash
2
3# Copyright (C) 2015 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17CTS_DIR=$(dirname ${0})/../../..
18source ${CTS_DIR}/test_defs.sh
19
20if [ `adb devices | wc -l` -lt 3 ]; then
21    echo "NO DEVICES/EMULATORS AVAILABLE. CONNECT ONE."
22    exit 1
23fi
24
25# Take the last serial in the list of devices
26SERIAL=`adb devices | egrep -o "^\w+" | tail -n1`
27if [ -z ${SERIAL} ]; then
28    echo "FAILED TO GET ADB DEVICE SERIAL FOR TEST. EXITING"
29    exit 1
30fi
31
32echo "Running device side tests on device: ${SERIAL}"
33
34APK=${ANDROID_PRODUCT_OUT}/data/app/CompatibilityTestApp/CompatibilityTestApp.apk
35checkFile ${APK}
36
37COMMON_PACKAGE=com.android.compatibility.common
38RUNNER=androidx.test.runner.AndroidJUnitRunner
39# TODO [2015-12-09 kalle] Fail & exit on failing install?
40adb -s ${SERIAL} install -r -g ${APK}
41build_jar_path ${JAR_DIR} "${JARS}"
42java $RDBG_FLAG -cp ${JAR_PATH} ${TF_CONSOLE} run singleCommand instrument --serial ${SERIAL} --package ${COMMON_PACKAGE} --runner ${RUNNER}
43adb -s ${SERIAL} uninstall ${COMMON_PACKAGE}
44