1*760c253cSXin Li// Copyright 2019 The ChromiumOS Authors 2*760c253cSXin Li// Use of this source code is governed by a BSD-style license that can be 3*760c253cSXin Li// found in the LICENSE file. 4*760c253cSXin Li 5*760c253cSXin Lipackage main 6*760c253cSXin Li 7*760c253cSXin Liimport ( 8*760c253cSXin Li "testing" 9*760c253cSXin Li) 10*760c253cSXin Li 11*760c253cSXin Lifunc TestCallRealGcc(t *testing.T) { 12*760c253cSXin Li withTestContext(t, func(ctx *testContext) { 13*760c253cSXin Li cmd := ctx.must(callCompiler(ctx, ctx.cfg, 14*760c253cSXin Li ctx.newCommand(gccX86_64, mainCc))) 15*760c253cSXin Li if err := verifyPath(cmd, gccX86_64+".real"); err != nil { 16*760c253cSXin Li t.Error(err) 17*760c253cSXin Li } 18*760c253cSXin Li }) 19*760c253cSXin Li} 20*760c253cSXin Li 21*760c253cSXin Lifunc TestCallRealGccForOtherNames(t *testing.T) { 22*760c253cSXin Li withTestContext(t, func(ctx *testContext) { 23*760c253cSXin Li cmd := ctx.must(callCompiler(ctx, ctx.cfg, 24*760c253cSXin Li ctx.newCommand("./x86_64-cros-linux-gnu-somename", mainCc))) 25*760c253cSXin Li if err := verifyPath(cmd, "\\./x86_64-cros-linux-gnu-somename.real"); err != nil { 26*760c253cSXin Li t.Error(err) 27*760c253cSXin Li } 28*760c253cSXin Li }) 29*760c253cSXin Li} 30*760c253cSXin Li 31*760c253cSXin Lifunc TestConvertClangToGccFlags(t *testing.T) { 32*760c253cSXin Li withTestContext(t, func(ctx *testContext) { 33*760c253cSXin Li var tests = []struct { 34*760c253cSXin Li in string 35*760c253cSXin Li out string 36*760c253cSXin Li }{ 37*760c253cSXin Li {"-march=alderlake", "-march=skylake"}, 38*760c253cSXin Li } 39*760c253cSXin Li 40*760c253cSXin Li for _, tt := range tests { 41*760c253cSXin Li cmd := ctx.must(callCompiler(ctx, ctx.cfg, 42*760c253cSXin Li ctx.newCommand(gccX86_64, tt.in, mainCc))) 43*760c253cSXin Li if err := verifyArgCount(cmd, 0, tt.in); err != nil { 44*760c253cSXin Li t.Error(err) 45*760c253cSXin Li } 46*760c253cSXin Li if err := verifyArgOrder(cmd, tt.out, mainCc); err != nil { 47*760c253cSXin Li t.Error(err) 48*760c253cSXin Li } 49*760c253cSXin Li } 50*760c253cSXin Li }) 51*760c253cSXin Li} 52*760c253cSXin Li 53*760c253cSXin Lifunc TestFilterUnsupportedGccFlags(t *testing.T) { 54*760c253cSXin Li withTestContext(t, func(ctx *testContext) { 55*760c253cSXin Li cmd := ctx.must(callCompiler(ctx, ctx.cfg, 56*760c253cSXin Li ctx.newCommand(gccX86_64, "-Xcompiler", mainCc))) 57*760c253cSXin Li if err := verifyArgCount(cmd, 0, "-Xcompiler"); err != nil { 58*760c253cSXin Li t.Error(err) 59*760c253cSXin Li } 60*760c253cSXin Li }) 61*760c253cSXin Li} 62