Add more Soong unit test coverage for gensrcs
When gensrcs's srcs prop is set with filegroup from external package and especially when gensrcs generates cpp headers, it's not trivial to know what the output paths and their correponding include paths look like. In mixed build, there are a few bugs in gensrcs's include paths for cpp headers (b/248555356 and b/248554581) that we'll eventually need to fix. These tests serve as an documentation of the existing behavior when gensrcs generate cpp headers. Test: go test Bug: 248555356 Change-Id: I10168dd4229be8f110a31955d214ef792c8050de
This commit is contained in:
parent
32a98a5d55
commit
370e08c1af
1 changed files with 88 additions and 0 deletions
|
@ -790,6 +790,94 @@ func TestGenruleOutputFiles(t *testing.T) {
|
|||
result.ModuleForTests("gen_all", "").Module().(*useSource).srcs)
|
||||
}
|
||||
|
||||
func TestGenSrcsWithNonRootAndroidBpOutputFiles(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForGenRuleTest,
|
||||
android.FixtureMergeMockFs(android.MockFS{
|
||||
"external-protos/path/Android.bp": []byte(`
|
||||
filegroup {
|
||||
name: "external-protos",
|
||||
srcs: ["baz/baz.proto", "bar.proto"],
|
||||
}
|
||||
`),
|
||||
"package-dir/Android.bp": []byte(`
|
||||
gensrcs {
|
||||
name: "module-name",
|
||||
cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)",
|
||||
srcs: [
|
||||
"src/foo.proto",
|
||||
":external-protos",
|
||||
],
|
||||
output_extension: "proto.h",
|
||||
}
|
||||
`),
|
||||
}),
|
||||
).RunTest(t)
|
||||
|
||||
exportedIncludeDir := "out/soong/.intermediates/package-dir/module-name/gen/gensrcs"
|
||||
gen := result.Module("module-name", "").(*Module)
|
||||
|
||||
android.AssertPathsRelativeToTopEquals(
|
||||
t,
|
||||
"include path",
|
||||
[]string{exportedIncludeDir},
|
||||
gen.exportedIncludeDirs,
|
||||
)
|
||||
android.AssertPathsRelativeToTopEquals(
|
||||
t,
|
||||
"files",
|
||||
[]string{
|
||||
exportedIncludeDir + "/package-dir/src/foo.proto.h",
|
||||
exportedIncludeDir + "/external-protos/path/baz/baz.proto.h",
|
||||
exportedIncludeDir + "/external-protos/path/bar.proto.h",
|
||||
},
|
||||
gen.outputFiles,
|
||||
)
|
||||
}
|
||||
|
||||
func TestGenSrcsWithSrcsFromExternalPackage(t *testing.T) {
|
||||
bp := `
|
||||
gensrcs {
|
||||
name: "module-name",
|
||||
cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)",
|
||||
srcs: [
|
||||
":external-protos",
|
||||
],
|
||||
output_extension: "proto.h",
|
||||
}
|
||||
`
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForGenRuleTest,
|
||||
android.FixtureMergeMockFs(android.MockFS{
|
||||
"external-protos/path/Android.bp": []byte(`
|
||||
filegroup {
|
||||
name: "external-protos",
|
||||
srcs: ["foo/foo.proto", "bar.proto"],
|
||||
}
|
||||
`),
|
||||
}),
|
||||
).RunTestWithBp(t, bp)
|
||||
|
||||
exportedIncludeDir := "out/soong/.intermediates/module-name/gen/gensrcs"
|
||||
gen := result.Module("module-name", "").(*Module)
|
||||
|
||||
android.AssertPathsRelativeToTopEquals(
|
||||
t,
|
||||
"include path",
|
||||
[]string{exportedIncludeDir},
|
||||
gen.exportedIncludeDirs,
|
||||
)
|
||||
android.AssertPathsRelativeToTopEquals(
|
||||
t,
|
||||
"files",
|
||||
[]string{
|
||||
exportedIncludeDir + "/external-protos/path/foo/foo.proto.h",
|
||||
exportedIncludeDir + "/external-protos/path/bar.proto.h",
|
||||
},
|
||||
gen.outputFiles,
|
||||
)
|
||||
}
|
||||
|
||||
func TestPrebuiltTool(t *testing.T) {
|
||||
testcases := []struct {
|
||||
name string
|
||||
|
|
Loading…
Reference in a new issue