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# The launcher script for running C-Suite. 18# This can be run from an Android build environment or a standalone C-Suite 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 environment. 53if [ ! -z "${ANDROID_BUILD_TOP}" ]; then 54 if [ ! -z "${ANDROID_HOST_OUT}" ]; then 55 CSUITE_ROOT=${ANDROID_HOST_OUT}/csuite 56 else 57 CSUITE_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/csuite 58 fi 59 if [ ! -d ${CSUITE_ROOT} ]; then 60 echo "Could not find $CSUITE_ROOT in Android build environment. Try 'make csuite'" 61 exit 62 fi; 63fi; 64 65if [ -z ${CSUITE_ROOT} ]; then 66 # Assume we're in an extracted csuite install. 67 CSUITE_ROOT="$(dirname $0)/../.." 68fi; 69 70JAR_DIR=${CSUITE_ROOT}/android-csuite/tools 71 72TRADEFED_JAR="tradefed" 73 74JARS="tradefed 75 compatibility-host-util 76 csuite-tradefed 77 csuite-tradefed-tests" 78 79for JAR in $JARS; do 80 checkFile ${JAR_DIR}/${JAR}.jar 81 JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar 82done 83 84OPTIONAL_JARS=" 85 google-tradefed 86 google-tradefed-tests 87 google-tf-prod-tests" 88 89for JAR in $OPTIONAL_JARS; do 90 if [ -f "${JAR_DIR}/${JAR}.jar" ]; then 91 JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar 92 fi; 93done 94 95LIB_DIR=${CSUITE_ROOT}/android-csuite/lib 96loadSharedLibraries "$HOST" "$LIB_DIR" 97 98# Include any host-side test jars. 99for j in ${CSUITE_ROOT}/android-csuite/testcases/*.jar; do 100 JAR_PATH=${JAR_PATH}:$j 101done 102 103java $RDBG_FLAG -cp ${JAR_PATH} -DCSUITE_ROOT=${CSUITE_ROOT} com.android.compatibility.common.tradefed.command.CompatibilityConsole "$@" 104