aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/sanitizer_flags_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'compiler_wrapper/sanitizer_flags_test.go')
-rw-r--r--compiler_wrapper/sanitizer_flags_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler_wrapper/sanitizer_flags_test.go b/compiler_wrapper/sanitizer_flags_test.go
index 2b348779..091af25a 100644
--- a/compiler_wrapper/sanitizer_flags_test.go
+++ b/compiler_wrapper/sanitizer_flags_test.go
@@ -32,6 +32,30 @@ func TestFilterUnsupportedSanitizerFlagsIfSanitizeGiven(t *testing.T) {
})
}
+func TestFilterUnsupportedDefaultSanitizerFlagsIfSanitizeGivenForClang(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ ctx.cfg.commonFlags = []string{"-D_FORTIFY_SOURCE=1"}
+ cmd := ctx.must(callCompiler(ctx, ctx.cfg,
+ ctx.newCommand(clangX86_64, "-fsanitize=kernel-address", mainCc)))
+ if err := verifyArgCount(cmd, 0, "-D_FORTIFY_SOURCE=1"); err != nil {
+ t.Error(err)
+ }
+ })
+}
+
+func TestKeepUnsupportedDefaultSanitizerFlagsIfSanitizeGivenForGcc(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ ctx.cfg.commonFlags = []string{"-D_FORTIFY_SOURCE=1"}
+ cmd := ctx.must(callCompiler(ctx, ctx.cfg,
+ ctx.newCommand(gccX86_64, "-fsanitize=kernel-address", mainCc)))
+ if err := verifyArgCount(cmd, 1, "-D_FORTIFY_SOURCE=1"); err != nil {
+ t.Error(err)
+ }
+ })
+}
+
+// TODO: This is a bug in the old wrapper to not filter
+// non user args for gcc. Fix this once we don't compare to the old wrapper anymore.
func TestKeepSanitizerFlagsIfNoSanitizeGiven(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
cmd := ctx.must(callCompiler(ctx, ctx.cfg,