From: Kir Kolyshkin Date: Wed, 7 Sep 2022 17:30:46 +0000 (-0700) Subject: os/exec: skip TestFindExecutableVsNoexec if mount failed X-Git-Tag: go1.20rc1~1130 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e828fbdffe3318b976aa12d2aee27d4a53bc9f12;p=gostls13.git os/exec: skip TestFindExecutableVsNoexec if mount failed Apparently, some testing environments do not allow root to mount tmpfs (due to e.g. AppArmor profile disallowing mount(2) syscall). Always skip the test if the mount has failed. Fixes the test issue introduced by CL 414824. Change-Id: Ic565d2e6f277f2926d85a351be7df2498ffba656 Reviewed-on: https://go-review.googlesource.com/c/go/+/429175 Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Bryan Mills Auto-Submit: Bryan Mills Reviewed-by: Michael Knyszek --- diff --git a/src/os/exec/lp_linux_test.go b/src/os/exec/lp_linux_test.go index 96051b5490..5d77427d89 100644 --- a/src/os/exec/lp_linux_test.go +++ b/src/os/exec/lp_linux_test.go @@ -23,10 +23,8 @@ func TestFindExecutableVsNoexec(t *testing.T) { // Create a tmpfs mount. err := syscall.Mount("tmpfs", tmp, "tmpfs", 0, "") if err != nil { - if os.Geteuid() == 0 { - t.Fatalf("tmpfs mount failed: %v", err) - } - // Requires root or CAP_SYS_ADMIN. + // Usually this means lack of CAP_SYS_ADMIN, but there might be + // other reasons, expecially in restricted test environments. t.Skipf("requires ability to mount tmpfs (%v)", err) } t.Cleanup(func() {