Browse code

Merge pull request #19815 from Microsoft/jjh/testruncreatevolumesinsymlinkdir

Fix TestRunCreateVolumesInSymlinkDir

Brian Goff authored on 2016/01/30 11:07:51
Showing 1 changed files
... ...
@@ -359,6 +359,13 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
359 359
 	}
360 360
 	defer os.RemoveAll(dir)
361 361
 
362
+	// In the case of Windows to Windows CI, if the machine is setup so that
363
+	// the temp directory is not the C: drive, this test is invalid and will
364
+	// not work.
365
+	if daemonPlatform == "windows" && strings.ToLower(dir[:1]) != "c" {
366
+		c.Skip("Requires TEMP to point to C: drive")
367
+	}
368
+
362 369
 	f, err := os.OpenFile(filepath.Join(dir, "test"), os.O_CREATE, 0700)
363 370
 	if err != nil {
364 371
 		c.Fatal(err)
... ...
@@ -381,6 +388,32 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
381 381
 	dockerCmd(c, "run", "-v", containerPath, name, cmd)
382 382
 }
383 383
 
384
+// Volume path is a symlink in the container
385
+func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *check.C) {
386
+	var (
387
+		dockerFile    string
388
+		containerPath string
389
+		cmd           string
390
+	)
391
+	testRequires(c, SameHostDaemon)
392
+	name := "test-volume-symlink2"
393
+
394
+	if daemonPlatform == "windows" {
395
+		dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir c:\\%s\nRUN mklink /D c:\\test c:\\%s", WindowsBaseImage, name, name)
396
+		containerPath = `c:\test\test`
397
+		cmd = "tasklist"
398
+	} else {
399
+		dockerFile = fmt.Sprintf("FROM busybox\nRUN mkdir -p /%s\nRUN ln -s /%s /test", name, name)
400
+		containerPath = "/test/test"
401
+		cmd = "true"
402
+	}
403
+	if _, err := buildImage(name, dockerFile, false); err != nil {
404
+		c.Fatal(err)
405
+	}
406
+
407
+	dockerCmd(c, "run", "-v", containerPath, name, cmd)
408
+}
409
+
384 410
 func (s *DockerSuite) TestRunVolumesMountedAsReadonly(c *check.C) {
385 411
 	// TODO Windows (Post TP4): This test cannot run on a Windows daemon as
386 412
 	// Windows does not support read-only bind mounts.