Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4ec5566 authored by Liana Kazanova's avatar Liana Kazanova Committed by Gerrit Code Review
Browse files

Merge "Revert "test_module_config for sh_test"" into main

parents 9a933b42 876b8038
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -1465,9 +1465,8 @@ 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{
		TestcaseRelDataFiles:    testcaseRel(a.data),
		InstalledFiles:          a.data,
		OutputFile:              a.OutputFile(),
		TestConfig:              a.testConfig,
		HostRequiredModuleNames: a.HostRequiredModuleNames(),
@@ -1475,8 +1474,6 @@ 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,
@@ -1485,14 +1482,6 @@ 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
+8 −10
Original line number Diff line number Diff line
@@ -1557,7 +1557,7 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) {

	j.Test.generateAndroidBuildActionsWithConfig(ctx, configs)
	android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{
		TestcaseRelDataFiles: testcaseRel(j.data),
		InstalledFiles:      j.data,
		OutputFile:          j.outputFile,
		TestConfig:          j.testConfig,
		RequiredModuleNames: j.RequiredModuleNames(ctx),
@@ -1565,8 +1565,6 @@ 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",
	})
}

+2 −32
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
package sh

import (
	"fmt"
	"path/filepath"
	"strings"

@@ -165,9 +164,6 @@ 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 {
@@ -192,7 +188,6 @@ type ShTest struct {

	data       []android.DataPath
	testConfig android.Path
	extraTestConfigs android.Paths

	dataModules map[string]android.Path
}
@@ -476,7 +471,6 @@ 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)
@@ -516,27 +510,6 @@ 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 {
@@ -560,9 +533,6 @@ 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)
			},
+0 −16
Original line number Diff line number Diff line
@@ -176,22 +176,6 @@ 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 {
+2 −8
Original line number Diff line number Diff line
@@ -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 installed for tests, relative to testcases dir.
	TestcaseRelDataFiles []string
	// data files and apps for android_test
	InstalledFiles android.Paths
	// apk for android_test
	OutputFile android.Path
	// Either handwritten or generated TF xml.
@@ -28,12 +28,6 @@ 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