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
18source "$(dirname $0)/script_help.sh"
19
20# TODO b/63295046 (sbasi) - Remove this when LOCAL_JAVA_LIBRARIES includes
21# installation.
22# Include any host-side dependency jars.
23if [[ ! -z "$ANDROID_HOST_OUT" ]]; then
24    # TF will load the first test-suite-info.properties in those jar files it loaded.
25    # In current cases that only those *ts suite jars have built in that file.
26    # If user tested testcases which using those jar files with suite-info properties
27    # but change the lunch target to different arch and continue testing other tests without the
28    # need of those *ts jars then TF will not testing with below error message:
29    # "None of the abi supported by this tests suite build".
30    # Create atest-tradefed.jar with test-suite-info.properties and make sure it's priroty is higher
31    # then other *ts-tradefed.jar.
32    deps="atest-tradefed.jar
33          compatibility-host-util.jar
34          hosttestlib.jar
35          cts-tradefed.jar
36          sts-tradefed.jar
37          vts-tradefed.jar
38          vts10-tradefed.jar
39          csuite-harness.jar
40          tradefed-isolation.jar
41          host-libprotobuf-java-full.jar
42          cts-dalvik-host-test-runner.jar"
43    for dep in $deps; do
44        if [ -f "$ANDROID_HOST_OUT/framework/$dep" ]; then
45          TF_PATH+=":$ANDROID_HOST_OUT/framework/$dep"
46        fi
47    done
48fi
49
50if [ "$(uname)" == "Darwin" ]; then
51    local_tmp_dir="$ANDROID_HOST_OUT/tmp"
52    [[ -f "$local_tmp_dir" ]] || mkdir -p "$local_tmp_dir"
53    java_tmp_dir_opt="-Djava.io.tmpdir=$local_tmp_dir"
54fi
55
56# Note: must leave $RDBG_FLAG and $TRADEFED_OPTS unquoted so that they go away when unset
57java $RDBG_FLAG \
58    -XX:+HeapDumpOnOutOfMemoryError \
59    -XX:-OmitStackTraceInFastThrow \
60    $TRADEFED_OPTS \
61    -cp ${TF_PATH} \
62    -DTF_JAR_DIR=${TF_JAR_DIR} ${java_tmp_dir_opt} \
63    com.android.tradefed.command.CommandRunner "$@"
64