mirror of https://github.com/golang/go.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 <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
dfdf55158d
commit
e828fbdffe
|
|
@ -23,10 +23,8 @@ func TestFindExecutableVsNoexec(t *testing.T) {
|
||||||
// Create a tmpfs mount.
|
// Create a tmpfs mount.
|
||||||
err := syscall.Mount("tmpfs", tmp, "tmpfs", 0, "")
|
err := syscall.Mount("tmpfs", tmp, "tmpfs", 0, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.Geteuid() == 0 {
|
// Usually this means lack of CAP_SYS_ADMIN, but there might be
|
||||||
t.Fatalf("tmpfs mount failed: %v", err)
|
// other reasons, expecially in restricted test environments.
|
||||||
}
|
|
||||||
// Requires root or CAP_SYS_ADMIN.
|
|
||||||
t.Skipf("requires ability to mount tmpfs (%v)", err)
|
t.Skipf("requires ability to mount tmpfs (%v)", err)
|
||||||
}
|
}
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue