Loading androidmk/cmd/androidmk/android.go +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading androidmk/cmd/androidmk/androidmk_test.go +4 −0 Original line number Diff line number Diff line Loading @@ -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: ` Loading @@ -765,6 +766,7 @@ android_test { name: "FooTest", defaults: ["cts_support_defaults"], test_suites: ["cts"], } `, }, Loading @@ -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: ` Loading @@ -781,6 +784,7 @@ android_test { name: "FooTest", defaults: ["cts_defaults"], test_suites: ["cts"], } `, }, Loading bpfix/bpfix/bpfix.go +28 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,10 @@ var fixSteps = []fixStep{ name: "removeTags", fix: runPatchListMod(removeTags), }, { name: "rewriteAndroidTest", fix: rewriteAndroidTest, }, } func NewFixRequest() FixRequest { Loading Loading @@ -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 Loading bpfix/bpfix/bpfix_test.go +33 −0 Original line number Diff line number Diff line Loading @@ -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
androidmk/cmd/androidmk/android.go +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
androidmk/cmd/androidmk/androidmk_test.go +4 −0 Original line number Diff line number Diff line Loading @@ -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: ` Loading @@ -765,6 +766,7 @@ android_test { name: "FooTest", defaults: ["cts_support_defaults"], test_suites: ["cts"], } `, }, Loading @@ -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: ` Loading @@ -781,6 +784,7 @@ android_test { name: "FooTest", defaults: ["cts_defaults"], test_suites: ["cts"], } `, }, Loading
bpfix/bpfix/bpfix.go +28 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,10 @@ var fixSteps = []fixStep{ name: "removeTags", fix: runPatchListMod(removeTags), }, { name: "rewriteAndroidTest", fix: rewriteAndroidTest, }, } func NewFixRequest() FixRequest { Loading Loading @@ -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 Loading
bpfix/bpfix/bpfix_test.go +33 −0 Original line number Diff line number Diff line Loading @@ -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) }) }) } }