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

Commit ec7a91f9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add extra_test_configs option"

parents f5a2b8a6 95d19422
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -167,6 +167,14 @@ func AndroidMkDataPaths(data []android.DataPath) []string {
	return testFiles
	return testFiles
}
}


func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
	if len(extraTestConfigs) > 0 {
		entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
			entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
		})
	}
}

func androidMkWriteTestData(data []android.DataPath, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
func androidMkWriteTestData(data []android.DataPath, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
	testFiles := AndroidMkDataPaths(data)
	testFiles := AndroidMkDataPaths(data)
	if len(testFiles) > 0 {
	if len(testFiles) > 0 {
@@ -372,6 +380,7 @@ func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.
	})
	})


	androidMkWriteTestData(test.data, ctx, entries)
	androidMkWriteTestData(test.data, ctx, entries)
	androidMkWriteExtraTestConfigs(test.extraTestConfigs, entries)
}
}


func (fuzz *fuzzBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
func (fuzz *fuzzBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
+10 −3
Original line number Original line Diff line number Diff line
@@ -40,8 +40,12 @@ type TestProperties struct {
type TestOptions struct {
type TestOptions struct {
	// The UID that you want to run the test as on a device.
	// The UID that you want to run the test as on a device.
	Run_test_as *string
	Run_test_as *string

	// A list of free-formed strings without spaces that categorize the test.
	// A list of free-formed strings without spaces that categorize the test.
	Test_suite_tag []string
	Test_suite_tag []string

	// a list of extra test configuration files that should be installed with the module.
	Extra_test_configs []string `android:"path,arch_variant"`
}
}


type TestBinaryProperties struct {
type TestBinaryProperties struct {
@@ -312,6 +316,7 @@ type testBinary struct {
	Properties       TestBinaryProperties
	Properties       TestBinaryProperties
	data             []android.DataPath
	data             []android.DataPath
	testConfig       android.Path
	testConfig       android.Path
	extraTestConfigs android.Paths
}
}


func (test *testBinary) linkerProps() []interface{} {
func (test *testBinary) linkerProps() []interface{} {
@@ -408,6 +413,8 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
	test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config,
	test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config,
		test.Properties.Test_config_template, test.Properties.Test_suites, configs, test.Properties.Auto_gen_config)
		test.Properties.Test_config_template, test.Properties.Test_suites, configs, test.Properties.Auto_gen_config)


	test.extraTestConfigs = android.PathsForModuleSrc(ctx, test.Properties.Test_options.Extra_test_configs)

	test.binaryDecorator.baseInstaller.dir = "nativetest"
	test.binaryDecorator.baseInstaller.dir = "nativetest"
	test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
	test.binaryDecorator.baseInstaller.dir64 = "nativetest64"


+8 −0
Original line number Original line Diff line number Diff line
@@ -161,6 +161,7 @@ func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
		if j.testConfig != nil {
		if j.testConfig != nil {
			entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
			entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
		}
		}
		androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
		androidMkWriteTestData(j.data, entries)
		androidMkWriteTestData(j.data, entries)
		if !BoolDefault(j.testProperties.Auto_gen_config, true) {
		if !BoolDefault(j.testProperties.Auto_gen_config, true) {
			entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
			entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
@@ -170,6 +171,12 @@ func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
	return entriesList
	return entriesList
}
}


func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
	if len(extraTestConfigs) > 0 {
		entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
	}
}

func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
	entriesList := j.Library.AndroidMkEntries()
	entriesList := j.Library.AndroidMkEntries()
	entries := &entriesList[0]
	entries := &entriesList[0]
@@ -431,6 +438,7 @@ func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
		if a.testConfig != nil {
		if a.testConfig != nil {
			entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
			entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
		}
		}
		androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
		androidMkWriteTestData(a.data, entries)
		androidMkWriteTestData(a.data, entries)
	})
	})


+4 −2
Original line number Original line Diff line number Diff line
@@ -1035,6 +1035,7 @@ type AndroidTest struct {
	testProperties testProperties
	testProperties testProperties


	testConfig       android.Path
	testConfig       android.Path
	extraTestConfigs android.Paths
	data             android.Paths
	data             android.Paths
}
}


@@ -1063,6 +1064,7 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	testConfig := tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config,
	testConfig := tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config,
		a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites, a.testProperties.Auto_gen_config, configs)
		a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites, a.testProperties.Auto_gen_config, configs)
	a.testConfig = a.FixTestConfig(ctx, testConfig)
	a.testConfig = a.FixTestConfig(ctx, testConfig)
	a.extraTestConfigs = android.PathsForModuleSrc(ctx, a.testProperties.Test_options.Extra_test_configs)
	a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
	a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
}
}


+14 −2
Original line number Original line Diff line number Diff line
@@ -2124,6 +2124,12 @@ func LibraryHostFactory() android.Module {
// Java Tests
// Java Tests
//
//


// Test option struct.
type TestOptions struct {
	// a list of extra test configuration files that should be installed with the module.
	Extra_test_configs []string `android:"path,arch_variant"`
}

type testProperties struct {
type testProperties struct {
	// list of compatibility suites (for example "cts", "vts") that the module should be
	// list of compatibility suites (for example "cts", "vts") that the module should be
	// installed into.
	// installed into.
@@ -2149,6 +2155,9 @@ type testProperties struct {
	// Add parameterized mainline modules to auto generated test config. The options will be
	// Add parameterized mainline modules to auto generated test config. The options will be
	// handled by TradeFed to do downloading and installing the specified modules on the device.
	// handled by TradeFed to do downloading and installing the specified modules on the device.
	Test_mainline_modules []string
	Test_mainline_modules []string

	// Test options.
	Test_options TestOptions
}
}


type hostTestProperties struct {
type hostTestProperties struct {
@@ -2178,6 +2187,7 @@ type Test struct {
	testProperties testProperties
	testProperties testProperties


	testConfig       android.Path
	testConfig       android.Path
	extraTestConfigs android.Paths
	data             android.Paths
	data             android.Paths
}
}


@@ -2217,6 +2227,8 @@ func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {


	j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
	j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)


	j.extraTestConfigs = android.PathsForModuleSrc(ctx, j.testProperties.Test_options.Extra_test_configs)

	ctx.VisitDirectDepsWithTag(dataNativeBinsTag, func(dep android.Module) {
	ctx.VisitDirectDepsWithTag(dataNativeBinsTag, func(dep android.Module) {
		j.data = append(j.data, android.OutputFileForModule(ctx, dep, ""))
		j.data = append(j.data, android.OutputFileForModule(ctx, dep, ""))
	})
	})