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
This commit is contained in:
Sam Delmerico
2022-01-20 21:10:28 +00:00
parent 1e698865b5
commit b3342ce580
4 changed files with 140 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"android/soong/android"
@@ -215,3 +216,40 @@ func TestShTestHost_dataDeviceModules(t *testing.T) {
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)
}
}