Handle LOCAL_MODULE_PATH assignment for android_test modules
Many Android.mk files for the CTS tests have LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) statement. This can be dropped during the conversion to blueprint files. Also, ignore the assignments to obsolete LOCAL_CTS_TEST_PACKAGE variable. Fixes: 125405331 Test: Internal tests, selectively run androidmk on Android.mk's in cts/ directory Change-Id: I2ed88acd3c8837f96b84be6eb7c7b9b0b5405f57
This commit is contained in:
parent
e608a51b06
commit
f7ed0513e9
|
@ -72,6 +72,7 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
|
|||
"LOCAL_JAR_EXCLUDE_FILES": skip, // Soong never excludes files from jars
|
||||
|
||||
"LOCAL_ANNOTATION_PROCESSOR_CLASSES": skip, // Soong gets the processor classes from the plugin
|
||||
"LOCAL_CTS_TEST_PACKAGE": skip, // Obsolete
|
||||
}
|
||||
|
||||
// adds a group of properties all having the same type
|
||||
|
|
|
@ -758,6 +758,7 @@ cc_library_shared {
|
|||
include $(CLEAR_VARS)
|
||||
LOCAL_PACKAGE_NAME := FooTest
|
||||
LOCAL_COMPATIBILITY_SUITE := cts
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
|
||||
include $(BUILD_CTS_SUPPORT_PACKAGE)
|
||||
`,
|
||||
expected: `
|
||||
|
@ -765,6 +766,7 @@ android_test {
|
|||
name: "FooTest",
|
||||
defaults: ["cts_support_defaults"],
|
||||
test_suites: ["cts"],
|
||||
|
||||
}
|
||||
`,
|
||||
},
|
||||
|
@ -774,6 +776,7 @@ android_test {
|
|||
include $(CLEAR_VARS)
|
||||
LOCAL_PACKAGE_NAME := FooTest
|
||||
LOCAL_COMPATIBILITY_SUITE := cts
|
||||
LOCAL_CTS_TEST_PACKAGE := foo.bar
|
||||
include $(BUILD_CTS_PACKAGE)
|
||||
`,
|
||||
expected: `
|
||||
|
@ -781,6 +784,7 @@ android_test {
|
|||
name: "FooTest",
|
||||
defaults: ["cts_defaults"],
|
||||
test_suites: ["cts"],
|
||||
|
||||
}
|
||||
`,
|
||||
},
|
||||
|
|
|
@ -98,6 +98,10 @@ var fixSteps = []fixStep{
|
|||
name: "removeTags",
|
||||
fix: runPatchListMod(removeTags),
|
||||
},
|
||||
{
|
||||
name: "rewriteAndroidTest",
|
||||
fix: rewriteAndroidTest,
|
||||
},
|
||||
}
|
||||
|
||||
func NewFixRequest() FixRequest {
|
||||
|
@ -561,6 +565,30 @@ func rewriteAndroidmkPrebuiltEtc(f *Fixer) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func rewriteAndroidTest(f *Fixer) error {
|
||||
for _, def := range f.tree.Defs {
|
||||
mod, ok := def.(*parser.Module)
|
||||
if !(ok && mod.Type == "android_test") {
|
||||
continue
|
||||
}
|
||||
// The rewriter converts LOCAL_MODULE_PATH attribute into a struct attribute
|
||||
// 'local_module_path'. For the android_test module, it should be $(TARGET_OUT_DATA_APPS),
|
||||
// that is, `local_module_path: { var: "TARGET_OUT_DATA_APPS"}`
|
||||
const local_module_path = "local_module_path"
|
||||
if prop_local_module_path, ok := mod.GetProperty(local_module_path); ok {
|
||||
removeProperty(mod, local_module_path)
|
||||
prefixVariableName := getStringProperty(prop_local_module_path, "var")
|
||||
path := getStringProperty(prop_local_module_path, "fixed")
|
||||
if prefixVariableName == "TARGET_OUT_DATA_APPS" && path == "" {
|
||||
continue
|
||||
}
|
||||
return indicateAttributeError(mod, "filename",
|
||||
"Only LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) is allowed for the android_test")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func runPatchListMod(modFunc func(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error) func(*Fixer) error {
|
||||
return func(f *Fixer) error {
|
||||
// Make sure all the offsets are accurate
|
||||
|
|
|
@ -751,3 +751,36 @@ func TestRewritePrebuiltEtc(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewriteAndroidTest(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
in string
|
||||
out string
|
||||
}{
|
||||
{
|
||||
name: "android_test valid module path",
|
||||
in: `
|
||||
android_test {
|
||||
name: "foo",
|
||||
local_module_path: {
|
||||
var: "TARGET_OUT_DATA_APPS",
|
||||
},
|
||||
}
|
||||
`,
|
||||
out: `
|
||||
android_test {
|
||||
name: "foo",
|
||||
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
runPass(t, test.in, test.out, func(fixer *Fixer) error {
|
||||
return rewriteAndroidTest(fixer)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue