• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 cts-v-host
18# can be used from an Android build environment, or a standalone cts-v 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" \
30          "and ANDROID_BUILD_TOP is not defined."
31  exit 1
32fi
33
34source ${UTILS_SCRIPT}
35
36checkPath aapt2
37checkPath adb
38
39RDBG_FLAG=$(getRemoteDbgFlag)
40
41# get OS
42HOST=`uname`
43HOST_ARCH=`uname -sm`
44if [ "$HOST_ARCH" == "Linux x86_64" ]; then
45    OS="linux-x86"
46elif [ "$HOST_ARCH" == "Linux aarch64" ]; then
47    OS="linux-arm64"
48    # Bundled java is for linux-x86 so use host JDK on linux-arm64
49    JAVA_BINARY=java
50elif [[ "$HOST_ARCH" == *"Darwin"* ]]; then
51    OS="darwin"
52    # Bundled java is for linux so use host JDK on Darwin
53    JAVA_BINARY=java
54else
55    echo "Unrecognized OS"
56    exit
57fi
58
59# check if in Android build env
60if [ ! -z "${ANDROID_BUILD_TOP}" ]; then
61    if [ ! -z "${ANDROID_HOST_OUT}" ]; then
62      CTSV_HOST_ROOT=${ANDROID_HOST_OUT}/cts-v-host
63    else
64      CTSV_HOST_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/cts-v-host
65    fi
66    if [ ! -d ${CTSV_HOST_ROOT} ]; then
67        echo "Could not find $CTSV_HOST_ROOT in Android build environment. Try 'make cts-v-host'"
68        exit
69    fi;
70fi;
71
72if [ -z ${CTSV_HOST_ROOT} ]; then
73    # assume we're in an extracted cts-v install
74    CTSV_HOST_ROOT="$(dirname $(realpath $0))/../.."
75fi;
76
77if [ -z ${JAVA_BINARY} ]; then
78    JAVA_BINARY=${CTSV_HOST_ROOT}/android-cts-v-host/jdk/bin/java
79fi;
80
81if [ ! -f "${JAVA_BINARY}" ]; then
82    JAVA_BINARY=java
83fi
84
85checkPath ${JAVA_BINARY}
86
87# Java version on Mac not within our control, so let it be best effort
88if [ ${OS} != "darwin" ]; then
89    checkJavaVersion ${JAVA_BINARY}
90else
91    echo "Mac is not a fully supported OS, so Java version support will be best effort"
92fi
93
94loadSharedLibraries "$HOST"
95
96ATS_CONSOLE_JAR=${CTSV_HOST_ROOT}/android-cts-v-host/tools/ats_console_deploy.jar
97ATS_OLC_SERVER_JAR=${CTSV_HOST_ROOT}/android-cts-v-host/tools/ats_olc_server_local_mode_deploy.jar
98checkFile ${ATS_CONSOLE_JAR}
99checkFile ${ATS_OLC_SERVER_JAR}
100
101FASTBOOT_FLAGS=" \
102  --enable_fastboot_in_android_real_device=true \
103  --fastboot='$(type -P fastboot 2>/dev/null)' \
104"
105if ! type -P fastboot &> /dev/null; then
106    FASTBOOT_FLAGS="--enable_fastboot_in_android_real_device=false"
107fi;
108
109# Add a new variable to control the dynamic downloader
110ENABLE_XTS_DYNAMIC_DOWNLOADER=${ENABLE_XTS_DYNAMIC_DOWNLOADER:-"false"}
111
112DEVICE_INFRA_SERVICE_FLAGS=" \
113  --aapt='$(type -P aapt2 2>/dev/null)' \
114  --adb='$(type -P adb 2>/dev/null)' \
115  --ats_console_olc_server_path='${ATS_OLC_SERVER_JAR}' \
116  --enable_cts_verifier_result_reporter=true \
117  --enable_xts_dynamic_downloader=${ENABLE_XTS_DYNAMIC_DOWNLOADER} \
118  --public_dir=/tmp \
119  --simplified_log_format=true \
120  --tmp_dir_root=/tmp \
121  --xts_res_dir_root='${HOME}/xts' \
122  ${FASTBOOT_FLAGS} \
123"
124
125LANG=en_US.UTF-8 TEST_TMPDIR=/tmp ${JAVA_BINARY} --add-opens=java.base/java.lang=ALL-UNNAMED -Xmx4g -XX:+HeapDumpOnOutOfMemoryError -DXTS_ROOT=${CTSV_HOST_ROOT} -DXTS_TYPE=cts-v-host -DDEVICE_INFRA_SERVICE_FLAGS="${DEVICE_INFRA_SERVICE_FLAGS}" -jar ${ATS_CONSOLE_JAR} "$@"
126