Add support of test data to python_host_test
Bug: none Test: m -j vts_vndk_abi_test confirm abi_dump.zip found next to test binary Change-Id: I834dddfc13eb9e7addd234307b085b16124db234
This commit is contained in:
parent
f793d7deb4
commit
3194912150
5 changed files with 39 additions and 21 deletions
|
@ -634,3 +634,21 @@ func shouldSkipAndroidMkProcessing(module *ModuleBase) bool {
|
||||||
// Make does not understand LinuxBionic
|
// Make does not understand LinuxBionic
|
||||||
module.Os() == LinuxBionic
|
module.Os() == LinuxBionic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AndroidMkDataPaths(data []DataPath) []string {
|
||||||
|
var testFiles []string
|
||||||
|
for _, d := range data {
|
||||||
|
rel := d.SrcPath.Rel()
|
||||||
|
path := d.SrcPath.String()
|
||||||
|
if !strings.HasSuffix(path, rel) {
|
||||||
|
panic(fmt.Errorf("path %q does not end with %q", path, rel))
|
||||||
|
}
|
||||||
|
path = strings.TrimSuffix(path, rel)
|
||||||
|
testFileString := path + ":" + rel
|
||||||
|
if len(d.RelativeInstallPath) > 0 {
|
||||||
|
testFileString += ":" + d.RelativeInstallPath
|
||||||
|
}
|
||||||
|
testFiles = append(testFiles, testFileString)
|
||||||
|
}
|
||||||
|
return testFiles
|
||||||
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(newDataPaths) > 0 {
|
if len(newDataPaths) > 0 {
|
||||||
fmt.Fprintln(w, "LOCAL_TEST_DATA :=", strings.Join(cc.AndroidMkDataPaths(newDataPaths), " "))
|
fmt.Fprintln(w, "LOCAL_TEST_DATA :=", strings.Join(android.AndroidMkDataPaths(newDataPaths), " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.module != nil && len(fi.module.NoticeFiles()) > 0 {
|
if fi.module != nil && len(fi.module.NoticeFiles()) > 0 {
|
||||||
|
|
|
@ -149,24 +149,6 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
return []android.AndroidMkEntries{entries}
|
return []android.AndroidMkEntries{entries}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AndroidMkDataPaths(data []android.DataPath) []string {
|
|
||||||
var testFiles []string
|
|
||||||
for _, d := range data {
|
|
||||||
rel := d.SrcPath.Rel()
|
|
||||||
path := d.SrcPath.String()
|
|
||||||
if !strings.HasSuffix(path, rel) {
|
|
||||||
panic(fmt.Errorf("path %q does not end with %q", path, rel))
|
|
||||||
}
|
|
||||||
path = strings.TrimSuffix(path, rel)
|
|
||||||
testFileString := path + ":" + rel
|
|
||||||
if len(d.RelativeInstallPath) > 0 {
|
|
||||||
testFileString += ":" + d.RelativeInstallPath
|
|
||||||
}
|
|
||||||
testFiles = append(testFiles, testFileString)
|
|
||||||
}
|
|
||||||
return testFiles
|
|
||||||
}
|
|
||||||
|
|
||||||
func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
|
func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
|
||||||
if len(extraTestConfigs) > 0 {
|
if len(extraTestConfigs) > 0 {
|
||||||
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
||||||
|
@ -176,7 +158,7 @@ func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *and
|
||||||
}
|
}
|
||||||
|
|
||||||
func androidMkWriteTestData(data []android.DataPath, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
|
func androidMkWriteTestData(data []android.DataPath, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
|
||||||
testFiles := AndroidMkDataPaths(data)
|
testFiles := android.AndroidMkDataPaths(data)
|
||||||
if len(testFiles) > 0 {
|
if len(testFiles) > 0 {
|
||||||
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
||||||
entries.AddStrings("LOCAL_TEST_DATA", testFiles...)
|
entries.AddStrings("LOCAL_TEST_DATA", testFiles...)
|
||||||
|
|
|
@ -15,11 +15,12 @@
|
||||||
package python
|
package python
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
type subAndroidMkProvider interface {
|
type subAndroidMkProvider interface {
|
||||||
|
@ -74,6 +75,11 @@ func (p *testDecorator) AndroidMk(base *Module, ret *android.AndroidMkData) {
|
||||||
if !BoolDefault(p.binaryProperties.Auto_gen_config, true) {
|
if !BoolDefault(p.binaryProperties.Auto_gen_config, true) {
|
||||||
fmt.Fprintln(w, "LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true")
|
fmt.Fprintln(w, "LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(p.data) > 0 {
|
||||||
|
fmt.Fprintln(w, "LOCAL_TEST_DATA :=",
|
||||||
|
strings.Join(android.AndroidMkDataPaths(p.data), " "))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
base.subAndroidMk(ret, p.binaryDecorator.pythonInstaller)
|
base.subAndroidMk(ret, p.binaryDecorator.pythonInstaller)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,10 @@ type TestProperties struct {
|
||||||
// the name of the test configuration template (for example "AndroidTestTemplate.xml") that
|
// the name of the test configuration template (for example "AndroidTestTemplate.xml") that
|
||||||
// should be installed with the module.
|
// should be installed with the module.
|
||||||
Test_config_template *string `android:"path,arch_variant"`
|
Test_config_template *string `android:"path,arch_variant"`
|
||||||
|
|
||||||
|
// list of files or filegroup modules that provide data that should be installed alongside
|
||||||
|
// the test
|
||||||
|
Data []string `android:"path,arch_variant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type testDecorator struct {
|
type testDecorator struct {
|
||||||
|
@ -42,6 +46,8 @@ type testDecorator struct {
|
||||||
testProperties TestProperties
|
testProperties TestProperties
|
||||||
|
|
||||||
testConfig android.Path
|
testConfig android.Path
|
||||||
|
|
||||||
|
data []android.DataPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func (test *testDecorator) bootstrapperProps() []interface{} {
|
func (test *testDecorator) bootstrapperProps() []interface{} {
|
||||||
|
@ -59,6 +65,12 @@ func (test *testDecorator) install(ctx android.ModuleContext, file android.Path)
|
||||||
test.binaryDecorator.pythonInstaller.relative = ctx.ModuleName()
|
test.binaryDecorator.pythonInstaller.relative = ctx.ModuleName()
|
||||||
|
|
||||||
test.binaryDecorator.pythonInstaller.install(ctx, file)
|
test.binaryDecorator.pythonInstaller.install(ctx, file)
|
||||||
|
|
||||||
|
dataSrcPaths := android.PathsForModuleSrc(ctx, test.testProperties.Data)
|
||||||
|
|
||||||
|
for _, dataSrcPath := range dataSrcPaths {
|
||||||
|
test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTest(hod android.HostOrDeviceSupported) *Module {
|
func NewTest(hod android.HostOrDeviceSupported) *Module {
|
||||||
|
|
Loading…
Reference in a new issue