aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/libgcc_flags_test.go
blob: d30bf737c5b2052831f48f06552e212532743c82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2021 The ChromiumOS Authors
// 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)
	})
}