Merge pull request #37143 from arm64b/copy-after-command-exit
Alternative failure mitigation of `TestExecInteractiveStdinClose` Upstream-commit: 2d7ae3e7e5bebb324be062e5d3f01f489f107285 Component: engine
This commit is contained in:
@ -25,10 +25,6 @@ func (s *DockerSuite) TestExecInteractiveStdinClose(c *check.C) {
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
b := bytes.NewBuffer(nil)
|
||||
go func() {
|
||||
io.Copy(b, p)
|
||||
p.Close()
|
||||
}()
|
||||
|
||||
ch := make(chan error)
|
||||
go func() { ch <- cmd.Wait() }()
|
||||
@ -36,9 +32,14 @@ func (s *DockerSuite) TestExecInteractiveStdinClose(c *check.C) {
|
||||
select {
|
||||
case err := <-ch:
|
||||
c.Assert(err, checker.IsNil)
|
||||
output := b.String()
|
||||
io.Copy(b, p)
|
||||
p.Close()
|
||||
bs := b.Bytes()
|
||||
bs = bytes.Trim(bs, "\x00")
|
||||
output := string(bs[:])
|
||||
c.Assert(strings.TrimSpace(output), checker.Equals, "hello")
|
||||
case <-time.After(5 * time.Second):
|
||||
p.Close()
|
||||
c.Fatal("timed out running docker exec")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user