diff options
author | Sasha Smundak <asmundak@google.com> | 2019-02-21 13:10:54 -0800 |
---|---|---|
committer | Sasha Smundak <asmundak@google.com> | 2019-02-22 15:10:08 -0800 |
commit | f7ed0513e9102cc34a07d3890bccdf351865db63 (patch) | |
tree | f98a65b184bdc1b5dda023750fc83b2e33c30b5b /bpfix | |
parent | e608a51b06031d3765541859068a2be298d19374 (diff) | |
download | build_soong-f7ed0513e9102cc34a07d3890bccdf351865db63.tar.gz build_soong-f7ed0513e9102cc34a07d3890bccdf351865db63.tar.bz2 build_soong-f7ed0513e9102cc34a07d3890bccdf351865db63.zip |
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
Diffstat (limited to 'bpfix')
-rw-r--r-- | bpfix/bpfix/bpfix.go | 28 | ||||
-rw-r--r-- | bpfix/bpfix/bpfix_test.go | 33 |
2 files changed, 61 insertions, 0 deletions
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go index 11f1877e..ba6435e0 100644 --- a/bpfix/bpfix/bpfix.go +++ b/bpfix/bpfix/bpfix.go @@ -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 diff --git a/bpfix/bpfix/bpfix_test.go b/bpfix/bpfix/bpfix_test.go index 13942235..459cd36b 100644 --- a/bpfix/bpfix/bpfix_test.go +++ b/bpfix/bpfix/bpfix_test.go @@ -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) + }) + }) + } +} |