Improve cc tests by adding fuzzer mutators

This fixes an issue that arises when deduping cc build component
registration code.

The fuzzer and fuzzer_deps post deps mutators were not previously
added when running cc tests. That meant the tests were not actually
testing the same behavior as at runtime.

Adding the mutators breaks the TestFuzzTarget test as the mutator
changes the variant of the fuzz_smoke_test that is created and so the
test fails to find it.

This fixes the test by correct the variant name.

Test: m checkbuild
Bug: 146540677
Change-Id: I9d2be0023affb7722f0399663fa18a2a5fb610d8
This commit is contained in:
Paul Duffin 2019-12-19 19:06:13 +00:00
parent d686791c16
commit 075c417837
2 changed files with 4 additions and 1 deletions

View File

@ -2478,7 +2478,7 @@ func TestFuzzTarget(t *testing.T) {
srcs: ["foo.c"],
}`)
variant := "android_arm64_armv8-a"
variant := "android_arm64_armv8-a_fuzzer"
ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
}

View File

@ -36,6 +36,9 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
})
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(fuzzer))
ctx.BottomUp("fuzzer", sanitizerMutator(fuzzer)).Parallel()
ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
})