mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Added a timeout to TestCmdStreamLargeStderr.
This commit is contained in:
parent
f483b214bb
commit
68278b66c5
1 changed files with 13 additions and 5 deletions
|
@ -6,20 +6,28 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCmdStreamLargeStderr(t *testing.T) {
|
func TestCmdStreamLargeStderr(t *testing.T) {
|
||||||
// This test checks for deadlock; thus, the main failure mode of this test is deadlocking.
|
|
||||||
// FIXME implement a timeout to avoid blocking the whole test suite when this test fails
|
|
||||||
cmd := exec.Command("/bin/sh", "-c", "dd if=/dev/zero bs=1k count=1000 of=/dev/stderr; echo hello")
|
cmd := exec.Command("/bin/sh", "-c", "dd if=/dev/zero bs=1k count=1000 of=/dev/stderr; echo hello")
|
||||||
out, err := CmdStream(cmd)
|
out, err := CmdStream(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to start command: " + err.Error())
|
t.Fatalf("Failed to start command: " + err.Error())
|
||||||
}
|
}
|
||||||
_, err = io.Copy(ioutil.Discard, out)
|
errCh := make(chan error)
|
||||||
|
go func() {
|
||||||
|
_, err := io.Copy(ioutil.Discard, out)
|
||||||
|
errCh <- err
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case err := <-errCh:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Command should not have failed (err=%s...)", err.Error()[:100])
|
t.Fatalf("Command should not have failed (err=%s...)", err.Error()[:100])
|
||||||
}
|
}
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
t.Fatalf("Command did not complete in 5 seconds; probable deadlock")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCmdStreamBad(t *testing.T) {
|
func TestCmdStreamBad(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue