diff options
Diffstat (limited to 'experiments/prepare_bazel_test_env/data/static')
2 files changed, 69 insertions, 0 deletions
diff --git a/experiments/prepare_bazel_test_env/data/static/build/bazel/rules/cc_tf_test_launcher.sh b/experiments/prepare_bazel_test_env/data/static/build/bazel/rules/cc_tf_test_launcher.sh new file mode 100644 index 0000000..ffe2850 --- /dev/null +++ b/experiments/prepare_bazel_test_env/data/static/build/bazel/rules/cc_tf_test_launcher.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Launches a native CC test with Tradefed. The script expects the following: +# 1. adb is present on the path. +# 2. LD_LIBRARY_PATH is set for any libraries that need to be referenced. +# 3. script_help.sh is included in the runfiles. +# 4. TF_JAR_DIR and TF_PATH are set corresponding to the location of the +# Tradefed JARs and any associated libraries. +# 5. The Tradefed launch script, test_module (i.e. hello_world_tests), +# and test_path (i.e. platform_testing/tests/example/native) are provided +# as the first and second positional arguments respectively. + +TRADEFED_LAUNCHER=$1 +shift +TEST_MODULE=$1 +shift +TEST_PATH=$1 +shift + +exec $TRADEFED_LAUNCHER template/atest_local_min \ + --template:map test=atest \ + --tests-dir "$TEST_PATH" \ + --logcat-on-failure \ + --no-enable-granular-attempts \ + --no-early-device-release \ + --include-filter "$TEST_MODULE" \ + --skip-loading-config-jar \ + --log-level-display VERBOSE \ + --log-level VERBOSE \ + -n \ + --prioritize-host-config \ + --skip-host-arch-check \ + "$@"
\ No newline at end of file diff --git a/experiments/prepare_bazel_test_env/data/static/build/bazel/rules/tf_test_executable.sh.template b/experiments/prepare_bazel_test_env/data/static/build/bazel/rules/tf_test_executable.sh.template new file mode 100644 index 0000000..f48e4fa --- /dev/null +++ b/experiments/prepare_bazel_test_env/data/static/build/bazel/rules/tf_test_executable.sh.template @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Script that handles set up for test execution in a Bazel environment. +# This script sets the PATH, LD_LIBRARY_PATH, TF_PATH, and TF_JAR_DIR +# that the called launcher script uses to execute the test. + +BAZEL_BIN_WORK_DIR="$(dirname $0)/$0.runfiles/__main__/" + +# Use the directory corresponding to the current module for running, this +# ensures that when Tradefed scans for tests, only the tests +# that were included as a dependency to the rule are referenced. +TESTCASE_RELPATH="{module_path}" + +# Ensure that the test is executing from the top of the runfiles dir. +if [[ -d $BAZEL_BIN_WORK_DIR/$TESTCASE_RELPATH ]] +then + cd $BAZEL_BIN_WORK_DIR || exit 1 +fi + +# Verify we can find the Tradefed launch script. +ATEST_TRADEFED_LAUNCHER="{tradefed_launcher_module_path}/atest_tradefed.sh" +if ! [[ -f $ATEST_TRADEFED_LAUNCHER ]] +then + echo "ERROR: Cannot find Tradefed launch script" >&2 + exit 1 +fi + +# Set the required variables for the environment. +export PATH={adb_path}:$PATH +export LD_LIBRARY_PATH="$TESTCASE_RELPATH/lib:$TESTCASE_RELPATH/lib64:" +export TF_PATH="{tradefed_deps_module_path}/*" +export TF_JAR_DIR="{tradefed_deps_module_path}/" + +# Call the test launcher, passing the module name and testcase directory +# and any additional arguments. +exec {launcher_path} $ATEST_TRADEFED_LAUNCHER "{module_name}" "$TESTCASE_RELPATH" "$@"
\ No newline at end of file |