1
0
mirror of https://github.com/moby/moby.git synced 2025-07-30 18:23:29 +03:00

reuse same code for setting pipes in run/exec

This also moves `exec -i` test to _unix_test.go because it seems to need a
pty to reliably reproduce the behavior.

Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
This commit is contained in:
Daniel, Dao Quang Minh
2015-04-22 23:37:15 +00:00
parent 3c9ae03a86
commit ade8146aa8
4 changed files with 87 additions and 91 deletions

View File

@ -38,44 +38,6 @@ func (s *DockerSuite) TestExec(c *check.C) {
}
func (s *DockerSuite) TestExecInteractiveStdinClose(c *check.C) {
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "-itd", "busybox", "/bin/cat"))
if err != nil {
c.Fatal(err)
}
contId := strings.TrimSpace(out)
returnchan := make(chan struct{})
go func() {
var err error
cmd := exec.Command(dockerBinary, "exec", "-i", contId, "/bin/ls", "/")
cmd.Stdin = os.Stdin
if err != nil {
c.Fatal(err)
}
out, err := cmd.CombinedOutput()
if err != nil {
c.Fatal(err, string(out))
}
if string(out) == "" {
c.Fatalf("Output was empty, likely blocked by standard input")
}
returnchan <- struct{}{}
}()
select {
case <-returnchan:
case <-time.After(10 * time.Second):
c.Fatal("timed out running docker exec")
}
}
func (s *DockerSuite) TestExecInteractive(c *check.C) {
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")