]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: skip TestUseCgroupFD if cgroupfs not mounted
authorShengjing Zhu <zsj950618@gmail.com>
Thu, 5 Jan 2023 07:00:25 +0000 (15:00 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 6 Jan 2023 18:22:52 +0000 (18:22 +0000)
When building in schroot (for building Debian package),
the cgroupfs is not mounted in schroot (only sysfs is mounted).

Change-Id: Ieddac7b2f334d58d832f5d84d81af812badf3720
Reviewed-on: https://go-review.googlesource.com/c/go/+/460539
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

src/syscall/exec_linux_test.go

index 1e21fffaef9f1c8ae56eee2959caa373d451f534..a6900f9033829e1df62bebabf0fda82a8a4ab118 100644 (file)
@@ -505,8 +505,9 @@ func prepareCgroupFD(t *testing.T) (int, string) {
        // Need an ability to create a sub-cgroup.
        subCgroup, err := os.MkdirTemp(prefix+string(bytes.TrimSpace(cg)), "subcg-")
        if err != nil {
-               // Running in an unprivileged container, this may also return EROFS #57262.
-               if os.IsPermission(err) || errors.Is(err, syscall.EROFS) {
+               // ErrPermission or EROFS (#57262) when running in an unprivileged container.
+               // ErrNotExist when cgroupfs is not mounted in chroot/schroot.
+               if os.IsNotExist(err) || os.IsPermission(err) || errors.Is(err, syscall.EROFS) {
                        t.Skip(err)
                }
                t.Fatal(err)