1// Copyright 2021 The ChromiumOS Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5package main 6 7import ( 8 "testing" 9) 10 11func TestDefaultStaticLibGCC(t *testing.T) { 12 withTestContext(t, func(ctx *testContext) { 13 runWithCompiler := func(compiler string) { 14 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 15 ctx.newCommand(compiler, mainCc))) 16 if err := verifyArgCount(cmd, 1, "-static-libgcc"); err != nil { 17 t.Error(err) 18 } 19 } 20 21 runWithCompiler(gccX86_64) 22 runWithCompiler(clangX86_64) 23 }) 24} 25 26func TestKeepStaticLibGCCWithUserArgs(t *testing.T) { 27 withTestContext(t, func(ctx *testContext) { 28 runWithCompiler := func(compiler string) { 29 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 30 ctx.newCommand(compiler, "-static-libgcc", mainCc))) 31 if err := verifyArgOrder(cmd, "-static-libgcc", mainCc); err != nil { 32 t.Error(err) 33 } 34 } 35 36 runWithCompiler(gccX86_64) 37 runWithCompiler(clangX86_64) 38 }) 39} 40 41func TestNoAddedStaticLibGCCWithSharedLibGCC(t *testing.T) { 42 withTestContext(t, func(ctx *testContext) { 43 runWithCompiler := func(compiler string) { 44 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 45 ctx.newCommand(compiler, "-shared-libgcc", mainCc))) 46 if err := verifyArgCount(cmd, 0, "-static-libgcc"); err != nil { 47 t.Error(err) 48 } 49 if err := verifyArgCount(cmd, 1, "-shared-libgcc"); err != nil { 50 t.Error(err) 51 } 52 } 53 54 runWithCompiler(gccX86_64) 55 runWithCompiler(clangX86_64) 56 }) 57} 58