118 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
			
		
		
	
	
			118 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
| #!/bin/bash
 | |
| 
 | |
| # Copyright (C) 2019 The Android Open Source Project.
 | |
| #
 | |
| # Licensed under the Apache License, Version 2.0 (the "License");
 | |
| # you may not use this file except in compliance with the License.
 | |
| # You may obtain a copy of the License at
 | |
| #
 | |
| #       http://www.apache.org/licenses/LICENSE-2.0
 | |
| #
 | |
| # Unless required by applicable law or agreed to in writing, software
 | |
| # distributed under the License is distributed on an "AS IS" BASIS,
 | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| # See the License for the specific language governing permissions and
 | |
| # limitations under the License.
 | |
| 
 | |
| # launcher script for mts-tradefed harness
 | |
| # can be used from an Android build environment, or a standalone mts zip
 | |
| 
 | |
| checkFile() {
 | |
|     if [ ! -f "$1" ]; then
 | |
|         echo "Unable to locate $1"
 | |
|         exit
 | |
|     fi;
 | |
| }
 | |
| 
 | |
| checkPath() {
 | |
|     if ! type -P $1 &> /dev/null; then
 | |
|         echo "Unable to find $1 in path."
 | |
|         exit
 | |
|     fi;
 | |
| }
 | |
| 
 | |
| checkPath adb
 | |
| checkPath java
 | |
| 
 | |
| # check java version
 | |
| JAVA_VERSION=$(java -version 2>&1 | head -n 1 | grep 'version [ "]\(1\.8\|9\|11\|17\).*[ "]')
 | |
| if [ "${JAVA_VERSION}" == "" ]; then
 | |
|     echo "Wrong java version. 1.8, 9, 11, or 17 is required."
 | |
|     exit
 | |
| fi
 | |
| 
 | |
| # check debug flag and set up remote debugging
 | |
| if [ -n "${TF_DEBUG}" ]; then
 | |
|   if [ -z "${TF_DEBUG_PORT}" ]; then
 | |
|     TF_DEBUG_PORT=10088
 | |
|   fi
 | |
|   RDBG_FLAG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${TF_DEBUG_PORT}
 | |
| fi
 | |
| 
 | |
| # get OS
 | |
| HOST=`uname`
 | |
| if [ "$HOST" == "Linux" ]; then
 | |
|     OS="linux-x86"
 | |
| elif [ "$HOST" == "Darwin" ]; then
 | |
|     OS="darwin-x86"
 | |
| else
 | |
|     echo "Unrecognized OS"
 | |
|     exit
 | |
| fi
 | |
| 
 | |
| # check if in Android build env
 | |
| if [ ! -z "${ANDROID_BUILD_TOP}" ]; then
 | |
|     if [ ! -z "${ANDROID_HOST_OUT}" ]; then
 | |
|       MTS_ROOT=${ANDROID_HOST_OUT}/mts
 | |
|     else
 | |
|       MTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/mts
 | |
|     fi
 | |
|     if [ ! -d ${MTS_ROOT} ]; then
 | |
|         echo "Could not find $MTS_ROOT in Android build environment. Try 'make mts'"
 | |
|         exit
 | |
|     fi;
 | |
| fi;
 | |
| 
 | |
| if [ -z ${MTS_ROOT} ]; then
 | |
|     # assume we're in an extracted mts install
 | |
|     MTS_ROOT="$(dirname $0)/../.."
 | |
| fi;
 | |
| 
 | |
| JAR_DIR=${MTS_ROOT}/android-mts/tools
 | |
| 
 | |
| for JAR in ${JAR_DIR}/*.jar; do
 | |
|     JAR_PATH=${JAR_PATH}:${JAR}
 | |
| done
 | |
| 
 | |
| # check if APE_API_KEY is set in the env by user.
 | |
| if [ ! -n "${APE_API_KEY}" ]; then
 | |
|     GTS_GOOGLE_SERVICE_ACCOUNT=${ANDROID_BUILD_TOP}/vendor/xts/tools/gts-google-service-account/gts-google-service-account.json
 | |
|     # set KEY only for google if APE_API_KEY isn't set and GTS_GOOGLE_SERVICE_ACCOUNT exists in the soure tree.
 | |
|     if [ -f "$GTS_GOOGLE_SERVICE_ACCOUNT" ]; then
 | |
|         APE_API_KEY=${GTS_GOOGLE_SERVICE_ACCOUNT}
 | |
|         export APE_API_KEY
 | |
|     else
 | |
|         echo "APE_API_KEY not set, GTS tests may fail without authentication."
 | |
|     fi;
 | |
| fi;
 | |
| echo "APE_API_KEY: $APE_API_KEY"
 | |
| 
 | |
| # load any shared libraries for host-side executables
 | |
| LIB_DIR=${MTS_ROOT}/android-mts/lib
 | |
| if [ "$HOST" == "Linux" ]; then
 | |
|     LD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${LD_LIBRARY_PATH}
 | |
|     export LD_LIBRARY_PATH
 | |
| elif [ "$HOST" == "Darwin" ]; then
 | |
|     DYLD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${DYLD_LIBRARY_PATH}
 | |
|     export DYLD_LIBRARY_PATH
 | |
| fi
 | |
| 
 | |
| # include any host-side test jars
 | |
| for j in ${MTS_ROOT}/android-mts/testcases/*.jar; do
 | |
|     JAR_PATH=${JAR_PATH}:$j
 | |
| done
 | |
| 
 | |
| java $RDBG_FLAG -cp ${JAR_PATH} -DMTS_ROOT=${MTS_ROOT} com.android.compatibility.common.tradefed.command.CompatibilityConsole "$@"
 | |
| 
 | |
| 
 |