diff options
Diffstat (limited to 'compiler_wrapper/cros_host_config_test.go')
-rw-r--r-- | compiler_wrapper/cros_host_config_test.go | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/compiler_wrapper/cros_host_config_test.go b/compiler_wrapper/cros_host_config_test.go new file mode 100644 index 00000000..d2be9ab6 --- /dev/null +++ b/compiler_wrapper/cros_host_config_test.go @@ -0,0 +1,96 @@ +// Copyright 2019 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package main + +import ( + "path" + "testing" +) + +const oldClangHostWrapperPathForTest = "$CHROOT/usr/bin/clang_host_wrapper" +const oldGccHostWrapperPathForTest = "$CHROOT/../src/third_party/chromiumos-overlay/sys-devel/gcc/files/host_wrapper" +const crosClangHostGoldenDir = "testdata/cros_clang_host_golden" +const crosGccHostGoldenDir = "testdata/cros_gcc_host_golden" + +func TestCrosClangHostConfig(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + useLlvmNext := false + useCCache := false + cfg, err := getConfig("cros.host", useCCache, useLlvmNext, oldClangHostWrapperPathForTest, "123") + if err != nil { + t.Fatal(err) + } + ctx.updateConfig(cfg) + + gomaPath := path.Join(ctx.tempDir, "gomacc") + ctx.writeFile(gomaPath, "") + gomaEnv := "GOMACC_PATH=" + gomaPath + + goldenFiles := []goldenFile{ + createClangPathGoldenInputs(ctx, gomaEnv), + createGoldenInputsForAllTargets("clang", mainCc), + createGoldenInputsForAllTargets("clang", "-ftrapv", mainCc), + createSanitizerGoldenInputs("clang"), + createClangArgsGoldenInputs(), + createBisectGoldenInputs(clangX86_64), + createForceDisableWErrorGoldenInputs(), + createClangTidyGoldenInputs(gomaEnv), + createClangHostWrapperInputs(), + } + + runGoldenRecords(ctx, crosClangHostGoldenDir, goldenFiles) + }) +} + +func TestCrosGccHostConfig(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + useLlvmNext := false + useCCache := false + cfg, err := getConfig("cros.host", useCCache, useLlvmNext, oldGccHostWrapperPathForTest, "123") + if err != nil { + t.Fatal(err) + } + ctx.updateConfig(cfg) + + gomaPath := path.Join(ctx.tempDir, "gomacc") + ctx.writeFile(gomaPath, "") + gomaEnv := "GOMACC_PATH=" + gomaPath + + // Note: The old gcc host wrapper is very limited and only adds flags. + // So we only test very few things here. + goldenFiles := []goldenFile{ + createGccPathGoldenInputs(ctx, gomaEnv), + createGoldenInputsForAllTargets("gcc", mainCc), + createGccArgsGoldenInputs(), + createGccHostWrapperInputs(), + } + + runGoldenRecords(ctx, crosGccHostGoldenDir, goldenFiles) + }) +} + +func createClangHostWrapperInputs() goldenFile { + return goldenFile{ + Name: "clang_host_wrapper.json", + Records: []goldenRecord{ + { + WrapperCmd: newGoldenCmd("./clang", mainCc), + Cmds: okResults, + }, + }, + } +} + +func createGccHostWrapperInputs() goldenFile { + return goldenFile{ + Name: "gcc_host_wrapper.json", + Records: []goldenRecord{ + { + WrapperCmd: newGoldenCmd("./gcc", mainCc), + Cmds: okResults, + }, + }, + } +} |