Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -104,7 +104,11 @@ func (s *DockerSuite) TestEventsLimit(c *check.C) {
|
| 104 | 104 |
waitGroup.Add(1) |
| 105 | 105 |
go func() {
|
| 106 | 106 |
defer waitGroup.Done() |
| 107 |
- errChan <- exec.Command(dockerBinary, args...).Run() |
|
| 107 |
+ out, err := exec.Command(dockerBinary, args...).CombinedOutput() |
|
| 108 |
+ if err != nil {
|
|
| 109 |
+ err = fmt.Errorf("%v: %s", err, string(out))
|
|
| 110 |
+ } |
|
| 111 |
+ errChan <- err |
|
| 108 | 112 |
}() |
| 109 | 113 |
} |
| 110 | 114 |
|
| ... | ... |
@@ -76,12 +76,8 @@ func (s *DockerSuite) TestRunExitCodeZero(c *check.C) {
|
| 76 | 76 |
// the exit code should be 1 |
| 77 | 77 |
func (s *DockerSuite) TestRunExitCodeOne(c *check.C) {
|
| 78 | 78 |
_, exitCode, err := dockerCmdWithError("run", "busybox", "false")
|
| 79 |
- if err != nil && !strings.Contains("exit status 1", fmt.Sprintf("%s", err)) {
|
|
| 80 |
- c.Fatal(err) |
|
| 81 |
- } |
|
| 82 |
- if exitCode != 1 {
|
|
| 83 |
- c.Errorf("container should've exited with exit code 1. Got %d", exitCode)
|
|
| 84 |
- } |
|
| 79 |
+ c.Assert(err, checker.NotNil) |
|
| 80 |
+ c.Assert(exitCode, checker.Equals, 1) |
|
| 85 | 81 |
} |
| 86 | 82 |
|
| 87 | 83 |
// it should be possible to pipe in data via stdin to a process running in a container |
| ... | ... |
@@ -3907,6 +3903,9 @@ func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *check.C) {
|
| 3907 | 3907 |
in, err := cmd.StdinPipe() |
| 3908 | 3908 |
c.Assert(err, check.IsNil) |
| 3909 | 3909 |
defer in.Close() |
| 3910 |
+ stdout := bytes.NewBuffer(nil) |
|
| 3911 |
+ cmd.Stdout = stdout |
|
| 3912 |
+ cmd.Stderr = stdout |
|
| 3910 | 3913 |
c.Assert(cmd.Start(), check.IsNil) |
| 3911 | 3914 |
|
| 3912 | 3915 |
waitChan := make(chan error) |
| ... | ... |
@@ -3916,7 +3915,7 @@ func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *check.C) {
|
| 3916 | 3916 |
|
| 3917 | 3917 |
select {
|
| 3918 | 3918 |
case err := <-waitChan: |
| 3919 |
- c.Assert(err, check.IsNil) |
|
| 3919 |
+ c.Assert(err, check.IsNil, check.Commentf(stdout.String())) |
|
| 3920 | 3920 |
case <-time.After(30 * time.Second): |
| 3921 | 3921 |
c.Fatal("timeout waiting for command to exit")
|
| 3922 | 3922 |
} |
| ... | ... |
@@ -24,8 +24,8 @@ func (s *DockerSuite) TestStartAttachReturnsOnError(c *check.C) {
|
| 24 | 24 |
go func() {
|
| 25 | 25 |
// Attempt to start attached to the container that won't start |
| 26 | 26 |
// This should return an error immediately since the container can't be started |
| 27 |
- if _, _, err := dockerCmdWithError("start", "-a", "test2"); err == nil {
|
|
| 28 |
- ch <- fmt.Errorf("Expected error but got none")
|
|
| 27 |
+ if out, _, err := dockerCmdWithError("start", "-a", "test2"); err == nil {
|
|
| 28 |
+ ch <- fmt.Errorf("Expected error but got none:\n%s", out)
|
|
| 29 | 29 |
} |
| 30 | 30 |
close(ch) |
| 31 | 31 |
}() |
| ... | ... |
@@ -35,10 +35,12 @@ func (s *DockerSuite) TestWaitBlockedExitZero(c *check.C) {
|
| 35 | 35 |
|
| 36 | 36 |
chWait := make(chan string) |
| 37 | 37 |
go func() {
|
| 38 |
+ chWait <- "" |
|
| 38 | 39 |
out, _, _ := runCommandWithOutput(exec.Command(dockerBinary, "wait", containerID)) |
| 39 | 40 |
chWait <- out |
| 40 | 41 |
}() |
| 41 | 42 |
|
| 43 |
+ <-chWait // make sure the goroutine is started |
|
| 42 | 44 |
time.Sleep(100 * time.Millisecond) |
| 43 | 45 |
dockerCmd(c, "stop", containerID) |
| 44 | 46 |
|
| ... | ... |
@@ -84,7 +86,7 @@ func (s *DockerSuite) TestWaitBlockedExitRandom(c *check.C) {
|
| 84 | 84 |
|
| 85 | 85 |
select {
|
| 86 | 86 |
case err := <-chWait: |
| 87 |
- c.Assert(err, checker.IsNil) |
|
| 87 |
+ c.Assert(err, checker.IsNil, check.Commentf(waitCmdOut.String())) |
|
| 88 | 88 |
status, err := waitCmdOut.ReadString('\n')
|
| 89 | 89 |
c.Assert(err, checker.IsNil) |
| 90 | 90 |
c.Assert(strings.TrimSpace(status), checker.Equals, "99", check.Commentf("expected exit 99, got %s", status))
|
| ... | ... |
@@ -468,7 +468,11 @@ func dockerCmdWithError(args ...string) (string, int, error) {
|
| 468 | 468 |
if err := validateArgs(args...); err != nil {
|
| 469 | 469 |
return "", 0, err |
| 470 | 470 |
} |
| 471 |
- return integration.DockerCmdWithError(dockerBinary, args...) |
|
| 471 |
+ out, code, err := integration.DockerCmdWithError(dockerBinary, args...) |
|
| 472 |
+ if err != nil {
|
|
| 473 |
+ err = fmt.Errorf("%v: %s", err, out)
|
|
| 474 |
+ } |
|
| 475 |
+ return out, code, err |
|
| 472 | 476 |
} |
| 473 | 477 |
|
| 474 | 478 |
func dockerCmdWithStdoutStderr(c *check.C, args ...string) (string, string, int) {
|