import (
"fmt"
+ "internal/testenv"
"os"
"runtime"
"sort"
if syscall.Getuid() != 0 {
t.Skip("skipping root only test")
}
+ if testing.Short() && testenv.Builder() != "" && os.Getenv("USER") == "swarming" {
+ // The Go build system's swarming user is known not to be root.
+ // Unfortunately, it sometimes appears as root due the current
+ // implementation of a no-network check using 'unshare -n -r'.
+ // Since this test does need root to work, we need to skip it.
+ t.Skip("skipping root only test on a non-root builder")
+ }
if runtime.GOOS == "linux" {
if _, err := os.Stat("/etc/alpine-release"); err == nil {
t.Skip("skipping failing test on alpine - go.dev/issue/19938")
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)
}
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)
}
import (
"bufio"
"fmt"
+ "internal/testenv"
"io"
"os"
"os/exec"
if os.Getuid() != 0 {
t.Skip("skipping root only test")
}
+ if testing.Short() && testenv.Builder() != "" && os.Getenv("USER") == "swarming" {
+ // The Go build system's swarming user is known not to be root.
+ // Unfortunately, it sometimes appears as root due the current
+ // implementation of a no-network check using 'unshare -n -r'.
+ // Since this test does need root to work, we need to skip it.
+ t.Skip("skipping root only test on a non-root builder")
+ }
// Copy the test binary to a location that a non-root user can read/execute
// after we drop privileges
import (
"fmt"
+ "internal/testenv"
"io"
"io/fs"
"os"
if os.Getuid() != 0 {
t.Skip("skipping root only test")
}
+ if testing.Short() && testenv.Builder() != "" && os.Getenv("USER") == "swarming" {
+ // The Go build system's swarming user is known not to be root.
+ // Unfortunately, it sometimes appears as root due the current
+ // implementation of a no-network check using 'unshare -n -r'.
+ // Since this test does need root to work, we need to skip it.
+ t.Skip("skipping root only test on a non-root builder")
+ }
if runtime.GOOS == "android" {
t.Skip("skipping on rooted android, see issue 27364")
if syscall.Getuid() != 0 {
t.Skip("skipping root only test")
}
+ if testing.Short() && testenv.Builder() != "" && os.Getenv("USER") == "swarming" {
+ // The Go build system's swarming user is known not to be root.
+ // Unfortunately, it sometimes appears as root due the current
+ // implementation of a no-network check using 'unshare -n -r'.
+ // Since this test does need root to work, we need to skip it.
+ t.Skip("skipping root only test on a non-root builder")
+ }
if _, err := os.Stat("/etc/alpine-release"); err == nil {
t.Skip("skipping glibc test on alpine - go.dev/issue/19938")
}