diff options
author | Tobias Bosch <tbosch@google.com> | 2019-08-13 09:22:36 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-08-13 18:42:24 +0000 |
commit | 1b336f8d1c5ddb9a977fd182cc32ddbfec68d1d2 (patch) | |
tree | c757e8fd195e904ad088fcb0292c7a7c4bbfb6a9 /compiler_wrapper | |
parent | caf583bca202cd1c5b3ae75e03073cba105f5e6d (diff) | |
download | toolchain-utils-1b336f8d1c5ddb9a977fd182cc32ddbfec68d1d2.tar.gz |
Add more golden tests for wrapper paths
Especially for:
- calling the wrapper with absolute path
- calling the wrapper in a deep directory
- calling a symlinked wrapper
BUG=chromium:773875
TEST=unit test
Change-Id: Ib01562d6c40d8d2ae0c439081fc04625663dcd07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1752524
Tested-by: Tobias Bosch <tbosch@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper')
11 files changed, 869 insertions, 8 deletions
diff --git a/compiler_wrapper/cros_hardened_config_test.go b/compiler_wrapper/cros_hardened_config_test.go index d2f4214e..5ae2f7e1 100644 --- a/compiler_wrapper/cros_hardened_config_test.go +++ b/compiler_wrapper/cros_hardened_config_test.go @@ -50,8 +50,8 @@ func TestCrosHardenedConfigWithoutCCache(t *testing.T) { ctx.writeFile(gomaPath, "") gomaEnv := "GOMACC_PATH=" + gomaPath runGoldenRecords(ctx, crosHardenedNoCCacheGoldenDir, []goldenFile{ - createGccPathGoldenInputs(gomaEnv), - createClangPathGoldenInputs(gomaEnv), + createGccPathGoldenInputs(ctx, gomaEnv), + createClangPathGoldenInputs(ctx, gomaEnv), createClangSyntaxGoldenInputs(gomaEnv), createBisectGoldenInputs(), createForceDisableWErrorGoldenInputs(), @@ -66,13 +66,13 @@ func createSyswrapperGoldenInputs(ctx *testContext) []goldenFile { gomaEnv := "GOMACC_PATH=" + gomaPath return []goldenFile{ - createGccPathGoldenInputs(gomaEnv), + createGccPathGoldenInputs(ctx, gomaEnv), createGoldenInputsForAllTargets("gcc", mainCc), createSysrootWrapperCommonGoldenInputs("gcc", gomaEnv), createSanitizerGoldenInputs("gcc"), createGccArgsGoldenInputs(), createClangSyntaxGoldenInputs(gomaEnv), - createClangPathGoldenInputs(gomaEnv), + createClangPathGoldenInputs(ctx, gomaEnv), createGoldenInputsForAllTargets("clang", mainCc), createGoldenInputsForAllTargets("clang", "-ftrapv", mainCc), createSysrootWrapperCommonGoldenInputs("clang", gomaEnv), @@ -192,7 +192,10 @@ func createForceDisableWErrorGoldenInputs() goldenFile { } } -func createGccPathGoldenInputs(gomaEnv string) goldenFile { +func createGccPathGoldenInputs(ctx *testContext, gomaEnv string) goldenFile { + deepPath := "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc" + linkedDeepPath := "symlinked/x86_64-cros-linux-gnu-gcc" + ctx.symlink(deepPath, linkedDeepPath) return goldenFile{ Name: "gcc_path.json", Records: []goldenRecord{ @@ -204,11 +207,26 @@ func createGccPathGoldenInputs(gomaEnv string) goldenFile { WrapperCmd: newGoldenCmd("./x86_64-cros-linux-gnu-gcc", mainCc), Cmds: errorResults, }, + { + WrapperCmd: newGoldenCmd(filepath.Join(ctx.tempDir, "x86_64-cros-linux-gnu-gcc"), mainCc), + Cmds: okResults, + }, + { + WrapperCmd: newGoldenCmd(deepPath, mainCc), + Cmds: okResults, + }, + { + WrapperCmd: newGoldenCmd(linkedDeepPath, mainCc), + Cmds: okResults, + }, }, } } -func createClangPathGoldenInputs(gomaEnv string) goldenFile { +func createClangPathGoldenInputs(ctx *testContext, gomaEnv string) goldenFile { + deepPath := "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-clang" + linkedDeepPath := "symlinked/x86_64-cros-linux-gnu-clang" + ctx.symlink(deepPath, linkedDeepPath) return goldenFile{ Name: "clang_path.json", Records: []goldenRecord{ @@ -251,6 +269,18 @@ func createClangPathGoldenInputs(gomaEnv string) goldenFile { errorResult, }, }, + { + WrapperCmd: newGoldenCmd(filepath.Join(ctx.tempDir, "x86_64-cros-linux-gnu-clang"), mainCc), + Cmds: okResults, + }, + { + WrapperCmd: newGoldenCmd(deepPath, mainCc), + Cmds: okResults, + }, + { + WrapperCmd: newGoldenCmd(linkedDeepPath, mainCc), + Cmds: okResults, + }, }, } } diff --git a/compiler_wrapper/cros_host_config_test.go b/compiler_wrapper/cros_host_config_test.go index 7ccdf3fb..a68cedd7 100644 --- a/compiler_wrapper/cros_host_config_test.go +++ b/compiler_wrapper/cros_host_config_test.go @@ -23,7 +23,7 @@ func TestCrosClangHostConfig(t *testing.T) { gomaEnv := "GOMACC_PATH=" + gomaPath goldenFiles := []goldenFile{ - createClangPathGoldenInputs(gomaEnv), + createClangPathGoldenInputs(ctx, gomaEnv), createGoldenInputsForAllTargets("clang", mainCc), createGoldenInputsForAllTargets("clang", "-ftrapv", mainCc), createSanitizerGoldenInputs("clang"), @@ -48,7 +48,7 @@ func TestCrosGccHostConfig(t *testing.T) { // Note: The old gcc host wrapper is very limited and only adds flags. // So we only test very few things here. goldenFiles := []goldenFile{ - createGccPathGoldenInputs(gomaEnv), + createGccPathGoldenInputs(ctx, gomaEnv), createGoldenInputsForAllTargets("gcc", mainCc), createGccArgsGoldenInputs(), } diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json b/compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json index a9a5d32e..f78549a8 100644 --- a/compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json +++ b/compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json @@ -255,5 +255,92 @@ "exitcode": 1 } ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/tmp/stable/clang", + "args": [ + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "main.cc" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/tmp/stable/a/b/c/d/e/f/g/clang", + "args": [ + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "main.cc" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/tmp/stable/a/b/c/d/e/f/g/clang", + "args": [ + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "main.cc" + ] + } + } + ] } ] diff --git a/compiler_wrapper/testdata/cros_gcc_host_golden/gcc_path.json b/compiler_wrapper/testdata/cros_gcc_host_golden/gcc_path.json index a027446e..2b6db77f 100644 --- a/compiler_wrapper/testdata/cros_gcc_host_golden/gcc_path.json +++ b/compiler_wrapper/testdata/cros_gcc_host_golden/gcc_path.json @@ -52,5 +52,77 @@ "exitcode": 1 } ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-gcc.real", + "args": [ + "-Wno-maybe-uninitialized", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "main.cc" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc.real", + "args": [ + "-Wno-maybe-uninitialized", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "main.cc" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-gcc.real", + "args": [ + "-Wno-maybe-uninitialized", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "main.cc" + ] + } + } + ] } ] diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clang_path.json b/compiler_wrapper/testdata/cros_hardened_golden/clang_path.json index d838707a..a2a03b72 100644 --- a/compiler_wrapper/testdata/cros_hardened_golden/clang_path.json +++ b/compiler_wrapper/testdata/cros_hardened_golden/clang_path.json @@ -361,5 +361,140 @@ "exitcode": 1 } ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "a/b/usr/bin/clang", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-Ba/b/bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "a/b/usr/bin/clang", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-Ba/b/bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] } ] diff --git a/compiler_wrapper/testdata/cros_hardened_golden/gcc_path.json b/compiler_wrapper/testdata/cros_hardened_golden/gcc_path.json index 94cda05d..0d32ad03 100644 --- a/compiler_wrapper/testdata/cros_hardened_golden/gcc_path.json +++ b/compiler_wrapper/testdata/cros_hardened_golden/gcc_path.json @@ -78,5 +78,116 @@ "exitcode": 1 } ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/tmp/stable/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "symlinked/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] } ] diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json index 78169313..ce07459e 100644 --- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json +++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json @@ -319,5 +319,119 @@ "exitcode": 1 } ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/clang", + "args": [ + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "a/b/usr/bin/clang", + "args": [ + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-Ba/b/bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "a/b/usr/bin/clang", + "args": [ + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-Ba/b/bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + } + ] } ] diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_path.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_path.json index 59cbf865..66957f5b 100644 --- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_path.json +++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_path.json @@ -66,5 +66,98 @@ "exitcode": 1 } ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-gcc.real", + "args": [ + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc.real", + "args": [ + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-gcc.real", + "args": [ + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ] + } + } + ] } ] diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json index 0141b7bb..a2744a5f 100644 --- a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json +++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json @@ -312,5 +312,119 @@ "exitcode": 1 } ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "a/b/usr/bin/clang", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "main.cc", + "-Ba/b/bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "a/b/usr/bin/clang", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "main.cc", + "-Ba/b/bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] } ] diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/gcc_path.json b/compiler_wrapper/testdata/cros_nonhardened_golden/gcc_path.json index 302b57e7..e3b5772a 100644 --- a/compiler_wrapper/testdata/cros_nonhardened_golden/gcc_path.json +++ b/compiler_wrapper/testdata/cros_nonhardened_golden/gcc_path.json @@ -70,5 +70,104 @@ "exitcode": 1 } ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/tmp/stable/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Wno-maybe-uninitialized", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "-Wtrampolines", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Wno-maybe-uninitialized", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "-Wtrampolines", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "symlinked/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "symlinked/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Wno-maybe-uninitialized", + "-Wno-unused-local-typedefs", + "-Wno-deprecated-declarations", + "-Wtrampolines", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] } ] diff --git a/compiler_wrapper/testutil_test.go b/compiler_wrapper/testutil_test.go index d7016018..da014ac9 100644 --- a/compiler_wrapper/testutil_test.go +++ b/compiler_wrapper/testutil_test.go @@ -174,6 +174,12 @@ func (ctx *testContext) writeFile(fullFileName string, fileContent string) { } func (ctx *testContext) symlink(oldname string, newname string) { + if !filepath.IsAbs(oldname) { + oldname = filepath.Join(ctx.tempDir, oldname) + } + if !filepath.IsAbs(newname) { + newname = filepath.Join(ctx.tempDir, newname) + } if err := os.MkdirAll(filepath.Dir(newname), 0777); err != nil { ctx.t.Fatal(err) } |