diff options
Diffstat (limited to 'compiler_wrapper/libgcc_flags_test.go')
-rw-r--r-- | compiler_wrapper/libgcc_flags_test.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/compiler_wrapper/libgcc_flags_test.go b/compiler_wrapper/libgcc_flags_test.go new file mode 100644 index 00000000..717c0e52 --- /dev/null +++ b/compiler_wrapper/libgcc_flags_test.go @@ -0,0 +1,57 @@ +// Copyright 2021 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package main + +import ( + "testing" +) + +func TestDefaultStaticLibGCC(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + runWithCompiler := func(compiler string) { + cmd := ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(compiler, mainCc))) + if err := verifyArgCount(cmd, 1, "-static-libgcc"); err != nil { + t.Error(err) + } + } + + runWithCompiler(gccX86_64) + runWithCompiler(clangX86_64) + }) +} + +func TestKeepStaticLibGCCWithUserArgs(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + runWithCompiler := func(compiler string) { + cmd := ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(compiler, "-static-libgcc", mainCc))) + if err := verifyArgOrder(cmd, "-static-libgcc", mainCc); err != nil { + t.Error(err) + } + } + + runWithCompiler(gccX86_64) + runWithCompiler(clangX86_64) + }) +} + +func TestNoAddedStaticLibGCCWithSharedLibGCC(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + runWithCompiler := func(compiler string) { + cmd := ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(compiler, "-shared-libgcc", mainCc))) + if err := verifyArgCount(cmd, 0, "-static-libgcc"); err != nil { + t.Error(err) + } + if err := verifyArgCount(cmd, 1, "-shared-libgcc"); err != nil { + t.Error(err) + } + } + + runWithCompiler(gccX86_64) + runWithCompiler(clangX86_64) + }) +} |