1// Copyright 2019 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 TestCallRealGcc(t *testing.T) { 12 withTestContext(t, func(ctx *testContext) { 13 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 14 ctx.newCommand(gccX86_64, mainCc))) 15 if err := verifyPath(cmd, gccX86_64+".real"); err != nil { 16 t.Error(err) 17 } 18 }) 19} 20 21func TestCallRealGccForOtherNames(t *testing.T) { 22 withTestContext(t, func(ctx *testContext) { 23 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 24 ctx.newCommand("./x86_64-cros-linux-gnu-somename", mainCc))) 25 if err := verifyPath(cmd, "\\./x86_64-cros-linux-gnu-somename.real"); err != nil { 26 t.Error(err) 27 } 28 }) 29} 30 31func TestConvertClangToGccFlags(t *testing.T) { 32 withTestContext(t, func(ctx *testContext) { 33 var tests = []struct { 34 in string 35 out string 36 }{ 37 {"-march=alderlake", "-march=skylake"}, 38 } 39 40 for _, tt := range tests { 41 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 42 ctx.newCommand(gccX86_64, tt.in, mainCc))) 43 if err := verifyArgCount(cmd, 0, tt.in); err != nil { 44 t.Error(err) 45 } 46 if err := verifyArgOrder(cmd, tt.out, mainCc); err != nil { 47 t.Error(err) 48 } 49 } 50 }) 51} 52 53func TestFilterUnsupportedGccFlags(t *testing.T) { 54 withTestContext(t, func(ctx *testContext) { 55 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 56 ctx.newCommand(gccX86_64, "-Xcompiler", mainCc))) 57 if err := verifyArgCount(cmd, 0, "-Xcompiler"); err != nil { 58 t.Error(err) 59 } 60 }) 61} 62