Browse code

Fixes 16556 CI failures

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2015/09/25 02:53:47
Showing 5 changed files
... ...
@@ -191,7 +191,7 @@ func (s *DockerSuite) TestContainerApiStartVolumeBinds(c *check.C) {
191 191
 	c.Assert(err, check.IsNil)
192 192
 	c.Assert(status, check.Equals, http.StatusCreated)
193 193
 
194
-	bindPath := randomTmpDirPath("test")
194
+	bindPath := randomTmpDirPath("test", daemonPlatform)
195 195
 	config = map[string]interface{}{
196 196
 		"Binds": []string{bindPath + ":/tmp"},
197 197
 	}
... ...
@@ -222,8 +222,8 @@ func (s *DockerSuite) TestContainerApiStartDupVolumeBinds(c *check.C) {
222 222
 	c.Assert(err, check.IsNil)
223 223
 	c.Assert(status, check.Equals, http.StatusCreated)
224 224
 
225
-	bindPath1 := randomTmpDirPath("test1")
226
-	bindPath2 := randomTmpDirPath("test2")
225
+	bindPath1 := randomTmpDirPath("test1", daemonPlatform)
226
+	bindPath2 := randomTmpDirPath("test2", daemonPlatform)
227 227
 
228 228
 	config = map[string]interface{}{
229 229
 		"Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"},
... ...
@@ -322,8 +322,8 @@ func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) {
322 322
 	// TODO Windows: This test cannot run on a Windows daemon as Windows does
323 323
 	// not support volumes
324 324
 	testRequires(c, DaemonIsLinux)
325
-	mountstr1 := randomTmpDirPath("test1") + ":/someplace"
326
-	mountstr2 := randomTmpDirPath("test2") + ":/someplace"
325
+	mountstr1 := randomTmpDirPath("test1", daemonPlatform) + ":/someplace"
326
+	mountstr2 := randomTmpDirPath("test2", daemonPlatform) + ":/someplace"
327 327
 
328 328
 	if out, _, err := dockerCmdWithError("run", "-v", mountstr1, "-v", mountstr2, "busybox", "true"); err == nil {
329 329
 		c.Fatal("Expected error about duplicate volume definitions")
... ...
@@ -2015,7 +2015,7 @@ func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) {
2015 2015
 		c.Fatalf("Data was copied on volumes-from but shouldn't be:\n%q", out)
2016 2016
 	}
2017 2017
 
2018
-	tmpDir := randomTmpDirPath("docker_test_bind_mount_copy_data")
2018
+	tmpDir := randomTmpDirPath("docker_test_bind_mount_copy_data", daemonPlatform)
2019 2019
 	if out, _, err := dockerCmdWithError("run", "-v", tmpDir+":/foo", "dataimage", "ls", "-lh", "/foo/bar"); err == nil || !strings.Contains(out, "No such file or directory") {
2020 2020
 		c.Fatalf("Data was copied on bind-mount but shouldn't be:\n%q", out)
2021 2021
 	}
... ...
@@ -61,8 +61,8 @@ func listTar(f io.Reader) ([]string, error) {
61 61
 	return integration.ListTar(f)
62 62
 }
63 63
 
64
-func randomTmpDirPath(s string) string {
65
-	return integration.RandomTmpDirPath(s)
64
+func randomTmpDirPath(s string, platform string) string {
65
+	return integration.RandomTmpDirPath(s, platform)
66 66
 }
67 67
 
68 68
 func consumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error) {
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"os/exec"
12 12
 	"path/filepath"
13 13
 	"reflect"
14
-	"runtime"
15 14
 	"strings"
16 15
 	"syscall"
17 16
 	"time"
... ...
@@ -247,12 +246,16 @@ func ListTar(f io.Reader) ([]string, error) {
247 247
 
248 248
 // RandomTmpDirPath provides a temporary path with rand string appended.
249 249
 // does not create or checks if it exists.
250
-func RandomTmpDirPath(s string) string {
250
+func RandomTmpDirPath(s string, platform string) string {
251 251
 	tmp := "/tmp"
252
-	if runtime.GOOS == "windows" {
252
+	if platform == "windows" {
253 253
 		tmp = os.Getenv("TEMP")
254 254
 	}
255
-	return filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10)))
255
+	path := filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10)))
256
+	if platform == "windows" {
257
+		return filepath.FromSlash(path) // Using \
258
+	}
259
+	return filepath.ToSlash(path) // Using /
256 260
 }
257 261
 
258 262
 // ConsumeWithSpeed reads chunkSize bytes from reader after every interval.
... ...
@@ -343,7 +343,7 @@ func TestListTar(t *testing.T) {
343 343
 }
344 344
 
345 345
 func TestRandomTmpDirPath(t *testing.T) {
346
-	path := RandomTmpDirPath("something")
346
+	path := RandomTmpDirPath("something", runtime.GOOS)
347 347
 
348 348
 	prefix := "/tmp/something"
349 349
 	if runtime.GOOS == "windows" {