mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
Handle error from GetDevice early
Also more verbose error. Fixes panic from #7701 Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
This commit is contained in:
@@ -1630,3 +1630,17 @@ func TestWriteResolvFileAndNotCommit(t *testing.T) {
|
||||
|
||||
logDone("run - write to /etc/resolv.conf and not commited")
|
||||
}
|
||||
|
||||
func TestRunWithBadDevice(t *testing.T) {
|
||||
name := "baddevice"
|
||||
cmd := exec.Command(dockerBinary, "run", "--name", name, "--device", "/etc", "busybox", "true")
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err == nil {
|
||||
t.Fatal("Run should fail with bad device")
|
||||
}
|
||||
expected := `"/etc": not a device node`
|
||||
if !strings.Contains(out, expected) {
|
||||
t.Fatalf("Output should contain %q, actual out: %q", expected, out)
|
||||
}
|
||||
logDone("run - error with bad device")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user