1#!/bin/bash 2 3# Copyright (C) 2019 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 17# launcher script for vts-tradefed harness 18# can be used from an Android build environment, or a standalone vts zip 19 20UTILS_SCRIPT="$(dirname $(realpath $0))/test-utils-script" 21 22if [ ! -f "${UTILS_SCRIPT}" ] 23then 24 UTILS_SCRIPT="${ANDROID_BUILD_TOP}/platform_testing/scripts/test-utils-script" 25fi 26 27if [ ! -f "${UTILS_SCRIPT}" ] 28then 29 echo -e "Cannot find test-utils-script in the same location as this script and ANDROID_BUILD_TOP is not defined." 30 exit 1 31fi 32 33source ${UTILS_SCRIPT} 34 35checkPath aapt 36checkPath adb 37 38RDBG_FLAG=$(getRemoteDbgFlag) 39 40# get OS 41HOST=`uname` 42HOST_ARCH=`uname -sm` 43if [ "$HOST_ARCH" == "Linux x86_64" ]; then 44 OS="linux-x86" 45elif [ "$HOST_ARCH" == "Linux aarch64" ]; then 46 OS="linux-arm64" 47 # Bundled java is for linux-x86 so use host JDK on linux-arm64 48 JAVA_BINARY=java 49elif [ "$HOST_ARCH" == "Darwin x86_64" ]; then 50 OS="darwin-x86" 51 # Bundled java is for linux so use host JDK on Darwin 52 JAVA_BINARY=java 53else 54 echo "Unrecognized OS" 55 exit 56fi 57 58# check if in Android build env 59if [ ! -z "${ANDROID_BUILD_TOP}" ]; then 60 if [ ! -z "${ANDROID_HOST_OUT}" ]; then 61 VTS_ROOT=${ANDROID_HOST_OUT}/vts 62 else 63 VTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/vts 64 fi 65 if [ ! -d ${VTS_ROOT} ]; then 66 echo "Could not find $VTS_ROOT in Android build environment. Try 'make vts'" 67 exit 68 fi; 69fi; 70 71if [ -z ${VTS_ROOT} ]; then 72 # assume we're in an extracted vts install 73 VTS_ROOT="$(dirname $(realpath $0))/../.." 74fi; 75 76if [ -z ${JAVA_BINARY} ]; then 77 JAVA_BINARY=${VTS_ROOT}/android-vts/jdk/bin/java 78fi; 79 80if [ ! -f "${JAVA_BINARY}" ]; then 81 JAVA_BINARY=java 82fi 83 84checkPath ${JAVA_BINARY} 85checkJavaVersion ${JAVA_BINARY} 86 87JAR_DIR=${VTS_ROOT}/android-vts/tools 88 89for JAR in ${JAR_DIR}/*.jar; do 90 JAR_PATH=${JAR_PATH}:${JAR} 91done 92JAR_PATH=${JAR_PATH:1} # Strip off leading ':' 93 94OPTIONAL_JARS=" 95 google-tradefed 96 google-tradefed-tests 97 google-tf-prod-tests" 98 99STANDALONE_JAR_DIR=${ANDROID_HOST_OUT}/framework 100for JAR in $OPTIONAL_JARS; do 101 if [ -f "${JAR_DIR}/${JAR}.jar" ]; then 102 JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar 103 elif [ -f "${STANDALONE_JAR_DIR}/${JAR}.jar" ]; then 104 JAR_PATH=${JAR_PATH}:${STANDALONE_JAR_DIR}/${JAR}.jar 105 fi; 106done 107 108LIB_DIR=${VTS_ROOT}/android-vts/lib 109loadSharedLibraries "$HOST" "$LIB_DIR" 110 111# include any host-side test jars 112for j in $(find ${VTS_ROOT}/android-vts/testcases -type f -name '*.jar'); do 113 JAR_PATH=${JAR_PATH}:$j 114done 115 116VTS_TESTCASES=${VTS_ROOT}/android-vts/testcases/ 117VTS_TESTCASES=${VTS_TESTCASES} ${JAVA_BINARY} $RDBG_FLAG -Xmx16g -XX:+HeapDumpOnOutOfMemoryError -cp ${JAR_PATH} -DVTS_ROOT=${VTS_ROOT} com.android.compatibility.common.tradefed.command.CompatibilityConsole "$@" 118