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:
38
java/java.go
38
java/java.go
@@ -325,6 +325,7 @@ func IsJniDepTag(depTag blueprint.DependencyTag) bool {
|
||||
|
||||
var (
|
||||
dataNativeBinsTag = dependencyTag{name: "dataNativeBins"}
|
||||
dataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
|
||||
staticLibTag = dependencyTag{name: "staticlib"}
|
||||
libTag = dependencyTag{name: "javalib", runtimeLinked: true}
|
||||
java9LibTag = dependencyTag{name: "java9lib", runtimeLinked: true}
|
||||
@@ -837,6 +838,9 @@ type testProperties struct {
|
||||
type hostTestProperties struct {
|
||||
// list of native binary modules that should be installed alongside the test
|
||||
Data_native_bins []string `android:"arch_variant"`
|
||||
|
||||
// list of device binary modules that should be installed alongside the test
|
||||
Data_device_bins []string `android:"arch_variant"`
|
||||
}
|
||||
|
||||
type testHelperLibraryProperties struct {
|
||||
@@ -910,6 +914,11 @@ func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(j.testHostProperties.Data_device_bins) > 0 {
|
||||
deviceVariations := ctx.Config().AndroidFirstDeviceTarget.Variations()
|
||||
ctx.AddFarVariationDependencies(deviceVariations, dataDeviceBinsTag, j.testHostProperties.Data_device_bins...)
|
||||
}
|
||||
|
||||
if len(j.testProperties.Jni_libs) > 0 {
|
||||
for _, target := range ctx.MultiTargets() {
|
||||
sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
|
||||
@@ -924,14 +933,35 @@ func (j *TestHost) AddExtraResource(p android.Path) {
|
||||
j.extraResources = append(j.extraResources, p)
|
||||
}
|
||||
|
||||
func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
var configs []tradefed.Config
|
||||
if len(j.testHostProperties.Data_device_bins) > 0 {
|
||||
// add Tradefed configuration to push device bins to device for testing
|
||||
remoteDir := filepath.Join("/data/local/tests/unrestricted/", j.Name())
|
||||
options := []tradefed.Option{{Name: "cleanup", Value: "true"}}
|
||||
for _, bin := range j.testHostProperties.Data_device_bins {
|
||||
fullPath := filepath.Join(remoteDir, bin)
|
||||
options = append(options, tradefed.Option{Name: "push-file", Key: bin, Value: fullPath})
|
||||
}
|
||||
configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.PushFilePreparer", options})
|
||||
}
|
||||
|
||||
j.Test.generateAndroidBuildActionsWithConfig(ctx, configs)
|
||||
}
|
||||
|
||||
func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.generateAndroidBuildActionsWithConfig(ctx, nil)
|
||||
}
|
||||
|
||||
func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, configs []tradefed.Config) {
|
||||
if j.testProperties.Test_options.Unit_test == nil && ctx.Host() {
|
||||
// TODO(b/): Clean temporary heuristic to avoid unexpected onboarding.
|
||||
defaultUnitTest := !inList("tradefed", j.properties.Libs) && !inList("cts", j.testProperties.Test_suites)
|
||||
j.testProperties.Test_options.Unit_test = proptools.BoolPtr(defaultUnitTest)
|
||||
}
|
||||
|
||||
j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template,
|
||||
j.testProperties.Test_suites, j.testProperties.Auto_gen_config, j.testProperties.Test_options.Unit_test)
|
||||
j.testProperties.Test_suites, configs, j.testProperties.Auto_gen_config, j.testProperties.Test_options.Unit_test)
|
||||
|
||||
j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
|
||||
|
||||
@@ -941,6 +971,10 @@ func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.data = append(j.data, android.OutputFileForModule(ctx, dep, ""))
|
||||
})
|
||||
|
||||
ctx.VisitDirectDepsWithTag(dataDeviceBinsTag, func(dep android.Module) {
|
||||
j.data = append(j.data, android.OutputFileForModule(ctx, dep, ""))
|
||||
})
|
||||
|
||||
ctx.VisitDirectDepsWithTag(jniLibTag, func(dep android.Module) {
|
||||
sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo)
|
||||
if sharedLibInfo.SharedLibrary != nil {
|
||||
@@ -973,7 +1007,7 @@ func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContex
|
||||
|
||||
func (j *JavaTestImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.prebuiltTestProperties.Test_config, nil,
|
||||
j.prebuiltTestProperties.Test_suites, nil, nil)
|
||||
j.prebuiltTestProperties.Test_suites, nil, nil, nil)
|
||||
|
||||
j.Import.GenerateAndroidBuildActions(ctx)
|
||||
}
|
||||
|
Reference in New Issue
Block a user