1#!/usr/bin/env bash 2 3# Copyright (C) 2015 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# A helper script that launches Trade Federation for atest 18if [[ -z "${ATEST_HELPER}" ]]; then 19 ATEST_HELPER="$(dirname $0)/atest_script_help.sh" 20fi 21source $ATEST_HELPER 22 23# TODO b/63295046 (sbasi) - Remove this when LOCAL_JAVA_LIBRARIES includes 24# installation. 25# Include any host-side dependency jars. 26if [[ ! -z "$ANDROID_HOST_OUT" ]]; then 27 # TF will load the first test-suite-info.properties in those jar files it loaded. 28 # In current cases that only those *ts suite jars have built in that file. 29 # If user tested testcases which using those jar files with suite-info properties 30 # but change the lunch target to different arch and continue testing other tests without the 31 # need of those *ts jars then TF will not testing with below error message: 32 # "None of the abi supported by this tests suite build". 33 # Create atest-tradefed.jar with test-suite-info.properties and make sure it's priroty is higher 34 # then other *ts-tradefed.jar. 35 deps="atest-tradefed.jar 36 compatibility-host-util.jar 37 hamcrest-library.jar 38 hosttestlib.jar 39 cts-tradefed.jar 40 sts-tradefed.jar 41 vts-tradefed.jar 42 csuite-harness.jar 43 tradefed-isolation.jar 44 host-libprotobuf-java-full.jar 45 cts-dalvik-host-test-runner.jar 46 compatibility-tradefed.jar" 47 for dep in $deps; do 48 if [ -f "$ANDROID_HOST_OUT/framework/$dep" ]; then 49 TF_PATH+=":$ANDROID_HOST_OUT/framework/$dep" 50 fi 51 done 52fi 53 54# Accumulate prebuilt jars as a part of classpath when the configurations are 55# packaged into a prebuilt jar (b/192046472) 56TF_CORE_DIR=$ANDROID_BUILD_TOP/tools/tradefederation/core 57if [ ! -d $TF_CORE_DIR ]; then 58 TF_DIR=$ANDROID_BUILD_TOP/tools/tradefederation/prebuilts/filegroups 59 GTF_DIR=$ANDROID_BUILD_TOP/vendor/google_tradefederation/prebuilts/filegroups 60 PREBUILT_JARS=$(find $TF_DIR $GTF_DIR -type f -name '*.jar' 2>/dev/null) 61 if [ -n "$PREBUILT_JARS" ]; then 62 for jar in $PREBUILT_JARS; do 63 TF_PATH+=":$jar" 64 done 65 fi 66fi 67 68if [ "$(uname)" == "Darwin" ]; then 69 local_tmp_dir="$ANDROID_HOST_OUT/tmp" 70 [[ -f "$local_tmp_dir" ]] || mkdir -p "$local_tmp_dir" 71 java_tmp_dir_opt="-Djava.io.tmpdir=$local_tmp_dir" 72fi 73 74# Override the TF classpath with the minimal set of jars that correspond to the 75# tests being run. This only happens when the Atest `--minimal-build` flag is 76# enabled. 77# TODO(b/283352284): Remove unnecessary entries once --minimal-build is the 78# default. 79if [ -n "${ATEST_HOST_JARS}" ]; then 80 echo "Replaced TF_PATH from ${TF_PATH} to ${ATEST_HOST_JARS}" 81 TF_PATH=${ATEST_HOST_JARS} 82fi 83 84# Customize TF related settings for ATest local run to align with test runs on 85# CI. 86extra_settings=" 87 --test-arg com.android.tradefed.testtype.python.PythonBinaryHostTest:python-options:-vv" 88 89 90# Note: must leave $RDBG_FLAG and $TRADEFED_OPTS unquoted so that they go away when unset 91LOCAL_MODE=1 START_FEATURE_SERVER=1 ${TF_JAVA} $RDBG_FLAG \ 92 -XX:+HeapDumpOnOutOfMemoryError \ 93 -XX:-OmitStackTraceInFastThrow \ 94 $TRADEFED_OPTS \ 95 -cp "${TF_PATH}" \ 96 -DTF_JAR_DIR=${TF_JAR_DIR} ${java_tmp_dir_opt} \ 97 com.android.tradefed.command.CommandRunner "$@" $extra_settings 98