Support java_data in sh_test_host
Bug: 297225342 Test: with a custom test rule Test: cd sh && go test ./... (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:de5d265a798ce0e12ad0a2d0a6675942df5cd10b) Merged-In: Ia5a60fa6d917f2c2fde56df543625024ec11877a Change-Id: Ia5a60fa6d917f2c2fde56df543625024ec11877a
This commit is contained in:
parent
4e6c42d417
commit
1725b20d14
3 changed files with 57 additions and 1 deletions
|
@ -10,6 +10,7 @@ bootstrap_go_package {
|
||||||
"soong",
|
"soong",
|
||||||
"soong-android",
|
"soong-android",
|
||||||
"soong-cc",
|
"soong-cc",
|
||||||
|
"soong-java",
|
||||||
"soong-tradefed",
|
"soong-tradefed",
|
||||||
],
|
],
|
||||||
srcs: [
|
srcs: [
|
||||||
|
|
|
@ -143,6 +143,9 @@ type TestProperties struct {
|
||||||
// Only available for host sh_test modules.
|
// Only available for host sh_test modules.
|
||||||
Data_device_libs []string `android:"path,arch_variant"`
|
Data_device_libs []string `android:"path,arch_variant"`
|
||||||
|
|
||||||
|
// list of java modules that provide data that should be installed alongside the test.
|
||||||
|
Java_data []string
|
||||||
|
|
||||||
// Install the test into a folder named for the module in all test suites.
|
// Install the test into a folder named for the module in all test suites.
|
||||||
Per_testcase_directory *bool
|
Per_testcase_directory *bool
|
||||||
|
|
||||||
|
@ -307,6 +310,7 @@ var (
|
||||||
shTestDataLibsTag = dependencyTag{name: "dataLibs"}
|
shTestDataLibsTag = dependencyTag{name: "dataLibs"}
|
||||||
shTestDataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
|
shTestDataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
|
||||||
shTestDataDeviceLibsTag = dependencyTag{name: "dataDeviceLibs"}
|
shTestDataDeviceLibsTag = dependencyTag{name: "dataDeviceLibs"}
|
||||||
|
shTestJavaDataTag = dependencyTag{name: "javaData"}
|
||||||
)
|
)
|
||||||
|
|
||||||
var sharedLibVariations = []blueprint.Variation{{Mutator: "link", Variation: "shared"}}
|
var sharedLibVariations = []blueprint.Variation{{Mutator: "link", Variation: "shared"}}
|
||||||
|
@ -322,6 +326,10 @@ func (s *ShTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
|
ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
|
||||||
ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),
|
ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),
|
||||||
shTestDataDeviceLibsTag, s.testProperties.Data_device_libs...)
|
shTestDataDeviceLibsTag, s.testProperties.Data_device_libs...)
|
||||||
|
|
||||||
|
javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
|
||||||
|
ctx.AddVariationDependencies(javaDataVariation, shTestJavaDataTag, s.testProperties.Java_data...)
|
||||||
|
|
||||||
} else if ctx.Target().Os.Class != android.Host {
|
} else if ctx.Target().Os.Class != android.Host {
|
||||||
if len(s.testProperties.Data_device_bins) > 0 {
|
if len(s.testProperties.Data_device_bins) > 0 {
|
||||||
ctx.PropertyErrorf("data_device_bins", "only available for host modules")
|
ctx.PropertyErrorf("data_device_bins", "only available for host modules")
|
||||||
|
@ -329,6 +337,9 @@ func (s *ShTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
if len(s.testProperties.Data_device_libs) > 0 {
|
if len(s.testProperties.Data_device_libs) > 0 {
|
||||||
ctx.PropertyErrorf("data_device_libs", "only available for host modules")
|
ctx.PropertyErrorf("data_device_libs", "only available for host modules")
|
||||||
}
|
}
|
||||||
|
if len(s.testProperties.Java_data) > 0 {
|
||||||
|
ctx.PropertyErrorf("Java_data", "only available for host modules")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +372,13 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
}
|
}
|
||||||
s.installedFile = ctx.InstallExecutable(s.installDir, s.outputFilePath.Base(), s.outputFilePath)
|
s.installedFile = ctx.InstallExecutable(s.installDir, s.outputFilePath.Base(), s.outputFilePath)
|
||||||
|
|
||||||
s.data = android.PathsForModuleSrc(ctx, s.testProperties.Data)
|
expandedData := android.PathsForModuleSrc(ctx, s.testProperties.Data)
|
||||||
|
|
||||||
|
// Emulate the data property for java_data dependencies.
|
||||||
|
for _, javaData := range ctx.GetDirectDepsWithTag(shTestJavaDataTag) {
|
||||||
|
expandedData = append(expandedData, android.OutputFilesForModule(ctx, javaData, "")...)
|
||||||
|
}
|
||||||
|
s.data = expandedData
|
||||||
|
|
||||||
var configs []tradefed.Config
|
var configs []tradefed.Config
|
||||||
if Bool(s.testProperties.Require_root) {
|
if Bool(s.testProperties.Require_root) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
|
"android/soong/java"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
@ -17,6 +18,7 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
var prepareForShTest = android.GroupFixturePreparers(
|
var prepareForShTest = android.GroupFixturePreparers(
|
||||||
cc.PrepareForTestWithCcBuildComponents,
|
cc.PrepareForTestWithCcBuildComponents,
|
||||||
|
java.PrepareForTestWithJavaDefaultModules,
|
||||||
PrepareForTestWithShBuildComponents,
|
PrepareForTestWithShBuildComponents,
|
||||||
android.FixtureMergeMockFs(android.MockFS{
|
android.FixtureMergeMockFs(android.MockFS{
|
||||||
"test.sh": nil,
|
"test.sh": nil,
|
||||||
|
@ -255,3 +257,39 @@ func TestShTestHost_dataDeviceModulesAutogenTradefedConfig(t *testing.T) {
|
||||||
t.Errorf("foo extraConfings %v does not contain %q", autogen.Args["extraConfigs"], expectedBinAutogenConfig)
|
t.Errorf("foo extraConfings %v does not contain %q", autogen.Args["extraConfigs"], expectedBinAutogenConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestShTestHost_javaData(t *testing.T) {
|
||||||
|
ctx, config := testShBinary(t, `
|
||||||
|
sh_test_host {
|
||||||
|
name: "foo",
|
||||||
|
src: "test.sh",
|
||||||
|
filename: "test.sh",
|
||||||
|
data: [
|
||||||
|
"testdata/data1",
|
||||||
|
"testdata/sub/data2",
|
||||||
|
],
|
||||||
|
java_data: [
|
||||||
|
"javalib",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library_host {
|
||||||
|
name: "javalib",
|
||||||
|
srcs: [],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
mod := ctx.ModuleForTests("foo", buildOS+"_x86_64").Module().(*ShTest)
|
||||||
|
if !mod.Host() {
|
||||||
|
t.Errorf("host bit is not set for a sh_test_host module.")
|
||||||
|
}
|
||||||
|
expectedData := []string{
|
||||||
|
":testdata/data1",
|
||||||
|
":testdata/sub/data2",
|
||||||
|
"out/soong/.intermediates/javalib/" + buildOS + "_common/combined/:javalib.jar",
|
||||||
|
}
|
||||||
|
|
||||||
|
entries := android.AndroidMkEntriesForTest(t, ctx, mod)[0]
|
||||||
|
actualData := entries.EntryMap["LOCAL_TEST_DATA"]
|
||||||
|
android.AssertStringPathsRelativeToTopEquals(t, "LOCAL_TEST_DATA", config, expectedData, actualData)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue