Add test to show broken behavior of fully qualified name in path property
It reveals a number of issues:
* PathForModuleSrc corrupts the name during validation of path
components.
* SrcIsModule and SrcIsModuleWithTag do not handle fully qualified names
properly or detect invalid unqualified names.
* getPathsFromModuleDep does not handle fully qualified names.
Bug: 193228441
Test: m nothing
Change-Id: I583bc5e7f7df8a1b9cc32acefac3dbe43f49a27a
diff --git a/android/paths_test.go b/android/paths_test.go
index 6f5d79e..c0667dc 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -1125,6 +1125,12 @@
rels []string
src string
rel string
+
+ // Make test specific preparations to the test fixture.
+ preparer FixturePreparer
+
+ // A test specific error handler.
+ errorHandler FixtureErrorHandler
}
func testPathForModuleSrc(t *testing.T, tests []pathForModuleSrcTestCase) {
@@ -1157,14 +1163,23 @@
"foo/src_special/$": nil,
}
+ errorHandler := test.errorHandler
+ if errorHandler == nil {
+ errorHandler = FixtureExpectsNoErrors
+ }
+
result := GroupFixturePreparers(
FixtureRegisterWithContext(func(ctx RegistrationContext) {
ctx.RegisterModuleType("test", pathForModuleSrcTestModuleFactory)
ctx.RegisterModuleType("output_file_provider", pathForModuleSrcOutputFileProviderModuleFactory)
- ctx.RegisterModuleType("filegroup", FileGroupFactory)
}),
+ PrepareForTestWithFilegroup,
+ PrepareForTestWithNamespace,
mockFS.AddToFixture(),
- ).RunTest(t)
+ OptionalFixturePreparer(test.preparer),
+ ).
+ ExtendWithErrorHandler(errorHandler).
+ RunTest(t)
m := result.ModuleForTests("foo", "").Module().(*pathForModuleSrcTestModule)
@@ -1333,6 +1348,85 @@
src: "foo/src_special/$",
rel: "src_special/$",
},
+ {
+ // This test makes sure that an unqualified module name cannot contain characters that make
+ // it appear as a qualified module name.
+ // TODO(b/193228441): Fix broken test.
+ name: "output file provider, invalid fully qualified name",
+ bp: `
+ test {
+ name: "foo",
+ src: "://other:b",
+ srcs: ["://other:c"],
+ }`,
+ preparer: FixtureAddTextFile("other/Android.bp", `
+ soong_namespace {}
+
+ output_file_provider {
+ name: "b",
+ outs: ["gen/b"],
+ }
+
+ output_file_provider {
+ name: "c",
+ outs: ["gen/c"],
+ }
+ `),
+ errorHandler: FixtureExpectsAllErrorsToMatchAPattern([]string{
+ // The message is broken because PathForModuleSrc corrupts the name during validation.
+ `"foo": missing dependencies: /other:b, is the property annotated with android:"path"`,
+ `"foo": missing dependency on "//other:c", is the property annotated with android:"path"`,
+ }),
+ },
+ {
+ // TODO(b/193228441): Fix broken test.
+ name: "output file provider, missing fully qualified name",
+ bp: `
+ test {
+ name: "foo",
+ src: "//other:b",
+ srcs: ["//other:c"],
+ }`,
+ src: "foo",
+ rel: "foo",
+ srcs: []string{"foo"},
+ rels: []string{"foo"},
+ errorHandler: FixtureExpectsAllErrorsToMatchAPattern([]string{
+ `"foo": Path is outside directory: /other:b`,
+ `"foo": Path is outside directory: /other:c`,
+ }),
+ },
+ {
+ // TODO(b/193228441): Fix broken test.
+ name: "output file provider, fully qualified name",
+ bp: `
+ test {
+ name: "foo",
+ src: "//other:b",
+ srcs: ["//other:c"],
+ }`,
+ preparer: FixtureAddTextFile("other/Android.bp", `
+ soong_namespace {}
+
+ output_file_provider {
+ name: "b",
+ outs: ["gen/b"],
+ }
+
+ output_file_provider {
+ name: "c",
+ outs: ["gen/c"],
+ }
+ `),
+ src: "foo",
+ rel: "foo",
+ srcs: []string{"foo"},
+ rels: []string{"foo"},
+ errorHandler: FixtureExpectsAllErrorsToMatchAPattern([]string{
+ `"foo": Path is outside directory: /other:b`,
+ `"foo": Path is outside directory: /other:c`,
+ }),
+ },
}
testPathForModuleSrc(t, tests)