aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2023-08-16 17:45:14 -0700
committerGopher Robot <gobot@golang.org>2023-09-01 04:33:32 +0000
commit38b623f42da899ba7fd6b3fd791a7a72ebd5fad0 (patch)
tree6af67c42dbcb20fef250f2f158553997ac100399 /src
parent62fb281cf72d4b7fa0a29500911a4af3a244f90f (diff)
downloadgo-38b623f42da899ba7fd6b3fd791a7a72ebd5fad0.tar.xz
syscall: fix skipping TestUseCgroupFD
The check in prepareCgroupFD tried to find out if clone3 with CLONE_INTO_CGROUP flag is supported, by supplying arguments in SysProcAttr that will make ForkExec use clone3 with CLONE_INTO_CGROUP and fail. CL 456375 inadvertently broke the above check by adding more errno values to ignore. As a result, TestUseCgroupFD is always skipped, even when the test could in fact be run. Fix by removing the check entirely, instead let's use the functionality and figure out from the errno if this has failed because of unsupported syscall, lack of permissions, or other reason. Change-Id: I108b27b6cfeec390ebd3f161ac39e8597569b666 Reviewed-on: https://go-review.googlesource.com/c/go/+/520265 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/syscall/exec_linux_test.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go
index 873ae4f915..33fa79a81d 100644
--- a/src/syscall/exec_linux_test.go
+++ b/src/syscall/exec_linux_test.go
@@ -410,17 +410,6 @@ func prepareCgroupFD(t *testing.T) (int, string) {
t.Skipf("cgroup v2 not available (/proc/self/cgroup contents: %q)", selfCg)
}
- // Need clone3 with CLONE_INTO_CGROUP support.
- _, err = syscall.ForkExec("non-existent binary", nil, &syscall.ProcAttr{
- Sys: &syscall.SysProcAttr{
- UseCgroupFD: true,
- CgroupFD: -1,
- },
- })
- if testenv.SyscallIsNotSupported(err) {
- t.Skipf("clone3 with CLONE_INTO_CGROUP not available: %v", err)
- }
-
// Need an ability to create a sub-cgroup.
subCgroup, err := os.MkdirTemp(prefix+string(bytes.TrimSpace(cg)), "subcg-")
if err != nil {
@@ -459,6 +448,13 @@ func TestUseCgroupFD(t *testing.T) {
}
out, err := cmd.CombinedOutput()
if err != nil {
+ if err != syscall.EINVAL && testenv.SyscallIsNotSupported(err) {
+ // Can be one of:
+ // - clone3 not supported (old kernel);
+ // - clone3 not allowed (by e.g. seccomp);
+ // - lack of CAP_SYS_ADMIN.
+ t.Skipf("clone3 with CLONE_INTO_CGROUP not available: %v", err)
+ }
t.Fatalf("Cmd failed with err %v, output: %s", err, out)
}
// NB: this wouldn't work with cgroupns.