| ... | ... |
@@ -84,10 +84,24 @@ func TestRunHostname(t *testing.T) {
|
| 84 | 84 |
} |
| 85 | 85 |
}) |
| 86 | 86 |
|
| 87 |
+ container := globalRuntime.List()[0] |
|
| 88 |
+ |
|
| 87 | 89 |
setTimeout(t, "CmdRun timed out", 10*time.Second, func() {
|
| 88 | 90 |
<-c |
| 91 |
+ |
|
| 92 |
+ go func() {
|
|
| 93 |
+ cli.CmdWait(container.ID) |
|
| 94 |
+ }() |
|
| 95 |
+ |
|
| 96 |
+ if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil {
|
|
| 97 |
+ t.Fatal(err) |
|
| 98 |
+ } |
|
| 89 | 99 |
}) |
| 90 | 100 |
|
| 101 |
+ // Cleanup pipes |
|
| 102 |
+ if err := closeWrap(stdout, stdoutPipe); err != nil {
|
|
| 103 |
+ t.Fatal(err) |
|
| 104 |
+ } |
|
| 91 | 105 |
} |
| 92 | 106 |
|
| 93 | 107 |
// TestRunWorkdir checks that 'docker run -w' correctly sets a custom working directory |
| ... | ... |
@@ -115,10 +129,24 @@ func TestRunWorkdir(t *testing.T) {
|
| 115 | 115 |
} |
| 116 | 116 |
}) |
| 117 | 117 |
|
| 118 |
+ container := globalRuntime.List()[0] |
|
| 119 |
+ |
|
| 118 | 120 |
setTimeout(t, "CmdRun timed out", 10*time.Second, func() {
|
| 119 | 121 |
<-c |
| 122 |
+ |
|
| 123 |
+ go func() {
|
|
| 124 |
+ cli.CmdWait(container.ID) |
|
| 125 |
+ }() |
|
| 126 |
+ |
|
| 127 |
+ if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil {
|
|
| 128 |
+ t.Fatal(err) |
|
| 129 |
+ } |
|
| 120 | 130 |
}) |
| 121 | 131 |
|
| 132 |
+ // Cleanup pipes |
|
| 133 |
+ if err := closeWrap(stdout, stdoutPipe); err != nil {
|
|
| 134 |
+ t.Fatal(err) |
|
| 135 |
+ } |
|
| 122 | 136 |
} |
| 123 | 137 |
|
| 124 | 138 |
// 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) {
|
| 146 | 146 |
} |
| 147 | 147 |
}) |
| 148 | 148 |
|
| 149 |
+ container := globalRuntime.List()[0] |
|
| 150 |
+ |
|
| 149 | 151 |
setTimeout(t, "CmdRun timed out", 5*time.Second, func() {
|
| 150 | 152 |
<-c |
| 153 |
+ |
|
| 154 |
+ go func() {
|
|
| 155 |
+ cli.CmdWait(container.ID) |
|
| 156 |
+ }() |
|
| 157 |
+ |
|
| 158 |
+ if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil {
|
|
| 159 |
+ t.Fatal(err) |
|
| 160 |
+ } |
|
| 151 | 161 |
}) |
| 152 | 162 |
|
| 163 |
+ // Cleanup pipes |
|
| 164 |
+ if err := closeWrap(stdout, stdoutPipe); err != nil {
|
|
| 165 |
+ t.Fatal(err) |
|
| 166 |
+ } |
|
| 153 | 167 |
} |
| 154 | 168 |
|
| 155 | 169 |
func TestRunExit(t *testing.T) {
|
| ... | ... |
@@ -1247,6 +1247,12 @@ func (container *Container) Mounted() (bool, error) {
|
| 1247 | 1247 |
} |
| 1248 | 1248 |
|
| 1249 | 1249 |
func (container *Container) Unmount() error {
|
| 1250 |
+ if _, err := os.Stat(container.RootfsPath()); err != nil {
|
|
| 1251 |
+ if os.IsNotExist(err) {
|
|
| 1252 |
+ return nil |
|
| 1253 |
+ } |
|
| 1254 |
+ return err |
|
| 1255 |
+ } |
|
| 1250 | 1256 |
return Unmount(container.RootfsPath()) |
| 1251 | 1257 |
} |
| 1252 | 1258 |
|