Skip to content

Commit 9cf209f

Browse files
author
Bryan C. Mills
committed
runtime/testdata/testprog: use testenv.SyscallIsNotSupported to check syscall.Unshare
syscall.Unshare is the sort of system call that may be blocked in a container environment, and experience has shown that different container implementations choose from a variety of different error codes for blocked syscalls. In particular, the patch in https://git.alpinelinux.org/aports/tree/community/go/tests-unshare-enosys.patch seems to suggest that the container environment used to test the Go distribution on Alpine Linux returns ENOSYS instead of EPERM. The existing testenv.SyscallIsNotSupported helper checks for the kinds of error codes we have seen from containers in practice, so let's use that here. For #62053. Updates #29366. Change-Id: Ic6755f7224fcdc0cb8b25dde2d6047ceb5c3ffdf Reviewed-on: https://go-review.googlesource.com/c/go/+/520057 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
1 parent 9049d77 commit 9cf209f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/runtime/testdata/testprog/syscalls_linux.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package main
77
import (
88
"bytes"
99
"fmt"
10+
"internal/testenv"
1011
"os"
1112
"syscall"
1213
)
@@ -44,11 +45,8 @@ func getcwd() (string, error) {
4445

4546
func unshareFs() error {
4647
err := syscall.Unshare(syscall.CLONE_FS)
47-
if err != nil {
48-
errno, ok := err.(syscall.Errno)
49-
if ok && errno == syscall.EPERM {
50-
return errNotPermitted
51-
}
48+
if testenv.SyscallIsNotSupported(err) {
49+
return errNotPermitted
5250
}
5351
return err
5452
}

0 commit comments

Comments
 (0)