aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/cros_hardened_config_test.go
diff options
context:
space:
mode:
authorTobias Bosch <tbosch@google.com>2019-09-26 09:45:35 -0700
committerTobias Bosch <tbosch@google.com>2019-09-26 20:19:44 +0000
commit8bb8b5b10282a5b603bb68e6c527d6b221d8f23d (patch)
treed20f602f7ee8e79872411028ef198acaab5e1d72 /compiler_wrapper/cros_hardened_config_test.go
parent52bf1077e4117f4497d0cff09443d1e843058e7f (diff)
downloadtoolchain-utils-8bb8b5b10282a5b603bb68e6c527d6b221d8f23d.tar.gz
Support extra args for llvm next.
Also removes the capability of defining the old wrapper path now that we are getting close to landing it. BUG=chromium:773875 TEST=golden tests and comparison against old wrapper. Change-Id: I543ddb1651edf2a269917f8afb5a667129bc3561 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1826986 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper/cros_hardened_config_test.go')
-rw-r--r--compiler_wrapper/cros_hardened_config_test.go51
1 files changed, 49 insertions, 2 deletions
diff --git a/compiler_wrapper/cros_hardened_config_test.go b/compiler_wrapper/cros_hardened_config_test.go
index 9d5f700a..b6d47da8 100644
--- a/compiler_wrapper/cros_hardened_config_test.go
+++ b/compiler_wrapper/cros_hardened_config_test.go
@@ -17,11 +17,13 @@ import (
const oldHardenedWrapperPathForTest = "$CHROOT/usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/gcc-bin/4.9.x/sysroot_wrapper.hardened"
const crosHardenedGoldenDir = "testdata/cros_hardened_golden"
const crosHardenedNoCCacheGoldenDir = "testdata/cros_hardened_noccache_golden"
+const crosHardenedLlvmNextGoldenDir = "testdata/cros_hardened_llvmnext_golden"
func TestCrosHardenedConfig(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
+ useLlvmNext := false
useCCache := true
- cfg, err := getConfig("cros.hardened", useCCache, oldHardenedWrapperPathForTest, "123")
+ cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123")
if err != nil {
t.Fatal(err)
}
@@ -33,8 +35,9 @@ func TestCrosHardenedConfig(t *testing.T) {
func TestCrosHardenedConfigWithoutCCache(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
+ useLlvmNext := false
useCCache := false
- cfg, err := getConfig("cros.hardened", useCCache, oldHardenedWrapperPathForTest, "123")
+ cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123")
if err != nil {
t.Fatal(err)
}
@@ -68,6 +71,50 @@ func TestCrosHardenedConfigWithoutCCache(t *testing.T) {
})
}
+func TestCrosHardenedConfigWithLlvmNext(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ useLlvmNext := true
+ useCCache := true
+ cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123")
+ if err != nil {
+ t.Fatal(err)
+ }
+ ctx.updateConfig(cfg)
+
+ // Create a copy of the old wrapper where we add the llvm next flags
+ if ctx.cfg.oldWrapperPath != "" {
+ oldWrapperContent, err := ioutil.ReadFile(ctx.cfg.oldWrapperPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ oldWrapperLlvmNextFlags := `
+LLVM_NEXT_FLAGS_TO_ADD = set(['-Wno-reorder-init-list',
+'-Wno-final-dtor-non-final-class',
+'-Wno-implicit-int-float-conversion',
+'-Wno-return-stack-address'
+])`
+ oldWrapperContent = regexp.MustCompile(`LLVM_NEXT_FLAGS_TO_ADD = set\(\[\]\)`).ReplaceAll(oldWrapperContent, []byte(oldWrapperLlvmNextFlags))
+ ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "oldwrapper_llvmnext")
+ if err := ioutil.WriteFile(ctx.cfg.oldWrapperPath, oldWrapperContent, 0666); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ // Only run the subset of the sysroot wrapper tests that execute commands.
+ gomaPath := path.Join(ctx.tempDir, "gomacc")
+ ctx.writeFile(gomaPath, "")
+ gomaEnv := "GOMACC_PATH=" + gomaPath
+ runGoldenRecords(ctx, crosHardenedLlvmNextGoldenDir, []goldenFile{
+ createGccPathGoldenInputs(ctx, gomaEnv),
+ createClangPathGoldenInputs(ctx, gomaEnv),
+ createClangSyntaxGoldenInputs(gomaEnv),
+ createBisectGoldenInputs(),
+ createForceDisableWErrorGoldenInputs(),
+ createClangTidyGoldenInputs(gomaEnv),
+ })
+ })
+}
+
func createSyswrapperGoldenInputs(ctx *testContext) []goldenFile {
gomaPath := path.Join(ctx.tempDir, "gomacc")
ctx.writeFile(gomaPath, "")