1#!/bin/bash 2# 3# Script that handles set up for test execution in a Bazel environment. 4# This script sets the PATH, LD_LIBRARY_PATH, TF_PATH, and TF_JAR_DIR 5# that the called launcher script uses to execute the test. 6 7BAZEL_BIN_WORK_DIR="$(dirname $0)/$0.runfiles/__main__/" 8 9# Use the directory corresponding to the current module for running, this 10# ensures that when Tradefed scans for tests, only the tests 11# that were included as a dependency to the rule are referenced. 12TESTCASE_RELPATH="{module_path}" 13 14# Ensure that the test is executing from the top of the runfiles dir. 15if [[ -d $BAZEL_BIN_WORK_DIR/$TESTCASE_RELPATH ]] 16then 17 cd $BAZEL_BIN_WORK_DIR || exit 1 18fi 19 20# Verify we can find the Tradefed launch script. 21ATEST_TRADEFED_LAUNCHER="{tradefed_launcher_module_path}/atest_tradefed.sh" 22if ! [[ -f $ATEST_TRADEFED_LAUNCHER ]] 23then 24 echo "ERROR: Cannot find Tradefed launch script" >&2 25 exit 1 26fi 27 28# Set the required variables for the environment. 29export PATH={adb_path}:$PATH 30export LD_LIBRARY_PATH="$TESTCASE_RELPATH/lib:$TESTCASE_RELPATH/lib64:" 31export TF_PATH="{tradefed_deps_module_path}/*" 32export TF_JAR_DIR="{tradefed_deps_module_path}/" 33 34# Call the test launcher, passing the module name and testcase directory 35# and any additional arguments. 36exec {launcher_path} $ATEST_TRADEFED_LAUNCHER "{module_name}" "$TESTCASE_RELPATH" "$@"