1// Copyright 2019 The Chromium OS Authors. All rights reserved. 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=goldmont", "-march=silvermont"}, 38 {"-march=goldmont-plus", "-march=silvermont"}, 39 {"-march=skylake", "-march=corei7"}, 40 {"-march=tigerlake", "-march=corei7"}, 41 {"-march=tremont", "-march=silvermont"}, 42 } 43 44 for _, tt := range tests { 45 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 46 ctx.newCommand(gccX86_64, tt.in, mainCc))) 47 if err := verifyArgCount(cmd, 0, tt.in); err != nil { 48 t.Error(err) 49 } 50 if err := verifyArgOrder(cmd, tt.out, mainCc); err != nil { 51 t.Error(err) 52 } 53 } 54 }) 55} 56 57func TestFilterUnsupportedGccFlags(t *testing.T) { 58 withTestContext(t, func(ctx *testContext) { 59 cmd := ctx.must(callCompiler(ctx, ctx.cfg, 60 ctx.newCommand(gccX86_64, "-Xcompiler", mainCc))) 61 if err := verifyArgCount(cmd, 0, "-Xcompiler"); err != nil { 62 t.Error(err) 63 } 64 }) 65} 66