aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2020-03-04 17:47:17 -0800
committerGeorge Burgess <gbiv@chromium.org>2020-03-05 02:03:33 +0000
commit49458a0af73d90313633c09d26f55b1a9f4172fa (patch)
tree9093c7a984ee9451859e2ac4597810428293f50c
parentc94f243ccfe39115e7a648ffbb6f7594b0d2e9ea (diff)
downloadtoolchain-utils-49458a0af73d90313633c09d26f55b1a9f4172fa.tar.gz
wrapper: make a test consider the caller's umask
Apparently my umask on my glinux system is 027 outside of the chroot, so this test fails for me. Mask out any bits that can't be set due to our umask. BUG=None TEST=go test Change-Id: I683a1ab315479e277d8b9b1fd3b61c96818bc055 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2088433 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
-rw-r--r--compiler_wrapper/compile_with_fallback_test.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler_wrapper/compile_with_fallback_test.go b/compiler_wrapper/compile_with_fallback_test.go
index b36c3e18..a67f3eb9 100644
--- a/compiler_wrapper/compile_with_fallback_test.go
+++ b/compiler_wrapper/compile_with_fallback_test.go
@@ -12,9 +12,18 @@ import (
"os"
"path/filepath"
"strings"
+ "syscall"
"testing"
)
+// Save this off before goroutines start running, since this necessarily involves modifying the
+// value for our umask, and that screams subtle race conditions. :)
+var umaskAtStartup = func() os.FileMode {
+ umask := syscall.Umask(0)
+ syscall.Umask(umask)
+ return os.FileMode(umask)
+}()
+
func TestOmitFallbackCompileForSuccessfulCall(t *testing.T) {
withCompileWithFallbackTestContext(t, func(ctx *testContext) {
ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(clangAndroid, mainCc)))
@@ -239,7 +248,7 @@ someerror
}
entry, _ := os.Lstat(filepath.Join(ctx.tempDir, "fallback_stderr"))
- if entry.Mode()&0777 != 0644 {
+ if entry.Mode()&0777 != 0644 & ^umaskAtStartup {
t.Errorf("unexpected mode for logfile. Got: %#o", entry.Mode())
}
})