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/cros_hardened_config_test.go | |
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/cros_hardened_config_test.go')
-rw-r--r-- | compiler_wrapper/cros_hardened_config_test.go | 42 |
1 files changed, 36 insertions, 6 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, + }, }, } } |