From 2d913d2e4e677a04139166074eabfd776bbc953f Mon Sep 17 00:00:00 2001 From: Karl Shaffer Date: Wed, 28 Apr 2021 15:41:15 -0400 Subject: Enables --host flag for Local TF runs The cc_tf_test_launcher now checks the next positional argument for a --host flag and adds the corresponding flags to the TradeFed execution. This flag approach mimics how ATest currently handles host/device tests. Test: Manual testing, through the following steps: bazel run //build/pesto/experiments/prepare_bazel_test_env -- generate bazel run //build/pesto/experiments/prepare_bazel_test_env -- sync (For host side test) bazel test //platform_testing/tests/example/native:hello_world_test --test_output=all --test_arg=--host (For device side test, requiring a device connected and lunch selecting the correct build target) bazel test //platform_testing/tests/example/native:hello_world_test --test_output=all Change-Id: I3b92a2551a1a9d272c45cd5047f5a764d8a849c7 --- .../static/build/bazel/rules/cc_tf_test_launcher.sh | 9 ++++++--- .../tests/example/native/BUILD.bazel.template | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 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 index ffe2850..2dc64ca 100644 --- 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 @@ -17,6 +17,11 @@ shift TEST_PATH=$1 shift +if [ $1 != "" ] && [ $1 == "--host" ]; then + HOST_ARGS=(-n --prioritize-host-config --skip-host-arch-check) + shift +fi + exec $TRADEFED_LAUNCHER template/atest_local_min \ --template:map test=atest \ --tests-dir "$TEST_PATH" \ @@ -27,7 +32,5 @@ exec $TRADEFED_LAUNCHER template/atest_local_min \ --skip-loading-config-jar \ --log-level-display VERBOSE \ --log-level VERBOSE \ - -n \ - --prioritize-host-config \ - --skip-host-arch-check \ + "${HOST_ARGS[@]}" \ "$@" \ No newline at end of file diff --git a/experiments/prepare_bazel_test_env/data/templates/platform_testing/tests/example/native/BUILD.bazel.template b/experiments/prepare_bazel_test_env/data/templates/platform_testing/tests/example/native/BUILD.bazel.template index 4c7e3e0..6d4a026 100644 --- a/experiments/prepare_bazel_test_env/data/templates/platform_testing/tests/example/native/BUILD.bazel.template +++ b/experiments/prepare_bazel_test_env/data/templates/platform_testing/tests/example/native/BUILD.bazel.template @@ -25,18 +25,24 @@ _LIB_SRCS = glob([ "{prebuilts_dir_name}/host/lib/**/*", "{prebuilts_dir_name}/host/lib64/**/*" ]) -_TESTCASE_SRCS = glob( +_TESTCASE_HOST_SRCS = glob( ["{prebuilts_dir_name}/host/testcases/hello_world_test/**/*"]) +_TESTCASE_DEVICE_SRCS = glob(["{prebuilts_dir_name}/target_testcases/hello_world_test/**/*"]) _LIB_OUTS = [f.replace("{prebuilts_dir_name}/host/", "") for f in _LIB_SRCS] -_TESTCASE_OUTS = [ - f.replace("{prebuilts_dir_name}/host/testcases/hello_world_test/", "") - for f in _TESTCASE_SRCS +_TESTCASE_HOST_OUTS = [ + f.replace("{prebuilts_dir_name}/host/testcases/hello_world_test/", "host/") + for f in _TESTCASE_HOST_SRCS ] +_TESTCASE_DEVICE_OUTS = [ + f.replace("{prebuilts_dir_name}/target_testcases/hello_world_test/", "device/") + for f in _TESTCASE_DEVICE_SRCS +] + genrule(name="hello_world_test_prebuilt", - srcs=_LIB_SRCS + _TESTCASE_SRCS, - outs=_LIB_OUTS + _TESTCASE_OUTS, + srcs=_LIB_SRCS + _TESTCASE_HOST_SRCS + _TESTCASE_DEVICE_SRCS, + outs=_LIB_OUTS + _TESTCASE_HOST_OUTS + _TESTCASE_DEVICE_OUTS, cmd=""" src_files=($(SRCS)) out_files=($(OUTS)) -- cgit v1.2.3