diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/os/os_test.go | 12 | ||||
| -rw-r--r-- | src/syscall/exec_linux_test.go | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/os/os_test.go b/src/os/os_test.go index b2f45b48f8..a878e40fd2 100644 --- a/src/os/os_test.go +++ b/src/os/os_test.go @@ -1275,15 +1275,19 @@ func TestOpenNoName(t *testing.T) { } } -func run(t *testing.T, cmd []string) string { +func runBinHostname(t *testing.T) string { // Run /bin/hostname and collect output. r, w, err := Pipe() if err != nil { t.Fatal(err) } defer r.Close() - p, err := StartProcess("/bin/hostname", []string{"hostname"}, &ProcAttr{Files: []*File{nil, w, Stderr}}) + const path = "/bin/hostname" + p, err := StartProcess(path, []string{"hostname"}, &ProcAttr{Files: []*File{nil, w, Stderr}}) if err != nil { + if _, err := Stat(path); IsNotExist(err) { + t.Skipf("skipping test; test requires %s but it does not exist", path) + } t.Fatal(err) } w.Close() @@ -1303,7 +1307,7 @@ func run(t *testing.T, cmd []string) string { output = output[0 : n-1] } if output == "" { - t.Fatalf("%v produced no output", cmd) + t.Fatalf("/bin/hostname produced no output") } return output @@ -1345,7 +1349,7 @@ func TestHostname(t *testing.T) { if err != nil { t.Fatalf("%v", err) } - want := run(t, []string{"/bin/hostname"}) + want := runBinHostname(t) if hostname != want { i := strings.Index(hostname, ".") if i < 0 || hostname[0:i] != want { diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go index 6d31941184..eb32cfd4b1 100644 --- a/src/syscall/exec_linux_test.go +++ b/src/syscall/exec_linux_test.go @@ -31,6 +31,9 @@ func whoamiCmd(t *testing.T, uid, gid int, setgroups bool) *exec.Cmd { if os.IsNotExist(err) { t.Skip("kernel doesn't support user namespaces") } + if os.IsPermission(err) { + t.Skip("unable to test user namespaces due to permissions") + } t.Fatalf("Failed to stat /proc/self/ns/user: %v", err) } if isChrooted(t) { |
