build device binary for java_test_host
This commit adds support for a java_host_test that requires a target
binary to run. If the binary has host and target variants and is added
as a dependency in the `data` attribute, then the host variant is used.
Instead, we need a way to force the use of the target variant.
Bug: 182919153
Test: add code from aosp/1647282/1 && atest AuthFsHostTest
Change-Id: I68a6259b41a5e6809e1b82eec3122ffdf5067f56
diff --git a/sh/sh_binary_test.go b/sh/sh_binary_test.go
index 28b6fb9..7fe1d85 100644
--- a/sh/sh_binary_test.go
+++ b/sh/sh_binary_test.go
@@ -4,6 +4,7 @@
"os"
"path/filepath"
"strconv"
+ "strings"
"testing"
"android/soong/android"
@@ -215,3 +216,40 @@
actualData := entries.EntryMap["LOCAL_TEST_DATA"]
android.AssertStringPathsRelativeToTopEquals(t, "LOCAL_TEST_DATA", config, expectedData, actualData)
}
+
+func TestShTestHost_dataDeviceModulesAutogenTradefedConfig(t *testing.T) {
+ ctx, config := testShBinary(t, `
+ sh_test_host {
+ name: "foo",
+ src: "test.sh",
+ data_device_bins: ["bar"],
+ data_device_libs: ["libbar"],
+ }
+
+ cc_binary {
+ name: "bar",
+ shared_libs: ["libbar"],
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library {
+ name: "libbar",
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ buildOS := config.BuildOS.String()
+ fooModule := ctx.ModuleForTests("foo", buildOS+"_x86_64")
+
+ expectedBinAutogenConfig := `<option name="push-file" key="bar" value="/data/local/tests/unrestricted/foo/bar" />`
+ autogen := fooModule.Rule("autogen")
+ if !strings.Contains(autogen.Args["extraConfigs"], expectedBinAutogenConfig) {
+ t.Errorf("foo extraConfings %v does not contain %q", autogen.Args["extraConfigs"], expectedBinAutogenConfig)
+ }
+}