From a675e249b133fe35eaf02fb0bdb807cfd4efe969 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 24 Oct 2013 15:43:14 -0700 Subject: [PATCH] fix workdir, hostname tests and a bunch on mount issue --- commands_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ container.go | 6 ++++++ 2 files changed, 48 insertions(+) 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 01d442fed0..22a7872e68 100644 --- a/container.go +++ b/container.go @@ -1247,6 +1247,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()) }