1#!/bin/bash 2 3# Copyright (C) 2024 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 mcts-tradefed harness 18# can be used from an Android build environment, or a standalone mcts 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 adb 36checkPath java 37checkJavaVersion java 38 39RDBG_FLAG=$(getRemoteDbgFlag) 40 41# get OS 42HOST=`uname` 43if [ "$HOST" == "Linux" ]; then 44 OS="linux-x86" 45elif [ "$HOST" == "Darwin" ]; then 46 OS="darwin-x86" 47else 48 echo "Unrecognized OS" 49 exit 50fi 51 52# check if in Android build env 53if [ ! -z "${ANDROID_BUILD_TOP}" ]; then 54 if [ ! -z "${ANDROID_HOST_OUT}" ]; then 55 MCTS_ROOT=${ANDROID_HOST_OUT}/mcts 56 else 57 MCTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/mcts 58 fi 59 if [ ! -d ${MCTS_ROOT} ]; then 60 echo "Could not find $MCTS_ROOT in Android build environment. Try 'make mcts'" 61 exit 62 fi; 63fi; 64 65if [ -z ${MCTS_ROOT} ]; then 66 # assume we're in an extracted mcts install 67 MCTS_ROOT="$(dirname $0)/../.." 68fi; 69 70JAR_DIR=${MCTS_ROOT}/android-mcts/tools 71 72for JAR in ${JAR_DIR}/*.jar; do 73 JAR_PATH=${JAR_PATH}:${JAR} 74done 75 76# check if APE_API_KEY is set in the env by user. 77if [ ! -n "${APE_API_KEY}" ]; then 78 GTS_GOOGLE_SERVICE_ACCOUNT=${ANDROID_BUILD_TOP}/vendor/xts/tools/gts-google-service-account/gts-google-service-account.json 79 # set KEY only for google if APE_API_KEY isn't set and GTS_GOOGLE_SERVICE_ACCOUNT exists in the soure tree. 80 if [ -f "$GTS_GOOGLE_SERVICE_ACCOUNT" ]; then 81 APE_API_KEY=${GTS_GOOGLE_SERVICE_ACCOUNT} 82 export APE_API_KEY 83 else 84 echo "APE_API_KEY not set, GTS tests may fail without authentication." 85 fi; 86fi; 87echo "APE_API_KEY: $APE_API_KEY" 88 89LIB_DIR=${MCTS_ROOT}/android-mcts/lib 90loadSharedLibraries "$HOST" "$LIB_DIR" 91 92# include any host-side test jars 93for j in $(find ${MCTS_ROOT}/android-mcts/testcases -name '*.jar'); do 94 case "$j" in 95 *testcases/art*) 96 /bin/true 97 ;; 98 *) 99 JAR_PATH=${JAR_PATH}:$j 100 ;; 101 esac 102done 103 104echo "java $RDBG_FLAG -cp ${JAR_PATH} -DMCTS_ROOT=${MCTS_ROOT} com.android.compatibility.common.tradefed.command.CompatibilityConsole "$@"" 105java $RDBG_FLAG -cp ${JAR_PATH} -DMCTS_ROOT=${MCTS_ROOT} com.android.compatibility.common.tradefed.command.CompatibilityConsole "$@" 106