test_module_config for sh_test
[retry reverted 45dca5c8cc538392edbde4ee1077fc86509b2e38 after rebase]
Implemented test_module_config for sh_tests.
There are some shell tests that have 130 cc_binaries and they get
duplicated in the vts .zip. test_module_config allows deduping for
lowmem and hwasan use cases freeing a 1 G in the zip.
Moved some of the knowledge about constructing the make rules back to
the provider.
I haven't tried this for cc_test or rust_test, but I think it will be
similar to sh_test if we ever need it.
There is currently only one usecase for using test_module_config with
sh_test (and none for cc_ or rust_)
Also added "extra_test_configs" to sh_test
Sample bp file.
test_module_config {
name: "vts_ltp_tmc",
base: "vts_ltp_test_x86_64",
test_suites: [
"general-tests",
"vts"
],
options: [
{name: "is-low-mem", value: "false"},
{name: "is-hwasan", value: "true"},
],
}
Test: go test ./
Test: m vts_ltp_test_x86_64_hwasan
Test: atest vts_ltp_test_x86_64_hwasan
Test: m vts # inspect the zip for symlinks
Test: CtsAppTestCases_android_server_am
Test: atest -c -v vts_ltp_test_x86_64:vts_ltp_test_x86_64_hwa
Change-Id: I208797f97e3448bcff7434630adfd7476fc275f9
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index 853f3d3..320e97f 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -15,6 +15,7 @@
package sh
import (
+ "fmt"
"path/filepath"
"strings"
@@ -164,6 +165,9 @@
// 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 {
@@ -186,8 +190,9 @@
installDir android.InstallPath
- data []android.DataPath
- testConfig android.Path
+ data []android.DataPath
+ testConfig android.Path
+ extraTestConfigs android.Paths
dataModules map[string]android.Path
}
@@ -471,6 +476,7 @@
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)
@@ -510,6 +516,27 @@
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 {
@@ -533,6 +560,9 @@
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)
},