فهرست منبع

fix workdir, hostname tests and a bunch on mount issue

Victor Vieux 11 سال پیش
والد
کامیت
a675e249b1
2فایلهای تغییر یافته به همراه48 افزوده شده و 0 حذف شده
  1. 42 0
      commands_test.go
  2. 6 0
      container.go

+ 42 - 0
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() {
 	setTimeout(t, "CmdRun timed out", 10*time.Second, func() {
 		<-c
 		<-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
 // 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() {
 	setTimeout(t, "CmdRun timed out", 10*time.Second, func() {
 		<-c
 		<-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
 // 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() {
 	setTimeout(t, "CmdRun timed out", 5*time.Second, func() {
 		<-c
 		<-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) {
 func TestRunExit(t *testing.T) {

+ 6 - 0
container.go

@@ -1247,6 +1247,12 @@ func (container *Container) Mounted() (bool, error) {
 }
 }
 
 
 func (container *Container) Unmount() 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())
 	return Unmount(container.RootfsPath())
 }
 }