aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJian Cai <jiancai@google.com>2020-01-23 15:03:04 -0800
committerJian Cai <jiancai@google.com>2020-02-13 04:09:36 +0000
commitc4615d189f6b0dc4c116fc0a78ac295f7427170e (patch)
tree33b7f1278427e157821c7e6a091dedad2410b3f9
parent8477fefd6c54adec7a45f7a1c9c2119f7aca2d2e (diff)
downloadtoolchain-utils-c4615d189f6b0dc4c116fc0a78ac295f7427170e.tar.gz
compiler_wrapper: update the presubmit tests.
Update paths used in test cases. BUG=chromium:1042452 TEST=verified locally. Change-Id: I0ddca454280f91508b632785ec9b417328e2ab3e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2018235 Tested-by: Jian Cai <jiancai@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
-rw-r--r--compiler_wrapper/goldenutil_test.go12
-rw-r--r--compiler_wrapper/testdata/android_golden/bisect.json6
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/bisect.json6
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/bisect.json6
-rw-r--r--compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json6
-rw-r--r--compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json6
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json6
7 files changed, 23 insertions, 25 deletions
diff --git a/compiler_wrapper/goldenutil_test.go b/compiler_wrapper/goldenutil_test.go
index 23e003c5..2b391d73 100644
--- a/compiler_wrapper/goldenutil_test.go
+++ b/compiler_wrapper/goldenutil_test.go
@@ -14,7 +14,6 @@ import (
"os"
"path/filepath"
"regexp"
- "runtime"
"strings"
)
@@ -128,6 +127,11 @@ func fillGoldenResults(ctx *testContext, files []goldenFile) []goldenFile {
}
cmdResult := record.Cmds[len(newCmds)]
cmdResult.Cmd = cmd
+ if numEnvUpdates := len(cmdResult.Cmd.EnvUpdates); numEnvUpdates > 0 {
+ if strings.HasPrefix(cmdResult.Cmd.EnvUpdates[numEnvUpdates-1], "PYTHONPATH") {
+ cmdResult.Cmd.EnvUpdates[numEnvUpdates-1] = "PYTHONPATH=/somepath/test_binary"
+ }
+ }
newCmds = append(newCmds, cmdResult)
io.WriteString(stdout, cmdResult.Stdout)
io.WriteString(stderr, cmdResult.Stderr)
@@ -146,13 +150,7 @@ func fillGoldenResults(ctx *testContext, files []goldenFile) []goldenFile {
// Create an empty wrapper at the given path.
// Needed as we are resolving symlinks which stats the wrapper file.
ctx.writeFile(record.WrapperCmd.Cmd.Path, "")
- // Assign a fixed path to os.Args[0] to pass the test.
- tmp := os.Args[0]
- // callCompiler verifies os.Args[0] exists, so use a real file.
- _, file, _, _ := runtime.Caller(1)
- os.Args[0] = file
record.WrapperCmd.ExitCode = callCompiler(ctx, ctx.cfg, record.WrapperCmd.Cmd)
- os.Args[0] = tmp
if hasInternalError(ctx.stderrString()) {
ctx.t.Errorf("found an internal error for wrapperCmd %#v and env #%v. Got: %s",
record.WrapperCmd.Cmd, record.Env, ctx.stderrString())
diff --git a/compiler_wrapper/testdata/android_golden/bisect.json b/compiler_wrapper/testdata/android_golden/bisect.json
index be07da68..25df7f17 100644
--- a/compiler_wrapper/testdata/android_golden/bisect.json
+++ b/compiler_wrapper/testdata/android_golden/bisect.json
@@ -27,7 +27,7 @@
"main.cc"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -62,7 +62,7 @@
"main.cc"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -100,7 +100,7 @@
"main.cc"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json b/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json
index ad4feac3..28adfee2 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json
@@ -41,7 +41,7 @@
"-Wno-implicit-int-float-conversion"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -90,7 +90,7 @@
"-Wno-implicit-int-float-conversion"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -142,7 +142,7 @@
"-Wno-implicit-int-float-conversion"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/bisect.json b/compiler_wrapper/testdata/cros_hardened_golden/bisect.json
index 6e1d4981..b00f9740 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/bisect.json
@@ -55,7 +55,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -118,7 +118,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -184,7 +184,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json
index 6e1d4981..b00f9740 100644
--- a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json
@@ -55,7 +55,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -118,7 +118,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -184,7 +184,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json
index 3fafcf01..5075f843 100644
--- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json
@@ -50,7 +50,7 @@
"x86_64-cros-linux-gnu"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -108,7 +108,7 @@
"x86_64-cros-linux-gnu"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -169,7 +169,7 @@
"x86_64-cros-linux-gnu"
],
"env_updates": [
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json b/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json
index 7d2acdac..cb5dea01 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json
@@ -47,7 +47,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -102,7 +102,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
}
}
@@ -160,7 +160,7 @@
"CCACHE_DIR=/var/cache/distfiles/ccache",
"CCACHE_UMASK=002",
"CCACHE_CPP2=yes",
- "PYTHONPATH=/media/storage/jiancai/chromeos/src/third_party/toolchain-utils/compiler_wrapper"
+ "PYTHONPATH=/somepath/test_binary"
]
},
"stdout": "somemessage",