Merge pull request #7083 from mheon/6983_bugfix

Fix Panic with -t and -a stderr
This commit is contained in:
Victor Vieux 2014-07-17 18:41:24 -07:00
Родитель 7a5ddd5df8 1476f295ac
Коммит 5948b105e7
2 изменённых файлов: 49 добавлений и 1 удалений

Просмотреть файл

@ -88,7 +88,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
}()
// When TTY is ON, use regular copy
if setRawTerminal {
if setRawTerminal && stdout != nil {
_, err = io.Copy(stdout, br)
} else {
_, err = utils.StdCopy(stdout, stderr, br)

Просмотреть файл

@ -1247,3 +1247,51 @@ func TestDnsOptionsBasedOnHostResolvConf(t *testing.T) {
logDone("run - dns options based on host resolv.conf")
}
// Regression test for #6983
func TestAttachStdErrOnlyTTYMode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-t", "-a", "stderr", "busybox", "true")
exitCode, err := runCommand(cmd)
if err != nil {
t.Fatal(err)
} else if exitCode != 0 {
t.Fatalf("Container should have exited with error code 0")
}
deleteAllContainers()
logDone("run - Attach stderr only with -t")
}
// Regression test for #6983
func TestAttachStdOutOnlyTTYMode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-t", "-a", "stdout", "busybox", "true")
exitCode, err := runCommand(cmd)
if err != nil {
t.Fatal(err)
} else if exitCode != 0 {
t.Fatalf("Container should have exited with error code 0")
}
deleteAllContainers()
logDone("run - Attach stdout only with -t")
}
// Regression test for #6983
func TestAttachStdOutAndErrTTYMode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-t", "-a", "stdout", "-a", "stderr", "busybox", "true")
exitCode, err := runCommand(cmd)
if err != nil {
t.Fatal(err)
} else if exitCode != 0 {
t.Fatalf("Container should have exited with error code 0")
}
deleteAllContainers()
logDone("run - Attach stderr and stdout with -t")
}