浏览代码

Merge pull request #19815 from Microsoft/jjh/testruncreatevolumesinsymlinkdir

Fix TestRunCreateVolumesInSymlinkDir
Brian Goff 9 年之前
父节点
当前提交
9c3cca23e9
共有 1 个文件被更改,包括 33 次插入0 次删除
  1. 33 0
      integration-cli/docker_cli_run_test.go

+ 33 - 0
integration-cli/docker_cli_run_test.go

@@ -359,6 +359,13 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
 	}
 	}
 	defer os.RemoveAll(dir)
 	defer os.RemoveAll(dir)
 
 
+	// In the case of Windows to Windows CI, if the machine is setup so that
+	// the temp directory is not the C: drive, this test is invalid and will
+	// not work.
+	if daemonPlatform == "windows" && strings.ToLower(dir[:1]) != "c" {
+		c.Skip("Requires TEMP to point to C: drive")
+	}
+
 	f, err := os.OpenFile(filepath.Join(dir, "test"), os.O_CREATE, 0700)
 	f, err := os.OpenFile(filepath.Join(dir, "test"), os.O_CREATE, 0700)
 	if err != nil {
 	if err != nil {
 		c.Fatal(err)
 		c.Fatal(err)
@@ -381,6 +388,32 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
 	dockerCmd(c, "run", "-v", containerPath, name, cmd)
 	dockerCmd(c, "run", "-v", containerPath, name, cmd)
 }
 }
 
 
+// Volume path is a symlink in the container
+func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *check.C) {
+	var (
+		dockerFile    string
+		containerPath string
+		cmd           string
+	)
+	testRequires(c, SameHostDaemon)
+	name := "test-volume-symlink2"
+
+	if daemonPlatform == "windows" {
+		dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir c:\\%s\nRUN mklink /D c:\\test c:\\%s", WindowsBaseImage, name, name)
+		containerPath = `c:\test\test`
+		cmd = "tasklist"
+	} else {
+		dockerFile = fmt.Sprintf("FROM busybox\nRUN mkdir -p /%s\nRUN ln -s /%s /test", name, name)
+		containerPath = "/test/test"
+		cmd = "true"
+	}
+	if _, err := buildImage(name, dockerFile, false); err != nil {
+		c.Fatal(err)
+	}
+
+	dockerCmd(c, "run", "-v", containerPath, name, cmd)
+}
+
 func (s *DockerSuite) TestRunVolumesMountedAsReadonly(c *check.C) {
 func (s *DockerSuite) TestRunVolumesMountedAsReadonly(c *check.C) {
 	// TODO Windows (Post TP4): This test cannot run on a Windows daemon as
 	// TODO Windows (Post TP4): This test cannot run on a Windows daemon as
 	// Windows does not support read-only bind mounts.
 	// Windows does not support read-only bind mounts.