diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:58:35 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:58:35 +0000 |
commit | 983a152aeaa1391c50e5a5b46263aea4d9af7587 (patch) | |
tree | 77dc031614745bb406dbd90cea9a082a1b5cdd54 /compiler_wrapper/sanitizer_flags_test.go | |
parent | 1b38c812789ede0d88389effa290fd29768eb71c (diff) | |
parent | 40214b48188358a80b7478bfff21d4814dd9177c (diff) | |
download | toolchain-utils-android14-mainline-media-swcodec-release.tar.gz |
Snap for 10453563 from 40214b48188358a80b7478bfff21d4814dd9177c to mainline-media-swcodec-releaseaml_swc_341711000aml_swc_341619000aml_swc_341513600aml_swc_341312300aml_swc_341312020aml_swc_341111000aml_swc_341011020aml_swc_340922010android14-mainline-media-swcodec-release
Change-Id: If52bc5d90ff434b6c205f53d523060f7437fdc09
Diffstat (limited to 'compiler_wrapper/sanitizer_flags_test.go')
-rw-r--r-- | compiler_wrapper/sanitizer_flags_test.go | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/compiler_wrapper/sanitizer_flags_test.go b/compiler_wrapper/sanitizer_flags_test.go index a401d58e..b4b1fd83 100644 --- a/compiler_wrapper/sanitizer_flags_test.go +++ b/compiler_wrapper/sanitizer_flags_test.go @@ -1,4 +1,4 @@ -// Copyright 2019 The Chromium OS Authors. All rights reserved. +// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,28 @@ import ( "testing" ) +func TestFortifyIsKeptIfSanitizerIsTrivial(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + cmd := ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(gccX86_64, "-fsanitize=return", "-D_FORTIFY_SOURCE=1", mainCc))) + if err := verifyArgCount(cmd, 1, "-D_FORTIFY_SOURCE=1"); err != nil { + t.Error(err) + } + + cmd = ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(gccX86_64, "-fsanitize=return,address", "-D_FORTIFY_SOURCE=1", mainCc))) + if err := verifyArgCount(cmd, 0, "-D_FORTIFY_SOURCE=1"); err != nil { + t.Error(err) + } + + cmd = ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(gccX86_64, "-fsanitize=address,return", "-D_FORTIFY_SOURCE=1", mainCc))) + if err := verifyArgCount(cmd, 0, "-D_FORTIFY_SOURCE=1"); err != nil { + t.Error(err) + } + }) +} + func TestFilterUnsupportedSanitizerFlagsIfSanitizeGiven(t *testing.T) { withTestContext(t, func(ctx *testContext) { cmd := ctx.must(callCompiler(ctx, ctx.cfg, @@ -23,6 +45,15 @@ func TestFilterUnsupportedSanitizerFlagsIfSanitizeGiven(t *testing.T) { } cmd = ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(gccX86_64, "-fsanitize=kernel-address", "-Wl,-z -Wl,defs", mainCc))) + if err := verifyArgCount(cmd, 0, "-Wl,-z"); err != nil { + t.Error(err) + } + if err := verifyArgCount(cmd, 0, "-Wl,defs"); err != nil { + t.Error(err) + } + + cmd = ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, "-fsanitize=kernel-address", "-D_FORTIFY_SOURCE=1", mainCc))) if err := verifyArgCount(cmd, 0, "-D_FORTIFY_SOURCE=1"); err != nil { t.Error(err) @@ -75,6 +106,15 @@ func TestKeepSanitizerFlagsIfNoSanitizeGiven(t *testing.T) { } cmd = ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(gccX86_64, "-Wl,-z", "-Wl,defs", mainCc))) + if err := verifyArgCount(cmd, 1, "-Wl,-z"); err != nil { + t.Error(err) + } + if err := verifyArgCount(cmd, 1, "-Wl,defs"); err != nil { + t.Error(err) + } + + cmd = ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, "-D_FORTIFY_SOURCE=1", mainCc))) if err := verifyArgCount(cmd, 1, "-D_FORTIFY_SOURCE=1"); err != nil { t.Error(err) |