1#!/bin/bash
2#
3# Copyright (C) 2014 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
17checkFile() {
18    if [ ! -f "$1" ]; then
19        echo "Unable to locate $1"
20        exit
21    fi;
22}
23
24HOST_JAR_DIR=${ANDROID_HOST_OUT}/framework
25HOST_JARS="ddmlib-prebuilt tradefed-prebuilt hosttestlib\
26    compatibility-tradefed_v2 compatibility-tradefed-tests_v2\
27    compatibility-java-scanner_v2 compatibility-java-scanner-tests_v2\
28    compatibility-native-scanner_v2 compatibility-native-scanner-tests_v2\
29    compatibility-xml-plan-generator_v2 compatibility-xml-plan-generator-tests_v2\
30    compatibility-device-util-tests_v2 compatibility-device-setup-tests_v2\
31    compatibility-common-util-hostsidelib_v2 compatibility-common-util-tests_v2"
32
33for JAR in ${HOST_JARS}; do
34    checkFile ${HOST_JAR_DIR}/${JAR}.jar
35    JAR_PATH=${JAR_PATH}:${HOST_JAR_DIR}/${JAR}.jar
36done
37
38DEVICE_LIBS_DIR=${ANDROID_PRODUCT_OUT}/obj/JAVA_LIBRARIES
39DEVICE_LIBS="compatibility-common-util-devicesidelib_v2 compatibility-device-util_v2\
40    compatibility-device-setup_v2"
41
42for LIB in ${DEVICE_LIBS}; do
43    checkFile ${DEVICE_LIBS_DIR}/${LIB}_intermediates/javalib.jar
44    JAR_PATH=${JAR_PATH}:${DEVICE_LIBS_DIR}/${LIB}_intermediates/javalib.jar
45done
46
47# TODO(stuartscott): Currently the test classes are explicitly set here, but
48# once our wrappers for tradefed are in place we can make it scan and generate
49# the list of test at runtime.
50TEST_CLASSES="com.android.compatibility.common.devicesetup.DeviceSetupTest\
51    com.android.compatibility.common.scanner.JavaScannerTest\
52    com.android.compatibility.common.scanner.NativeScannerTest\
53    com.android.compatibility.common.tradefed.TradefedTest\
54    com.android.compatibility.common.util.DeviceUtilTest\
55    com.android.compatibility.common.util.CommonUtilTest\
56    com.android.compatibility.common.xmlgenerator.XmlPlanGeneratorTest"
57
58for CLASS in ${TEST_CLASSES}; do
59    java $RDBG_FLAG -cp ${JAR_PATH} com.android.compatibility.common.tradefed.command.CompatibilityConsole run\
60            singleCommand host -n --class ${CLASS} "$@"
61done
62