From 7b920b4057cb6097898a5ec0292d31b096bd05b2 Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Tue, 22 Jun 2021 16:57:27 -0400 Subject: [PATCH] Update memtag code behavior to match comment. Test: go test soong tests Change-Id: I630c06f01c90256b1990c37b9236e8967a5fa316 --- cc/sanitize.go | 10 +++++++--- cc/sanitize_test.go | 12 ++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cc/sanitize.go b/cc/sanitize.go index 0199897d4..0ed0d47c5 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -293,9 +293,13 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { } // cc_test targets default to SYNC MemTag unless explicitly set to ASYNC (via diag: {memtag_heap}). - if ctx.testBinary() && s.Memtag_heap == nil { - s.Memtag_heap = proptools.BoolPtr(true) - s.Diag.Memtag_heap = proptools.BoolPtr(true) + if ctx.testBinary() { + if s.Memtag_heap == nil { + s.Memtag_heap = proptools.BoolPtr(true) + } + if s.Diag.Memtag_heap == nil { + s.Diag.Memtag_heap = proptools.BoolPtr(true) + } } var globalSanitizers []string diff --git a/cc/sanitize_test.go b/cc/sanitize_test.go index c43547ccd..0070e4026 100644 --- a/cc/sanitize_test.go +++ b/cc/sanitize_test.go @@ -359,9 +359,9 @@ func TestSanitizeMemtagHeap(t *testing.T) { checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_binary_override_default_disable", variant), Async) checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_binary_override_default_sync", variant), Sync) - checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_no_override", variant), Async) - checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_async", variant), Async) - checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_disable", variant), Async) + checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_no_override", variant), Sync) + checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_async", variant), Sync) + checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_disable", variant), Sync) checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_sync", variant), Sync) checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_set_async_binary_no_override", variant), Async) @@ -434,9 +434,9 @@ func TestSanitizeMemtagHeapWithSanitizeDevice(t *testing.T) { checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_binary_override_default_disable", variant), Async) checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_binary_override_default_sync", variant), Sync) - checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_no_override", variant), Async) - checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_async", variant), Async) - checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_disable", variant), Async) + checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_no_override", variant), Sync) + checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_async", variant), Sync) + checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_disable", variant), Sync) checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_test_override_default_sync", variant), Sync) checkHasMemtagNote(t, ctx.ModuleForTests("set_memtag_set_async_binary_no_override", variant), Async)