• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2set -e
3set -x
4
5TEST_MODULE="{module_name}"
6TEST_PATH="{tradefed_test_dir}"
7ATEST_TF_LAUNCHER="{atest_tradefed_launcher}"
8ATEST_HELPER="{atest_helper}"
9SHARED_LIB_DIRS="{shared_lib_dirs}"
10PATH_ADDITIONS="{path_additions}"
11TRADEFED_CLASSPATH="{tradefed_classpath}"
12RESULT_REPORTERS_CONFIG_FILE="{result_reporters_config_file}"
13ATEST_JAVA_HOME="{atest_java_home}"
14read -a ADDITIONAL_TRADEFED_OPTIONS <<< "{additional_tradefed_options}"
15
16# Export variables expected by the Atest launcher script.
17export LD_LIBRARY_PATH="${SHARED_LIB_DIRS}"
18export TF_PATH="${TRADEFED_CLASSPATH}"
19export PATH="${PATH_ADDITIONS}:${PATH}"
20export ATEST_HELPER="${ATEST_HELPER}"
21export JAVA_HOME="${ATEST_JAVA_HOME}"
22
23exit_code_file="$(mktemp /tmp/tf-exec-XXXXXXXXXX)"
24
25"${ATEST_TF_LAUNCHER}" template/atest_local_min \
26    --template:map test=atest \
27    --template:map reporters="${RESULT_REPORTERS_CONFIG_FILE}" \
28    --tests-dir "${TEST_PATH}" \
29    --logcat-on-failure \
30    --no-enable-granular-attempts \
31    --no-early-device-release \
32    --include-filter "${TEST_MODULE}" \
33    --skip-loading-config-jar \
34    --log-level-display VERBOSE \
35    --log-level VERBOSE \
36    "${ADDITIONAL_TRADEFED_OPTIONS[@]}" \
37    --bazel-exit-code-result-reporter:file=${exit_code_file} \
38    --bazel-xml-result-reporter:file=${XML_OUTPUT_FILE} \
39    --proto-output-file="${TEST_UNDECLARED_OUTPUTS_DIR}/proto-results" \
40    --use-delimited-api=true \
41    --log-file-path="${TEST_UNDECLARED_OUTPUTS_DIR}" \
42    --compress-files=false \
43    "$@"
44
45# Use the TF exit code if it terminates abnormally.
46tf_exit=$?
47if [ ${tf_exit} -ne 0 ]
48then
49     echo "Tradefed command failed with exit code ${tf_exit}"
50     exit ${tf_exit}
51fi
52
53# Set the exit code based on the exit code in the reporter-generated file.
54exit_code=$(<${exit_code_file})
55if [ $? -ne 0 ]
56then
57  echo "Could not read exit code file: ${exit_code_file}"
58  exit 36
59fi
60
61if [ ${exit_code} -ne 0 ]
62then
63  echo "Test failed with exit code ${exit_code}"
64  exit ${exit_code}
65fi
66