]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.12] syscall: skip TestSyscallNoError when temp dir is mounted...
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 15 Feb 2019 18:55:45 +0000 (18:55 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 15 Feb 2019 21:10:28 +0000 (21:10 +0000)
Fixes #30258

Change-Id: I73b63eb9d3aca00f562fdc3af010e96269bb6b9c
Reviewed-on: https://go-review.googlesource.com/c/162891
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
(cherry picked from commit 5fcc24074f8e48cd8404bd250c2c268aca2bc3d2)
Reviewed-on: https://go-review.googlesource.com/c/162818
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

src/syscall/syscall_linux_test.go

index 293549a841d05a5124555d12566c1a256a5d0f2e..8a578639bd8d86b9cc335404bfb2f20cb87018b9 100644 (file)
@@ -360,10 +360,23 @@ func TestSyscallNoError(t *testing.T) {
                strconv.FormatUint(uint64(-uid), 10) + " / " +
                strconv.FormatUint(uint64(uid), 10)
        if got != want {
+               if filesystemIsNoSUID(tmpBinary) {
+                       t.Skip("skipping test when temp dir is mounted nosuid")
+               }
                t.Errorf("expected %s, got %s", want, got)
        }
 }
 
+// filesystemIsNoSUID reports whether the filesystem for the given
+// path is mounted nosuid.
+func filesystemIsNoSUID(path string) bool {
+       var st syscall.Statfs_t
+       if syscall.Statfs(path, &st) != nil {
+               return false
+       }
+       return st.Flags&syscall.MS_NOSUID != 0
+}
+
 func syscallNoError() {
        // Test that the return value from SYS_GETEUID32 (which cannot fail)
        // doesn't get treated as an error (see https://golang.org/issue/22924)