Loading java/app.go +12 −1 Original line number Diff line number Diff line Loading @@ -1465,8 +1465,9 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_common_data)...) a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_data)...) a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_prefer32_data)...) android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{ InstalledFiles: a.data, TestcaseRelDataFiles: testcaseRel(a.data), OutputFile: a.OutputFile(), TestConfig: a.testConfig, HostRequiredModuleNames: a.HostRequiredModuleNames(), Loading @@ -1474,6 +1475,8 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { IsHost: false, LocalCertificate: a.certificate.AndroidMkString(), IsUnitTest: Bool(a.testProperties.Test_options.Unit_test), MkInclude: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", MkAppClass: "APPS", }) android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{ TestOnly: true, Loading @@ -1482,6 +1485,14 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { } func testcaseRel(paths android.Paths) []string { relPaths := []string{} for _, p := range paths { relPaths = append(relPaths, p.Rel()) } return relPaths } func (a *AndroidTest) FixTestConfig(ctx android.ModuleContext, testConfig android.Path) android.Path { if testConfig == nil { return nil Loading java/java.go +10 −8 Original line number Diff line number Diff line Loading @@ -1557,7 +1557,7 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.Test.generateAndroidBuildActionsWithConfig(ctx, configs) android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{ InstalledFiles: j.data, TestcaseRelDataFiles: testcaseRel(j.data), OutputFile: j.outputFile, TestConfig: j.testConfig, RequiredModuleNames: j.RequiredModuleNames(ctx), Loading @@ -1565,6 +1565,8 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) { IsHost: true, LocalSdkVersion: j.sdkVersion.String(), IsUnitTest: Bool(j.testProperties.Test_options.Unit_test), MkInclude: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", MkAppClass: "JAVA_LIBRARIES", }) } Loading sh/sh_binary.go +32 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package sh import ( "fmt" "path/filepath" "strings" Loading Loading @@ -164,6 +165,9 @@ type TestProperties struct { // Test options. Test_options android.CommonTestOptions // a list of extra test configuration files that should be installed with the module. Extra_test_configs []string `android:"path,arch_variant"` } type ShBinary struct { Loading @@ -188,6 +192,7 @@ type ShTest struct { data []android.DataPath testConfig android.Path extraTestConfigs android.Paths dataModules map[string]android.Path } Loading Loading @@ -471,6 +476,7 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { HostTemplate: "${ShellTestConfigTemplate}", }) s.extraTestConfigs = android.PathsForModuleSrc(ctx, s.testProperties.Extra_test_configs) s.dataModules = make(map[string]android.Path) ctx.VisitDirectDeps(func(dep android.Module) { depTag := ctx.OtherModuleDependencyTag(dep) Loading Loading @@ -510,6 +516,27 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { installedData := ctx.InstallTestData(s.installDir, s.data) s.installedFile = ctx.InstallExecutable(s.installDir, s.outputFilePath.Base(), s.outputFilePath, installedData...) mkEntries := s.AndroidMkEntries()[0] android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{ TestcaseRelDataFiles: addArch(ctx.Arch().ArchType.String(), installedData.Paths()), OutputFile: s.outputFilePath, TestConfig: s.testConfig, TestSuites: s.testProperties.Test_suites, IsHost: false, IsUnitTest: Bool(s.testProperties.Test_options.Unit_test), MkInclude: mkEntries.Include, MkAppClass: mkEntries.Class, InstallDir: s.installDir, }) } func addArch(archType string, paths android.Paths) []string { archRelPaths := []string{} for _, p := range paths { archRelPaths = append(archRelPaths, fmt.Sprintf("%s/%s", archType, p.Rel())) } return archRelPaths } func (s *ShTest) InstallInData() bool { Loading @@ -533,6 +560,9 @@ func (s *ShTest) AndroidMkEntries() []android.AndroidMkEntries { entries.AddStrings("LOCAL_TEST_DATA_BINS", s.testProperties.Data_bins...) } entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(s.testProperties.Per_testcase_directory)) if len(s.extraTestConfigs) > 0 { entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", s.extraTestConfigs.Strings()...) } s.testProperties.Test_options.SetAndroidMkEntries(entries) }, Loading sh/sh_binary_test.go +16 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,22 @@ func TestShTestHost(t *testing.T) { android.AssertBoolEquals(t, "LOCAL_IS_UNIT_TEST", true, actualData) } func TestShTestExtraTestConfig(t *testing.T) { result, _ := testShBinary(t, ` sh_test { name: "foo", src: "test.sh", filename: "test.sh", extra_test_configs: ["config1.xml", "config2.xml"], } `) mod := result.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest) entries := android.AndroidMkEntriesForTest(t, result, mod)[0] actualData := entries.EntryMap["LOCAL_EXTRA_FULL_TEST_CONFIGS"] android.AssertStringPathsRelativeToTopEquals(t, "extra_configs", result.Config(), []string{"config1.xml", "config2.xml"}, actualData) } func TestShTestHost_dataDeviceModules(t *testing.T) { ctx, config := testShBinary(t, ` sh_test_host { Loading tradefed/providers.go +8 −2 Original line number Diff line number Diff line Loading @@ -9,8 +9,8 @@ import ( // Data that test_module_config[_host] modules types will need from // their dependencies to write out build rules and AndroidMkEntries. type BaseTestProviderData struct { // data files and apps for android_test InstalledFiles android.Paths // data files and apps installed for tests, relative to testcases dir. TestcaseRelDataFiles []string // apk for android_test OutputFile android.Path // Either handwritten or generated TF xml. Loading @@ -28,6 +28,12 @@ type BaseTestProviderData struct { LocalCertificate string // Indicates if the base module was a unit test. IsUnitTest bool // The .mk file is used AndroidMkEntries for base (soong_java_prebuilt, etc.) MkInclude string // The AppClass to use for the AndroidMkEntries for the base. MkAppClass string // value for LOCAL_MODULE_PATH. The directory where the module is installed. InstallDir android.InstallPath } var BaseTestProviderKey = blueprint.NewProvider[BaseTestProviderData]() Loading
java/app.go +12 −1 Original line number Diff line number Diff line Loading @@ -1465,8 +1465,9 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_common_data)...) a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_data)...) a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_prefer32_data)...) android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{ InstalledFiles: a.data, TestcaseRelDataFiles: testcaseRel(a.data), OutputFile: a.OutputFile(), TestConfig: a.testConfig, HostRequiredModuleNames: a.HostRequiredModuleNames(), Loading @@ -1474,6 +1475,8 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { IsHost: false, LocalCertificate: a.certificate.AndroidMkString(), IsUnitTest: Bool(a.testProperties.Test_options.Unit_test), MkInclude: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", MkAppClass: "APPS", }) android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{ TestOnly: true, Loading @@ -1482,6 +1485,14 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { } func testcaseRel(paths android.Paths) []string { relPaths := []string{} for _, p := range paths { relPaths = append(relPaths, p.Rel()) } return relPaths } func (a *AndroidTest) FixTestConfig(ctx android.ModuleContext, testConfig android.Path) android.Path { if testConfig == nil { return nil Loading
java/java.go +10 −8 Original line number Diff line number Diff line Loading @@ -1557,7 +1557,7 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.Test.generateAndroidBuildActionsWithConfig(ctx, configs) android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{ InstalledFiles: j.data, TestcaseRelDataFiles: testcaseRel(j.data), OutputFile: j.outputFile, TestConfig: j.testConfig, RequiredModuleNames: j.RequiredModuleNames(ctx), Loading @@ -1565,6 +1565,8 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) { IsHost: true, LocalSdkVersion: j.sdkVersion.String(), IsUnitTest: Bool(j.testProperties.Test_options.Unit_test), MkInclude: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", MkAppClass: "JAVA_LIBRARIES", }) } Loading
sh/sh_binary.go +32 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package sh import ( "fmt" "path/filepath" "strings" Loading Loading @@ -164,6 +165,9 @@ type TestProperties struct { // Test options. Test_options android.CommonTestOptions // a list of extra test configuration files that should be installed with the module. Extra_test_configs []string `android:"path,arch_variant"` } type ShBinary struct { Loading @@ -188,6 +192,7 @@ type ShTest struct { data []android.DataPath testConfig android.Path extraTestConfigs android.Paths dataModules map[string]android.Path } Loading Loading @@ -471,6 +476,7 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { HostTemplate: "${ShellTestConfigTemplate}", }) s.extraTestConfigs = android.PathsForModuleSrc(ctx, s.testProperties.Extra_test_configs) s.dataModules = make(map[string]android.Path) ctx.VisitDirectDeps(func(dep android.Module) { depTag := ctx.OtherModuleDependencyTag(dep) Loading Loading @@ -510,6 +516,27 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { installedData := ctx.InstallTestData(s.installDir, s.data) s.installedFile = ctx.InstallExecutable(s.installDir, s.outputFilePath.Base(), s.outputFilePath, installedData...) mkEntries := s.AndroidMkEntries()[0] android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{ TestcaseRelDataFiles: addArch(ctx.Arch().ArchType.String(), installedData.Paths()), OutputFile: s.outputFilePath, TestConfig: s.testConfig, TestSuites: s.testProperties.Test_suites, IsHost: false, IsUnitTest: Bool(s.testProperties.Test_options.Unit_test), MkInclude: mkEntries.Include, MkAppClass: mkEntries.Class, InstallDir: s.installDir, }) } func addArch(archType string, paths android.Paths) []string { archRelPaths := []string{} for _, p := range paths { archRelPaths = append(archRelPaths, fmt.Sprintf("%s/%s", archType, p.Rel())) } return archRelPaths } func (s *ShTest) InstallInData() bool { Loading @@ -533,6 +560,9 @@ func (s *ShTest) AndroidMkEntries() []android.AndroidMkEntries { entries.AddStrings("LOCAL_TEST_DATA_BINS", s.testProperties.Data_bins...) } entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(s.testProperties.Per_testcase_directory)) if len(s.extraTestConfigs) > 0 { entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", s.extraTestConfigs.Strings()...) } s.testProperties.Test_options.SetAndroidMkEntries(entries) }, Loading
sh/sh_binary_test.go +16 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,22 @@ func TestShTestHost(t *testing.T) { android.AssertBoolEquals(t, "LOCAL_IS_UNIT_TEST", true, actualData) } func TestShTestExtraTestConfig(t *testing.T) { result, _ := testShBinary(t, ` sh_test { name: "foo", src: "test.sh", filename: "test.sh", extra_test_configs: ["config1.xml", "config2.xml"], } `) mod := result.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest) entries := android.AndroidMkEntriesForTest(t, result, mod)[0] actualData := entries.EntryMap["LOCAL_EXTRA_FULL_TEST_CONFIGS"] android.AssertStringPathsRelativeToTopEquals(t, "extra_configs", result.Config(), []string{"config1.xml", "config2.xml"}, actualData) } func TestShTestHost_dataDeviceModules(t *testing.T) { ctx, config := testShBinary(t, ` sh_test_host { Loading
tradefed/providers.go +8 −2 Original line number Diff line number Diff line Loading @@ -9,8 +9,8 @@ import ( // Data that test_module_config[_host] modules types will need from // their dependencies to write out build rules and AndroidMkEntries. type BaseTestProviderData struct { // data files and apps for android_test InstalledFiles android.Paths // data files and apps installed for tests, relative to testcases dir. TestcaseRelDataFiles []string // apk for android_test OutputFile android.Path // Either handwritten or generated TF xml. Loading @@ -28,6 +28,12 @@ type BaseTestProviderData struct { LocalCertificate string // Indicates if the base module was a unit test. IsUnitTest bool // The .mk file is used AndroidMkEntries for base (soong_java_prebuilt, etc.) MkInclude string // The AppClass to use for the AndroidMkEntries for the base. MkAppClass string // value for LOCAL_MODULE_PATH. The directory where the module is installed. InstallDir android.InstallPath } var BaseTestProviderKey = blueprint.NewProvider[BaseTestProviderData]()