syscall, cmd/cgo: skip tests that shouldn't run under 'unshare -n -r'

A small number of tests in the main tree are currently skipped in LUCI
because our builders there run tests without root. Unfortunately, these
tests begin to run when run under 'unshare -n -r' as implemented in
the current iteration of a no-network check. Add targeted builder-only
skips so that they don't begin to run and fail with a false positive.

Updates #10719.
For #30612.

Change-Id: I6dd320714a279c395882c1b2ebfbb2fce58f913b
Reviewed-on: https://go-review.googlesource.com/c/go/+/513779
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Dmitri Shuralyov 2023-07-27 19:36:55 -04:00 committed by Gopher Robot
parent f322d67ced
commit 2ad666dea0
4 changed files with 47 additions and 0 deletions

View file

@ -249,6 +249,14 @@ func TestUnshareMountNameSpace(t *testing.T) {
if testenv.SyscallIsNotSupported(err) {
t.Skipf("skipping: could not start process with CLONE_NEWNS: %v", err)
}
if testing.Short() && testenv.Builder() != "" && os.Getenv("USER") == "swarming" {
// The Go build system's swarming user is known not to support
// starting a process with CLONE_NEWNS.
// Unfortunately, it doesn't get recognized as such due the current
// implementation of a no-network check using 'unshare -n -r'.
// Since this test does need start this process, we need to skip it.
t.Skipf("skipping: could not start process with CLONE_NEWNS: %v", err)
}
t.Fatalf("unshare failed: %v\n%s", err, o)
}
@ -301,6 +309,14 @@ func TestUnshareMountNameSpaceChroot(t *testing.T) {
if testenv.SyscallIsNotSupported(err) {
t.Skipf("skipping: could not start process with CLONE_NEWNS and Chroot %q: %v", d, err)
}
if testing.Short() && testenv.Builder() != "" && os.Getenv("USER") == "swarming" {
// The Go build system's swarming user is known not to support
// starting a process with CLONE_NEWNS and Chroot.
// Unfortunately, it doesn't get recognized as such due the current
// implementation of a no-network check using 'unshare -n -r'.
// Since this test does need start this process, we need to skip it.
t.Skipf("skipping: could not start process with CLONE_NEWNS and Chroot %q: %v", d, err)
}
t.Fatalf("unshare failed: %v\n%s", err, o)
}