• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2set -e
3
4TEST_PATH="${TEST_SRCDIR}"
5SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6PATH_ADDITIONS="{PATH_ADDITIONS}"
7
8export PATH="$SCRIPT_DIR:${PATH}"
9# Prepend the REMOTE_JAVA_HOME environment variable to the path to ensure
10# that all Java invocations throughout the test execution flow use the same
11# version.
12if [ ! -z "${REMOTE_JAVA_HOME}" ]; then
13  export PATH="${REMOTE_JAVA_HOME}/bin:${PATH}"
14fi
15
16exit_code_file="$(mktemp /tmp/tf-exec-XXXXXXXXXX)"
17
18atest_tradefed.sh template/atest_local_min \
19    --template:map test=atest \
20    --template:map reporters="${SCRIPT_DIR}/result-reporters.xml" \
21    --tests-dir "$TEST_PATH" \
22    --logcat-on-failure \
23    --no-enable-granular-attempts \
24    --no-early-device-release \
25    --skip-host-arch-check \
26    --include-filter "{MODULE}" \
27    --skip-loading-config-jar \
28    "${ADDITIONAL_TRADEFED_OPTIONS[@]}" \
29    --bazel-exit-code-result-reporter:file=${exit_code_file} \
30    --bazel-xml-result-reporter:file=${XML_OUTPUT_FILE} \
31    --proto-output-file="${TEST_UNDECLARED_OUTPUTS_DIR}/proto-results" \
32    --log-file-path="${TEST_UNDECLARED_OUTPUTS_DIR}" \
33    "$@"
34
35# Use the TF exit code if it terminates abnormally.
36tf_exit=$?
37if [ ${tf_exit} -ne 0 ]
38then
39     echo "Tradefed command failed with exit code ${tf_exit}"
40     exit ${tf_exit}
41fi
42
43# Set the exit code based on the exit code in the reporter-generated file.
44exit_code=$(<${exit_code_file})
45if [ $? -ne 0 ]
46then
47  echo "Could not read exit code file: ${exit_code_file}"
48  exit 36
49fi
50
51if [ ${exit_code} -ne 0 ]
52then
53  echo "Test failed with exit code ${exit_code}"
54  exit ${exit_code}
55fi
56