diff --git a/api_test.go b/api_test.go index 4af9c78058..71b91c285e 100644 --- a/api_test.go +++ b/api_test.go @@ -731,7 +731,7 @@ func TestPostContainersRestart(t *testing.T) { container, err := runtime.Create( &Config{ Image: GetTestImage(runtime).ID, - Cmd: []string{"/bin/cat"}, + Cmd: []string{"/bin/top"}, OpenStdin: true, }, ) @@ -837,7 +837,7 @@ func TestPostContainersStop(t *testing.T) { container, err := runtime.Create( &Config{ Image: GetTestImage(runtime).ID, - Cmd: []string{"/bin/cat"}, + Cmd: []string{"/bin/top"}, OpenStdin: true, }, ) diff --git a/commands_test.go b/commands_test.go index 2034269eaf..8a71489a2d 100644 --- a/commands_test.go +++ b/commands_test.go @@ -84,10 +84,24 @@ func TestRunHostname(t *testing.T) { } }) + container := globalRuntime.List()[0] + setTimeout(t, "CmdRun timed out", 10*time.Second, func() { <-c + + go func() { + cli.CmdWait(container.ID) + }() + + if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil { + t.Fatal(err) + } }) + // Cleanup pipes + if err := closeWrap(stdout, stdoutPipe); err != nil { + t.Fatal(err) + } } // TestRunWorkdir checks that 'docker run -w' correctly sets a custom working directory @@ -115,10 +129,24 @@ func TestRunWorkdir(t *testing.T) { } }) + container := globalRuntime.List()[0] + setTimeout(t, "CmdRun timed out", 10*time.Second, func() { <-c + + go func() { + cli.CmdWait(container.ID) + }() + + if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil { + t.Fatal(err) + } }) + // Cleanup pipes + if err := closeWrap(stdout, stdoutPipe); err != nil { + t.Fatal(err) + } } // TestRunWorkdirExists checks that 'docker run -w' correctly sets a custom working directory, even if it exists @@ -146,10 +174,24 @@ func TestRunWorkdirExists(t *testing.T) { } }) + container := globalRuntime.List()[0] + setTimeout(t, "CmdRun timed out", 5*time.Second, func() { <-c + + go func() { + cli.CmdWait(container.ID) + }() + + if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil { + t.Fatal(err) + } }) + // Cleanup pipes + if err := closeWrap(stdout, stdoutPipe); err != nil { + t.Fatal(err) + } } func TestRunExit(t *testing.T) { diff --git a/container.go b/container.go index b17f7d6421..54a51baad9 100644 --- a/container.go +++ b/container.go @@ -1249,6 +1249,12 @@ func (container *Container) Mounted() (bool, error) { } func (container *Container) Unmount() error { + if _, err := os.Stat(container.RootfsPath()); err != nil { + if os.IsNotExist(err) { + return nil + } + return err + } return Unmount(container.RootfsPath()) } diff --git a/container_test.go b/container_test.go index 9fdddc9044..ea65d0fa77 100644 --- a/container_test.go +++ b/container_test.go @@ -1593,7 +1593,6 @@ func TestMultipleVolumesFrom(t *testing.T) { t.Fatal(err) } - t.Log(container3.Volumes) if container3.Volumes["/test"] != container.Volumes["/test"] { t.Fail() } diff --git a/network_proxy_test.go b/network_proxy_test.go index c27393eb54..be506795b0 100644 --- a/network_proxy_test.go +++ b/network_proxy_test.go @@ -44,7 +44,6 @@ func NewEchoServer(t *testing.T, proto, address string) EchoServer { } server = &UDPEchoServer{conn: socket, testCtx: t} } - t.Logf("EchoServer listening on %v/%v\n", proto, server.LocalAddr().String()) return server } @@ -56,10 +55,7 @@ func (server *TCPEchoServer) Run() { return } go func(client net.Conn) { - server.testCtx.Logf("TCP client accepted on the EchoServer\n") - written, err := io.Copy(client, client) - server.testCtx.Logf("%v bytes echoed back to the client\n", written) - if err != nil { + if _, err := io.Copy(client, client); err != nil { server.testCtx.Logf("can't echo to the client: %v\n", err.Error()) } client.Close() @@ -79,7 +75,6 @@ func (server *UDPEchoServer) Run() { if err != nil { return } - server.testCtx.Logf("Writing UDP datagram back") for i := 0; i != read; { written, err := server.conn.WriteTo(readBuf[i:read], from) if err != nil { diff --git a/runtime_test.go b/runtime_test.go index 74feb02976..8e7c169bfb 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -340,7 +340,6 @@ func startEchoServerContainer(t *testing.T, proto string) (*Runtime, *Container, } else { t.Fatal(fmt.Errorf("Unknown protocol %v", proto)) } - t.Log("Trying port", strPort) container, err = runtime.Create(&Config{ Image: GetTestImage(runtime).ID, Cmd: []string{"sh", "-c", cmd}, @@ -353,7 +352,7 @@ func startEchoServerContainer(t *testing.T, proto string) (*Runtime, *Container, nuke(runtime) t.Fatal(err) } - t.Logf("Port %v already in use", strPort) + t.Logf("Port %v already in use, trying another one", strPort) } if err := container.Start(&HostConfig{}); err != nil {