Browse code

Use testEnv methods and remove most of the global variables

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2017/01/14 01:23:28
Showing 40 changed files
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"syscall"
12 12
 	"testing"
13 13
 
14
-	"github.com/docker/docker/api/types/container"
15 14
 	"github.com/docker/docker/api/types/swarm"
16 15
 	cliconfig "github.com/docker/docker/cli/config"
17 16
 	"github.com/docker/docker/integration-cli/daemon"
... ...
@@ -40,40 +39,6 @@ var (
40 40
 
41 41
 	// the docker client binary to use
42 42
 	dockerBinary = "docker"
43
-
44
-	// isLocalDaemon is true if the daemon under test is on the same
45
-	// host as the CLI.
46
-	isLocalDaemon bool
47
-	// daemonPlatform is held globally so that tests can make intelligent
48
-	// decisions on how to configure themselves according to the platform
49
-	// of the daemon. This is initialized in docker_utils by sending
50
-	// a version call to the daemon and examining the response header.
51
-	daemonPlatform string
52
-
53
-	// WindowsBaseImage is the name of the base image for Windows testing
54
-	// Environment variable WINDOWS_BASE_IMAGE can override this
55
-	WindowsBaseImage string
56
-
57
-	// For a local daemon on Linux, these values will be used for testing
58
-	// user namespace support as the standard graph path(s) will be
59
-	// appended with the root remapped uid.gid prefix
60
-	dockerBasePath       string
61
-	volumesConfigPath    string
62
-	containerStoragePath string
63
-
64
-	// daemonStorageDriver is held globally so that tests can know the storage
65
-	// driver of the daemon. This is initialized in docker_utils by sending
66
-	// a version call to the daemon and examining the response header.
67
-	daemonStorageDriver string
68
-
69
-	// isolation is the isolation mode of the daemon under test
70
-	isolation container.Isolation
71
-
72
-	// experimentalDaemon tell whether the main daemon has
73
-	// experimental features enabled or not
74
-	experimentalDaemon bool
75
-
76
-	daemonKernelVersion string
77 43
 )
78 44
 
79 45
 func init() {
... ...
@@ -86,22 +51,6 @@ func init() {
86 86
 		fmt.Println(err)
87 87
 		os.Exit(1)
88 88
 	}
89
-
90
-	assignGlobalVariablesFromTestEnv(testEnv)
91
-}
92
-
93
-// FIXME(vdemeester) remove this and use environment
94
-func assignGlobalVariablesFromTestEnv(testEnv *environment.Execution) {
95
-	isLocalDaemon = testEnv.LocalDaemon()
96
-	daemonPlatform = testEnv.DaemonPlatform()
97
-	dockerBasePath = testEnv.DockerBasePath()
98
-	volumesConfigPath = testEnv.VolumesConfigPath()
99
-	containerStoragePath = testEnv.ContainerStoragePath()
100
-	daemonStorageDriver = testEnv.DaemonStorageDriver()
101
-	isolation = testEnv.Isolation()
102
-	experimentalDaemon = testEnv.ExperimentalDaemon()
103
-	daemonKernelVersion = testEnv.DaemonKernelVersion()
104
-	WindowsBaseImage = testEnv.MinimalBaseImage()
105 89
 }
106 90
 
107 91
 func TestMain(m *testing.M) {
... ...
@@ -125,17 +74,17 @@ func TestMain(m *testing.M) {
125 125
 	for _, img := range images {
126 126
 		protectedImages[img] = struct{}{}
127 127
 	}
128
-	if !isLocalDaemon {
129
-		fmt.Println("INFO: Testing against a remote daemon")
130
-	} else {
128
+	if testEnv.LocalDaemon() {
131 129
 		fmt.Println("INFO: Testing against a local daemon")
130
+	} else {
131
+		fmt.Println("INFO: Testing against a remote daemon")
132 132
 	}
133 133
 	exitCode := m.Run()
134 134
 	os.Exit(exitCode)
135 135
 }
136 136
 
137 137
 func Test(t *testing.T) {
138
-	if daemonPlatform == "linux" {
138
+	if testEnv.DaemonPlatform() == "linux" {
139 139
 		ensureFrozenImagesLinux(t)
140 140
 	}
141 141
 	check.TestingT(t)
... ...
@@ -149,7 +98,7 @@ type DockerSuite struct {
149 149
 }
150 150
 
151 151
 func (s *DockerSuite) OnTimeout(c *check.C) {
152
-	if testEnv.DaemonPID() > 0 && isLocalDaemon {
152
+	if testEnv.DaemonPID() > 0 && testEnv.LocalDaemon() {
153 153
 		daemon.SignalDaemonDump(testEnv.DaemonPID())
154 154
 	}
155 155
 }
... ...
@@ -160,7 +109,7 @@ func (s *DockerSuite) TearDownTest(c *check.C) {
160 160
 	deleteAllImages(c)
161 161
 	deleteAllVolumes(c)
162 162
 	deleteAllNetworks(c)
163
-	if daemonPlatform == "linux" {
163
+	if testEnv.DaemonPlatform() == "linux" {
164 164
 		deleteAllPlugins(c)
165 165
 	}
166 166
 }
... ...
@@ -185,7 +134,7 @@ func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
185 185
 	testRequires(c, DaemonIsLinux, registry.Hosting)
186 186
 	s.reg = setupRegistry(c, false, "", "")
187 187
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
188
-		Experimental: experimentalDaemon,
188
+		Experimental: testEnv.ExperimentalDaemon(),
189 189
 	})
190 190
 }
191 191
 
... ...
@@ -219,7 +168,7 @@ func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) {
219 219
 	testRequires(c, DaemonIsLinux, registry.Hosting, NotArm64)
220 220
 	s.reg = setupRegistry(c, true, "", "")
221 221
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
222
-		Experimental: experimentalDaemon,
222
+		Experimental: testEnv.ExperimentalDaemon(),
223 223
 	})
224 224
 }
225 225
 
... ...
@@ -253,7 +202,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) {
253 253
 	testRequires(c, DaemonIsLinux, registry.Hosting)
254 254
 	s.reg = setupRegistry(c, false, "htpasswd", "")
255 255
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
256
-		Experimental: experimentalDaemon,
256
+		Experimental: testEnv.ExperimentalDaemon(),
257 257
 	})
258 258
 }
259 259
 
... ...
@@ -288,7 +237,7 @@ func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *check.C) {
288 288
 func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) {
289 289
 	testRequires(c, DaemonIsLinux, registry.Hosting)
290 290
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
291
-		Experimental: experimentalDaemon,
291
+		Experimental: testEnv.ExperimentalDaemon(),
292 292
 	})
293 293
 }
294 294
 
... ...
@@ -329,7 +278,7 @@ func (s *DockerDaemonSuite) OnTimeout(c *check.C) {
329 329
 func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
330 330
 	testRequires(c, DaemonIsLinux, SameHostDaemon)
331 331
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
332
-		Experimental: experimentalDaemon,
332
+		Experimental: testEnv.ExperimentalDaemon(),
333 333
 	})
334 334
 }
335 335
 
... ...
@@ -387,7 +336,7 @@ func (s *DockerSwarmSuite) SetUpTest(c *check.C) {
387 387
 func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemon.Swarm {
388 388
 	d := &daemon.Swarm{
389 389
 		Daemon: daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
390
-			Experimental: experimentalDaemon,
390
+			Experimental: testEnv.ExperimentalDaemon(),
391 391
 		}),
392 392
 		Port: defaultSwarmPort + s.portIndex,
393 393
 	}
... ...
@@ -16,7 +16,7 @@ import (
16 16
 func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *check.C) {
17 17
 	testRequires(c, NotUserNamespace)
18 18
 	var testD string
19
-	if daemonPlatform == "windows" {
19
+	if testEnv.DaemonPlatform() == "windows" {
20 20
 		testD = `FROM busybox
21 21
 COPY * /tmp/
22 22
 RUN find / -name ba*
... ...
@@ -919,7 +919,7 @@ func (s *DockerSuite) TestContainerAPIStart(c *check.C) {
919 919
 	c.Assert(err, checker.IsNil)
920 920
 
921 921
 	// TODO(tibor): figure out why this doesn't work on windows
922
-	if isLocalDaemon {
922
+	if testEnv.LocalDaemon() {
923 923
 		c.Assert(status, checker.Equals, http.StatusNotModified)
924 924
 	}
925 925
 }
... ...
@@ -943,7 +943,7 @@ func (s *DockerSuite) TestContainerAPIWait(c *check.C) {
943 943
 	name := "test-api-wait"
944 944
 
945 945
 	sleepCmd := "/bin/sleep"
946
-	if daemonPlatform == "windows" {
946
+	if testEnv.DaemonPlatform() == "windows" {
947 947
 		sleepCmd = "sleep"
948 948
 	}
949 949
 	dockerCmd(c, "run", "--name", name, "busybox", sleepCmd, "2")
... ...
@@ -1112,7 +1112,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) {
1112 1112
 	testRequires(c, SameHostDaemon)
1113 1113
 
1114 1114
 	vol := "/testvolume"
1115
-	if daemonPlatform == "windows" {
1115
+	if testEnv.DaemonPlatform() == "windows" {
1116 1116
 		vol = `c:\testvolume`
1117 1117
 	}
1118 1118
 
... ...
@@ -1769,7 +1769,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) {
1769 1769
 		err     error
1770 1770
 		testImg string
1771 1771
 	)
1772
-	if daemonPlatform != "windows" {
1772
+	if testEnv.DaemonPlatform() != "windows" {
1773 1773
 		testImg, err = buildImage("test-mount-config", `
1774 1774
 	FROM busybox
1775 1775
 	RUN mkdir `+destPath+` && touch `+destPath+slash+`bar
... ...
@@ -1822,7 +1822,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) {
1822 1822
 		}
1823 1823
 	}
1824 1824
 
1825
-	if daemonPlatform != "windows" { // Windows does not support volume populate
1825
+	if testEnv.DaemonPlatform() != "windows" { // Windows does not support volume populate
1826 1826
 		cases = append(cases, []testCase{
1827 1827
 			{mounttypes.Mount{Type: "volume", Target: destPath, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath}},
1828 1828
 			{mounttypes.Mount{Type: "volume", Target: destPath + slash, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath}},
... ...
@@ -1872,7 +1872,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) {
1872 1872
 		}
1873 1873
 
1874 1874
 		out, _, err := dockerCmdWithError("start", "-a", id)
1875
-		if (x.cfg.Type != "volume" || (x.cfg.VolumeOptions != nil && x.cfg.VolumeOptions.NoCopy)) && daemonPlatform != "windows" {
1875
+		if (x.cfg.Type != "volume" || (x.cfg.VolumeOptions != nil && x.cfg.VolumeOptions.NoCopy)) && testEnv.DaemonPlatform() != "windows" {
1876 1876
 			c.Assert(err, checker.NotNil, check.Commentf("%s\n%v", out, mps[0]))
1877 1877
 		} else {
1878 1878
 			c.Assert(err, checker.IsNil, check.Commentf("%s\n%v", out, mps[0]))
... ...
@@ -73,7 +73,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) {
73 73
 }
74 74
 
75 75
 func (s *DockerSuite) TestAPIImagesDelete(c *check.C) {
76
-	if daemonPlatform != "windows" {
76
+	if testEnv.DaemonPlatform() != "windows" {
77 77
 		testRequires(c, Network)
78 78
 	}
79 79
 	name := "test-api-images-delete"
... ...
@@ -97,7 +97,7 @@ func (s *DockerSuite) TestAPIImagesDelete(c *check.C) {
97 97
 }
98 98
 
99 99
 func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
100
-	if daemonPlatform != "windows" {
100
+	if testEnv.DaemonPlatform() != "windows" {
101 101
 		testRequires(c, Network)
102 102
 	}
103 103
 	name := "test-api-images-history"
... ...
@@ -27,7 +27,7 @@ func (s *DockerSuite) TestInspectAPIContainerResponse(c *check.C) {
27 27
 
28 28
 	var cases []acase
29 29
 
30
-	if daemonPlatform == "windows" {
30
+	if testEnv.DaemonPlatform() == "windows" {
31 31
 		cases = []acase{
32 32
 			{"v1.25", append(keysBase, "Mounts")},
33 33
 		}
... ...
@@ -38,7 +38,7 @@ func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *check.C) {
38 38
 
39 39
 	var cpuPercent = 0.0
40 40
 
41
-	if daemonPlatform != "windows" {
41
+	if testEnv.DaemonPlatform() != "windows" {
42 42
 		cpuDelta := float64(v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage)
43 43
 		systemDelta := float64(v.CPUStats.SystemUsage - v.PreCPUStats.SystemUsage)
44 44
 		cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CPUStats.CPUUsage.PercpuUsage)) * 100.0
... ...
@@ -104,7 +104,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) {
104 104
 
105 105
 	// Retrieve the container address
106 106
 	net := "bridge"
107
-	if daemonPlatform == "windows" {
107
+	if testEnv.DaemonPlatform() == "windows" {
108 108
 		net = "nat"
109 109
 	}
110 110
 	contIP := findContainerIP(c, id, net)
... ...
@@ -152,7 +152,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) {
152 152
 	// On Linux, account for ARP.
153 153
 	expRxPkts := preRxPackets + uint64(numPings)
154 154
 	expTxPkts := preTxPackets + uint64(numPings)
155
-	if daemonPlatform != "windows" {
155
+	if testEnv.DaemonPlatform() != "windows" {
156 156
 		expRxPkts++
157 157
 		expTxPkts++
158 158
 	}
... ...
@@ -36,7 +36,7 @@ func (s *DockerSuite) TestAPIGetEnabledCORS(c *check.C) {
36 36
 }
37 37
 
38 38
 func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) {
39
-	if daemonPlatform != runtime.GOOS {
39
+	if testEnv.DaemonPlatform() != runtime.GOOS {
40 40
 		c.Skip("Daemon platform doesn't match test platform")
41 41
 	}
42 42
 	if api.MinVersion == api.DefaultVersion {
... ...
@@ -33,7 +33,7 @@ type DockerAuthzV2Suite struct {
33 33
 func (s *DockerAuthzV2Suite) SetUpTest(c *check.C) {
34 34
 	testRequires(c, DaemonIsLinux, Network)
35 35
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
36
-		Experimental: experimentalDaemon,
36
+		Experimental: testEnv.ExperimentalDaemon(),
37 37
 	})
38 38
 	s.d.Start(c)
39 39
 }
... ...
@@ -65,7 +65,7 @@ type authorizationController struct {
65 65
 
66 66
 func (s *DockerAuthzSuite) SetUpTest(c *check.C) {
67 67
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
68
-		Experimental: experimentalDaemon,
68
+		Experimental: testEnv.ExperimentalDaemon(),
69 69
 	})
70 70
 	s.ctrl = &authorizationController{}
71 71
 }
... ...
@@ -36,7 +36,7 @@ func (s *DockerSuite) TestBuildJSONEmptyRun(c *check.C) {
36 36
 func (s *DockerSuite) TestBuildShCmdJSONEntrypoint(c *check.C) {
37 37
 	name := "testbuildshcmdjsonentrypoint"
38 38
 	expected := "/bin/sh -c echo test"
39
-	if daemonPlatform == "windows" {
39
+	if testEnv.DaemonPlatform() == "windows" {
40 40
 		expected = "cmd /S /C echo test"
41 41
 	}
42 42
 
... ...
@@ -74,7 +74,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementVolume(c *check.C) {
74 74
 
75 75
 	var volumePath string
76 76
 
77
-	if daemonPlatform == "windows" {
77
+	if testEnv.DaemonPlatform() == "windows" {
78 78
 		volumePath = "c:/quux"
79 79
 	} else {
80 80
 		volumePath = "/quux"
... ...
@@ -131,7 +131,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementWorkdir(c *check.C) {
131 131
 	res := inspectFieldJSON(c, name, "Config.WorkingDir")
132 132
 
133 133
 	expected := `"/work"`
134
-	if daemonPlatform == "windows" {
134
+	if testEnv.DaemonPlatform() == "windows" {
135 135
 		expected = `"C:\\work"`
136 136
 	}
137 137
 	if res != expected {
... ...
@@ -634,7 +634,7 @@ RUN [ $(cat "/test dir/test_file6") = 'test6' ]`, command, command, command, com
634 634
 
635 635
 func (s *DockerSuite) TestBuildCopyFileWithWhitespaceOnWindows(c *check.C) {
636 636
 	testRequires(c, DaemonIsWindows)
637
-	dockerfile := `FROM ` + WindowsBaseImage + `
637
+	dockerfile := `FROM ` + testEnv.MinimalBaseImage() + `
638 638
 RUN mkdir "C:/test dir"
639 639
 RUN mkdir "C:/test_dir"
640 640
 COPY [ "test file1", "/test_file1" ]
... ...
@@ -1387,7 +1387,7 @@ func (s *DockerSuite) TestBuildRelativeWorkdir(c *check.C) {
1387 1387
 		expectedFinal string
1388 1388
 	)
1389 1389
 
1390
-	if daemonPlatform == "windows" {
1390
+	if testEnv.DaemonPlatform() == "windows" {
1391 1391
 		expected1 = `C:/`
1392 1392
 		expected2 = `C:/test1`
1393 1393
 		expected3 = `C:/test2`
... ...
@@ -1466,7 +1466,7 @@ func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *check.C) {
1466 1466
 	name := "testbuildworkdirwithenvvariables"
1467 1467
 
1468 1468
 	var expected string
1469
-	if daemonPlatform == "windows" {
1469
+	if testEnv.DaemonPlatform() == "windows" {
1470 1470
 		expected = `C:\test1\test2`
1471 1471
 	} else {
1472 1472
 		expected = `/test1/test2`
... ...
@@ -1488,7 +1488,7 @@ func (s *DockerSuite) TestBuildRelativeCopy(c *check.C) {
1488 1488
 	testRequires(c, NotUserNamespace)
1489 1489
 
1490 1490
 	var expected string
1491
-	if daemonPlatform == "windows" {
1491
+	if testEnv.DaemonPlatform() == "windows" {
1492 1492
 		expected = `C:/test1/test2`
1493 1493
 	} else {
1494 1494
 		expected = `/test1/test2`
... ...
@@ -1597,7 +1597,7 @@ func (s *DockerSuite) TestBuildContextCleanup(c *check.C) {
1597 1597
 	testRequires(c, SameHostDaemon)
1598 1598
 
1599 1599
 	name := "testbuildcontextcleanup"
1600
-	entries, err := ioutil.ReadDir(filepath.Join(dockerBasePath, "tmp"))
1600
+	entries, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp"))
1601 1601
 	if err != nil {
1602 1602
 		c.Fatalf("failed to list contents of tmp dir: %s", err)
1603 1603
 	}
... ...
@@ -1605,7 +1605,7 @@ func (s *DockerSuite) TestBuildContextCleanup(c *check.C) {
1605 1605
 	buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+`
1606 1606
         ENTRYPOINT ["/bin/echo"]`))
1607 1607
 
1608
-	entriesFinal, err := ioutil.ReadDir(filepath.Join(dockerBasePath, "tmp"))
1608
+	entriesFinal, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp"))
1609 1609
 	if err != nil {
1610 1610
 		c.Fatalf("failed to list contents of tmp dir: %s", err)
1611 1611
 	}
... ...
@@ -1619,7 +1619,7 @@ func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) {
1619 1619
 	testRequires(c, SameHostDaemon)
1620 1620
 
1621 1621
 	name := "testbuildcontextcleanup"
1622
-	entries, err := ioutil.ReadDir(filepath.Join(dockerBasePath, "tmp"))
1622
+	entries, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp"))
1623 1623
 	if err != nil {
1624 1624
 		c.Fatalf("failed to list contents of tmp dir: %s", err)
1625 1625
 	}
... ...
@@ -1629,7 +1629,7 @@ func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) {
1629 1629
 		ExitCode: 1,
1630 1630
 	})
1631 1631
 
1632
-	entriesFinal, err := ioutil.ReadDir(filepath.Join(dockerBasePath, "tmp"))
1632
+	entriesFinal, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp"))
1633 1633
 	if err != nil {
1634 1634
 		c.Fatalf("failed to list contents of tmp dir: %s", err)
1635 1635
 	}
... ...
@@ -2253,7 +2253,7 @@ func (s *DockerSuite) TestBuildAddFileNotFound(c *check.C) {
2253 2253
 	name := "testbuildaddnotfound"
2254 2254
 	expected := "foo: no such file or directory"
2255 2255
 
2256
-	if daemonPlatform == "windows" {
2256
+	if testEnv.DaemonPlatform() == "windows" {
2257 2257
 		expected = "foo: The system cannot find the file specified"
2258 2258
 	}
2259 2259
 
... ...
@@ -2307,7 +2307,7 @@ func (s *DockerSuite) TestBuildOnBuild(c *check.C) {
2307 2307
 // gh #2446
2308 2308
 func (s *DockerSuite) TestBuildAddToSymlinkDest(c *check.C) {
2309 2309
 	makeLink := `ln -s /foo /bar`
2310
-	if daemonPlatform == "windows" {
2310
+	if testEnv.DaemonPlatform() == "windows" {
2311 2311
 		makeLink = `mklink /D C:\bar C:\foo`
2312 2312
 	}
2313 2313
 	name := "testbuildaddtosymlinkdest"
... ...
@@ -3299,7 +3299,7 @@ func (s *DockerSuite) TestBuildCmdShDashC(c *check.C) {
3299 3299
 
3300 3300
 	res := inspectFieldJSON(c, name, "Config.Cmd")
3301 3301
 	expected := `["/bin/sh","-c","echo cmd"]`
3302
-	if daemonPlatform == "windows" {
3302
+	if testEnv.DaemonPlatform() == "windows" {
3303 3303
 		expected = `["cmd","/S","/C","echo cmd"]`
3304 3304
 	}
3305 3305
 	if res != expected {
... ...
@@ -3374,7 +3374,7 @@ func (s *DockerSuite) TestBuildEntrypointCanBeOverridenByChildInspect(c *check.C
3374 3374
 		expected = `["/bin/sh","-c","echo quux"]`
3375 3375
 	)
3376 3376
 
3377
-	if daemonPlatform == "windows" {
3377
+	if testEnv.DaemonPlatform() == "windows" {
3378 3378
 		expected = `["cmd","/S","/C","echo quux"]`
3379 3379
 	}
3380 3380
 
... ...
@@ -3431,7 +3431,7 @@ func (s *DockerSuite) TestBuildVerifySingleQuoteFails(c *check.C) {
3431 3431
 	// it should barf on it.
3432 3432
 	name := "testbuildsinglequotefails"
3433 3433
 	expectedExitCode := 2
3434
-	if daemonPlatform == "windows" {
3434
+	if testEnv.DaemonPlatform() == "windows" {
3435 3435
 		expectedExitCode = 127
3436 3436
 	}
3437 3437
 
... ...
@@ -3447,7 +3447,7 @@ func (s *DockerSuite) TestBuildVerboseOut(c *check.C) {
3447 3447
 	name := "testbuildverboseout"
3448 3448
 	expected := "\n123\n"
3449 3449
 
3450
-	if daemonPlatform == "windows" {
3450
+	if testEnv.DaemonPlatform() == "windows" {
3451 3451
 		expected = "\n123\r\n"
3452 3452
 	}
3453 3453
 
... ...
@@ -3463,7 +3463,7 @@ func (s *DockerSuite) TestBuildWithTabs(c *check.C) {
3463 3463
 	res := inspectFieldJSON(c, name, "ContainerConfig.Cmd")
3464 3464
 	expected1 := `["/bin/sh","-c","echo\tone\t\ttwo"]`
3465 3465
 	expected2 := `["/bin/sh","-c","echo\u0009one\u0009\u0009two"]` // syntactically equivalent, and what Go 1.3 generates
3466
-	if daemonPlatform == "windows" {
3466
+	if testEnv.DaemonPlatform() == "windows" {
3467 3467
 		expected1 = `["cmd","/S","/C","echo\tone\t\ttwo"]`
3468 3468
 		expected2 = `["cmd","/S","/C","echo\u0009one\u0009\u0009two"]` // syntactically equivalent, and what Go 1.3 generates
3469 3469
 	}
... ...
@@ -3656,7 +3656,7 @@ func (s *DockerSuite) TestBuildStderr(c *check.C) {
3656 3656
 	result.Assert(c, icmd.Success)
3657 3657
 
3658 3658
 	// Windows to non-Windows should have a security warning
3659
-	if runtime.GOOS == "windows" && daemonPlatform != "windows" && !strings.Contains(result.Stdout(), "SECURITY WARNING:") {
3659
+	if runtime.GOOS == "windows" && testEnv.DaemonPlatform() != "windows" && !strings.Contains(result.Stdout(), "SECURITY WARNING:") {
3660 3660
 		c.Fatalf("Stdout contains unexpected output: %q", result.Stdout())
3661 3661
 	}
3662 3662
 
... ...
@@ -3775,7 +3775,7 @@ func (s *DockerSuite) TestBuildVolumesRetainContents(c *check.C) {
3775 3775
 		volName  = "/foo"
3776 3776
 	)
3777 3777
 
3778
-	if daemonPlatform == "windows" {
3778
+	if testEnv.DaemonPlatform() == "windows" {
3779 3779
 		volName = "C:/foo"
3780 3780
 	}
3781 3781
 
... ...
@@ -4139,7 +4139,7 @@ RUN echo "  \
4139 4139
 
4140 4140
 	expected := "\n    foo  \n"
4141 4141
 	// Windows uses the builtin echo, which preserves quotes
4142
-	if daemonPlatform == "windows" {
4142
+	if testEnv.DaemonPlatform() == "windows" {
4143 4143
 		expected = "\"    foo  \""
4144 4144
 	}
4145 4145
 
... ...
@@ -4173,7 +4173,7 @@ func (s *DockerSuite) TestBuildMissingArgs(c *check.C) {
4173 4173
 		"INSERT":     {},
4174 4174
 	}
4175 4175
 
4176
-	if daemonPlatform == "windows" {
4176
+	if testEnv.DaemonPlatform() == "windows" {
4177 4177
 		skipCmds = map[string]struct{}{
4178 4178
 			"CMD":        {},
4179 4179
 			"RUN":        {},
... ...
@@ -4306,7 +4306,7 @@ func (s *DockerSuite) TestBuildRUNErrMsg(c *check.C) {
4306 4306
 	name := "testbuildbadrunerrmsg"
4307 4307
 	shell := "/bin/sh -c"
4308 4308
 	exitCode := 127
4309
-	if daemonPlatform == "windows" {
4309
+	if testEnv.DaemonPlatform() == "windows" {
4310 4310
 		shell = "cmd /S /C"
4311 4311
 		// architectural - Windows has to start the container to determine the exe is bad, Linux does not
4312 4312
 		exitCode = 1
... ...
@@ -4460,7 +4460,7 @@ func (s *DockerTrustSuite) TestTrustedBuildTagIgnoresOtherDelegationRoles(c *che
4460 4460
 func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) {
4461 4461
 	name := "testbuildnullstringinaddcopyvolume"
4462 4462
 	volName := "nullvolume"
4463
-	if daemonPlatform == "windows" {
4463
+	if testEnv.DaemonPlatform() == "windows" {
4464 4464
 		volName = `C:\\nullvolume`
4465 4465
 	}
4466 4466
 
... ...
@@ -4500,7 +4500,7 @@ func (s *DockerSuite) TestBuildBuildTimeArg(c *check.C) {
4500 4500
 	envKey := "foo"
4501 4501
 	envVal := "bar"
4502 4502
 	var dockerfile string
4503
-	if daemonPlatform == "windows" {
4503
+	if testEnv.DaemonPlatform() == "windows" {
4504 4504
 		// Bugs in Windows busybox port - use the default base image and native cmd stuff
4505 4505
 		dockerfile = fmt.Sprintf(`FROM `+minimalBaseImage()+`
4506 4506
 			ARG %s
... ...
@@ -5008,7 +5008,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgDefintionWithNoEnvInjection(c *check.
5008 5008
 func (s *DockerSuite) TestBuildNoNamedVolume(c *check.C) {
5009 5009
 	volName := "testname:/foo"
5010 5010
 
5011
-	if daemonPlatform == "windows" {
5011
+	if testEnv.DaemonPlatform() == "windows" {
5012 5012
 		volName = "testname:C:\\foo"
5013 5013
 	}
5014 5014
 	dockerCmd(c, "run", "-v", volName, "busybox", "sh", "-c", "touch /foo/oops")
... ...
@@ -5226,7 +5226,7 @@ func (s *DockerSuite) TestBuildWorkdirWindowsPath(c *check.C) {
5226 5226
 	testRequires(c, DaemonIsWindows)
5227 5227
 	name := "testbuildworkdirwindowspath"
5228 5228
 	buildImageSuccessfully(c, name, withDockerfile(`
5229
-	FROM `+WindowsBaseImage+`
5229
+	FROM `+testEnv.MinimalBaseImage()+`
5230 5230
 	RUN mkdir C:\\work
5231 5231
 	WORKDIR C:\\work
5232 5232
 	RUN if "%CD%" NEQ "C:\work" exit -1
... ...
@@ -5911,7 +5911,7 @@ func (s *DockerSuite) TestBuildOpaqueDirectory(c *check.C) {
5911 5911
 func (s *DockerSuite) TestBuildWindowsUser(c *check.C) {
5912 5912
 	testRequires(c, DaemonIsWindows)
5913 5913
 	name := "testbuildwindowsuser"
5914
-	buildImageNew(name, withDockerfile(`FROM `+WindowsBaseImage+`
5914
+	buildImageNew(name, withDockerfile(`FROM `+testEnv.MinimalBaseImage()+`
5915 5915
 		RUN net user user /add
5916 5916
 		USER user
5917 5917
 		RUN set username
... ...
@@ -5942,7 +5942,7 @@ func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *check.C) {
5942 5942
 	testRequires(c, DaemonIsWindows)
5943 5943
 	name := "testbuildwindowsenvcaseinsensitive"
5944 5944
 	buildImageSuccessfully(c, name, withDockerfile(`
5945
-		FROM `+WindowsBaseImage+`
5945
+		FROM `+testEnv.MinimalBaseImage()+`
5946 5946
 		ENV FOO=bar foo=baz
5947 5947
   `))
5948 5948
 	res := inspectFieldJSON(c, name, "Config.Env")
... ...
@@ -5962,7 +5962,7 @@ WORKDIR /foo/bar
5962 5962
 
5963 5963
 	// The Windows busybox image has a blank `cmd`
5964 5964
 	lookingFor := `["sh"]`
5965
-	if daemonPlatform == "windows" {
5965
+	if testEnv.DaemonPlatform() == "windows" {
5966 5966
 		lookingFor = "null"
5967 5967
 	}
5968 5968
 	c.Assert(strings.TrimSpace(out), checker.Equals, lookingFor)
... ...
@@ -636,7 +636,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *check.C) {
636 636
 	// digest verification for the target layer digest.
637 637
 
638 638
 	// Remove distribution cache to force a re-pull of the blobs
639
-	if err := os.RemoveAll(filepath.Join(dockerBasePath, "image", s.d.StorageDriver(), "distribution")); err != nil {
639
+	if err := os.RemoveAll(filepath.Join(testEnv.DockerBasePath(), "image", s.d.StorageDriver(), "distribution")); err != nil {
640 640
 		c.Fatalf("error clearing distribution cache: %v", err)
641 641
 	}
642 642
 
... ...
@@ -679,7 +679,7 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *check.C) {
679 679
 	// digest verification for the target layer digest.
680 680
 
681 681
 	// Remove distribution cache to force a re-pull of the blobs
682
-	if err := os.RemoveAll(filepath.Join(dockerBasePath, "image", s.d.StorageDriver(), "distribution")); err != nil {
682
+	if err := os.RemoveAll(filepath.Join(testEnv.DockerBasePath(), "image", s.d.StorageDriver(), "distribution")); err != nil {
683 683
 		c.Fatalf("error clearing distribution cache: %v", err)
684 684
 	}
685 685
 
... ...
@@ -41,7 +41,7 @@ func (s *DockerSuite) TestCpCheckDestOwnership(c *check.C) {
41 41
 }
42 42
 
43 43
 func getRootUIDGID() (int, int, error) {
44
-	uidgid := strings.Split(filepath.Base(dockerBasePath), ".")
44
+	uidgid := strings.Split(filepath.Base(testEnv.DockerBasePath()), ".")
45 45
 	if len(uidgid) == 1 {
46 46
 		//user namespace remapping is not turned on; return 0
47 47
 		return 0, 0, nil
... ...
@@ -58,7 +58,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) {
58 58
 // Make sure we can grow the container's rootfs at creation time.
59 59
 func (s *DockerSuite) TestCreateGrowRootfs(c *check.C) {
60 60
 	// Windows and Devicemapper support growing the rootfs
61
-	if daemonPlatform != "windows" {
61
+	if testEnv.DaemonPlatform() != "windows" {
62 62
 		testRequires(c, Devicemapper)
63 63
 	}
64 64
 	out, _ := dockerCmd(c, "create", "--storage-opt", "size=120G", "busybox")
... ...
@@ -226,8 +226,8 @@ func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) {
226 226
 func (s *DockerSuite) TestCreateHostnameWithNumber(c *check.C) {
227 227
 	image := "busybox"
228 228
 	// Busybox on Windows does not implement hostname command
229
-	if daemonPlatform == "windows" {
230
-		image = WindowsBaseImage
229
+	if testEnv.DaemonPlatform() == "windows" {
230
+		image = testEnv.MinimalBaseImage()
231 231
 	}
232 232
 	out, _ := dockerCmd(c, "run", "-h", "web.0", image, "hostname")
233 233
 	c.Assert(strings.TrimSpace(out), checker.Equals, "web.0", check.Commentf("hostname not set, expected `web.0`, got: %s", out))
... ...
@@ -411,7 +411,7 @@ func (s *DockerSuite) TestCreateWithWorkdir(c *check.C) {
411 411
 
412 412
 	dockerCmd(c, "create", "--name", name, "-w", dir, "busybox")
413 413
 	// Windows does not create the workdir until the container is started
414
-	if daemonPlatform == "windows" {
414
+	if testEnv.DaemonPlatform() == "windows" {
415 415
 		dockerCmd(c, "start", name)
416 416
 	}
417 417
 	dockerCmd(c, "cp", fmt.Sprintf("%s:%s", name, dir), prefix+slash+"tmp")
... ...
@@ -1398,7 +1398,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) {
1398 1398
 // A subsequent daemon restart shoud clean up said mounts.
1399 1399
 func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *check.C) {
1400 1400
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
1401
-		Experimental: experimentalDaemon,
1401
+		Experimental: testEnv.ExperimentalDaemon(),
1402 1402
 	})
1403 1403
 	d.StartWithBusybox(c)
1404 1404
 
... ...
@@ -1431,7 +1431,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec
1431 1431
 // os.Interrupt should perform a graceful daemon shutdown and hence cleanup mounts.
1432 1432
 func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *check.C) {
1433 1433
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
1434
-		Experimental: experimentalDaemon,
1434
+		Experimental: testEnv.ExperimentalDaemon(),
1435 1435
 	})
1436 1436
 	d.StartWithBusybox(c)
1437 1437
 
... ...
@@ -1652,7 +1652,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) {
1652 1652
 // FIXME(vdemeester) should be a unit test
1653 1653
 func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) {
1654 1654
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
1655
-		Experimental: experimentalDaemon,
1655
+		Experimental: testEnv.ExperimentalDaemon(),
1656 1656
 	})
1657 1657
 	c.Assert(d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil)
1658 1658
 	expected := "Failed to set log opts: syslog-address should be in form proto://address"
... ...
@@ -1662,7 +1662,7 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) {
1662 1662
 // FIXME(vdemeester) should be a unit test
1663 1663
 func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *check.C) {
1664 1664
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
1665
-		Experimental: experimentalDaemon,
1665
+		Experimental: testEnv.ExperimentalDaemon(),
1666 1666
 	})
1667 1667
 	c.Assert(d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil)
1668 1668
 	expected := "Failed to set log opts: invalid fluentd-address corrupted:c: "
... ...
@@ -19,7 +19,7 @@ func (s *DockerSuite) TestDiffFilenameShownInOutput(c *check.C) {
19 19
 	// a "Files/" prefix.
20 20
 	containerID := strings.TrimSpace(out)
21 21
 	lookingFor := "A /foo/bar"
22
-	if daemonPlatform == "windows" {
22
+	if testEnv.DaemonPlatform() == "windows" {
23 23
 		err := waitExited(containerID, 60*time.Second)
24 24
 		c.Assert(err, check.IsNil)
25 25
 		lookingFor = "C Files/foo/bar"
... ...
@@ -688,7 +688,7 @@ func (s *DockerSuite) TestEventsContainerRestart(c *check.C) {
688 688
 
689 689
 	// wait until test2 is auto removed.
690 690
 	waitTime := 10 * time.Second
691
-	if daemonPlatform == "windows" {
691
+	if testEnv.DaemonPlatform() == "windows" {
692 692
 		// Windows takes longer...
693 693
 		waitTime = 90 * time.Second
694 694
 	}
... ...
@@ -53,7 +53,7 @@ type graphEventsCounter struct {
53 53
 
54 54
 func (s *DockerExternalGraphdriverSuite) SetUpTest(c *check.C) {
55 55
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
56
-		Experimental: experimentalDaemon,
56
+		Experimental: testEnv.ExperimentalDaemon(),
57 57
 	})
58 58
 }
59 59
 
... ...
@@ -51,7 +51,7 @@ type DockerExternalVolumeSuite struct {
51 51
 
52 52
 func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) {
53 53
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
54
-		Experimental: experimentalDaemon,
54
+		Experimental: testEnv.ExperimentalDaemon(),
55 55
 	})
56 56
 	s.ec = &eventCounter{}
57 57
 }
... ...
@@ -118,7 +118,7 @@ func (s *DockerSuite) TestHelpTextVerify(c *check.C) {
118 118
 		cmdsToTest = append(cmdsToTest, "network ls")
119 119
 		cmdsToTest = append(cmdsToTest, "network rm")
120 120
 
121
-		if experimentalDaemon {
121
+		if testEnv.ExperimentalDaemon() {
122 122
 			cmdsToTest = append(cmdsToTest, "checkpoint create")
123 123
 			cmdsToTest = append(cmdsToTest, "checkpoint ls")
124 124
 			cmdsToTest = append(cmdsToTest, "checkpoint rm")
... ...
@@ -36,7 +36,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
36 36
 		"Live Restore Enabled:",
37 37
 	}
38 38
 
39
-	if daemonPlatform == "linux" {
39
+	if testEnv.DaemonPlatform() == "linux" {
40 40
 		stringsToCheck = append(stringsToCheck, "Init Binary:", "Security Options:", "containerd version:", "runc version:", "init version:")
41 41
 	}
42 42
 
... ...
@@ -44,7 +44,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
44 44
 		stringsToCheck = append(stringsToCheck, "Runtimes:", "Default Runtime: runc")
45 45
 	}
46 46
 
47
-	if experimentalDaemon {
47
+	if testEnv.ExperimentalDaemon() {
48 48
 		stringsToCheck = append(stringsToCheck, "Experimental: true")
49 49
 	} else {
50 50
 		stringsToCheck = append(stringsToCheck, "Experimental: false")
... ...
@@ -72,7 +72,7 @@ func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
72 72
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
73 73
 
74 74
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
75
-		Experimental: experimentalDaemon,
75
+		Experimental: testEnv.ExperimentalDaemon(),
76 76
 	})
77 77
 	discoveryBackend := "consul://consuladdr:consulport/some/path"
78 78
 	discoveryAdvertise := "1.1.1.1:2375"
... ...
@@ -91,7 +91,7 @@ func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
91 91
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
92 92
 
93 93
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
94
-		Experimental: experimentalDaemon,
94
+		Experimental: testEnv.ExperimentalDaemon(),
95 95
 	})
96 96
 	discoveryBackend := "consul://consuladdr:consulport/some/path"
97 97
 
... ...
@@ -110,7 +110,7 @@ func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
110 110
 	testRequires(c, SameHostDaemon, Network, DaemonIsLinux)
111 111
 
112 112
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
113
-		Experimental: experimentalDaemon,
113
+		Experimental: testEnv.ExperimentalDaemon(),
114 114
 	})
115 115
 	discoveryBackend := "consul://consuladdr:consulport/some/path"
116 116
 	discoveryAdvertise := "eth0"
... ...
@@ -177,7 +177,7 @@ func (s *DockerSuite) TestInfoDebug(c *check.C) {
177 177
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
178 178
 
179 179
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
180
-		Experimental: experimentalDaemon,
180
+		Experimental: testEnv.ExperimentalDaemon(),
181 181
 	})
182 182
 	d.Start(c, "--debug")
183 183
 	defer d.Stop(c)
... ...
@@ -200,7 +200,7 @@ func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
200 200
 	registryHost := "insecurehost.com:5000"
201 201
 
202 202
 	d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
203
-		Experimental: experimentalDaemon,
203
+		Experimental: testEnv.ExperimentalDaemon(),
204 204
 	})
205 205
 	d.Start(c, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
206 206
 	defer d.Stop(c)
... ...
@@ -53,7 +53,7 @@ func (s *DockerSuite) TestInspectDefault(c *check.C) {
53 53
 }
54 54
 
55 55
 func (s *DockerSuite) TestInspectStatus(c *check.C) {
56
-	if daemonPlatform != "windows" {
56
+	if testEnv.DaemonPlatform() != "windows" {
57 57
 		defer unpauseAllContainers(c)
58 58
 	}
59 59
 	out, _ := runSleepingContainer(c, "-d")
... ...
@@ -64,7 +64,7 @@ func (s *DockerSuite) TestInspectStatus(c *check.C) {
64 64
 
65 65
 	// Windows does not support pause/unpause on Windows Server Containers.
66 66
 	// (RS1 does for Hyper-V Containers, but production CI is not setup for that)
67
-	if daemonPlatform != "windows" {
67
+	if testEnv.DaemonPlatform() != "windows" {
68 68
 		dockerCmd(c, "pause", out)
69 69
 		inspectOut = inspectField(c, out, "State.Status")
70 70
 		c.Assert(inspectOut, checker.Equals, "paused")
... ...
@@ -209,7 +209,7 @@ func (s *DockerSuite) TestInspectContainerGraphDriver(c *check.C) {
209 209
 func (s *DockerSuite) TestInspectBindMountPoint(c *check.C) {
210 210
 	modifier := ",z"
211 211
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
212
-	if daemonPlatform == "windows" {
212
+	if testEnv.DaemonPlatform() == "windows" {
213 213
 		modifier = ""
214 214
 		// Linux creates the host directory if it doesn't exist. Windows does not.
215 215
 		os.Mkdir(`c:\data`, os.ModeDir)
... ...
@@ -232,7 +232,7 @@ func (s *DockerSuite) TestInspectBindMountPoint(c *check.C) {
232 232
 	c.Assert(m.Driver, checker.Equals, "")
233 233
 	c.Assert(m.Source, checker.Equals, prefix+slash+"data")
234 234
 	c.Assert(m.Destination, checker.Equals, prefix+slash+"data")
235
-	if daemonPlatform != "windows" { // Windows does not set mode
235
+	if testEnv.DaemonPlatform() != "windows" { // Windows does not set mode
236 236
 		c.Assert(m.Mode, checker.Equals, "ro"+modifier)
237 237
 	}
238 238
 	c.Assert(m.RW, checker.Equals, false)
... ...
@@ -49,7 +49,7 @@ type DockerNetworkSuite struct {
49 49
 
50 50
 func (s *DockerNetworkSuite) SetUpTest(c *check.C) {
51 51
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
52
-		Experimental: experimentalDaemon,
52
+		Experimental: testEnv.ExperimentalDaemon(),
53 53
 	})
54 54
 }
55 55
 
... ...
@@ -47,7 +47,7 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
47 47
 	c.Assert(err, checker.IsNil)
48 48
 	c.Assert(out, checker.Contains, pNameWithTag)
49 49
 
50
-	_, err = os.Stat(filepath.Join(dockerBasePath, "plugins", id))
50
+	_, err = os.Stat(filepath.Join(testEnv.DockerBasePath(), "plugins", id))
51 51
 	if !os.IsNotExist(err) {
52 52
 		c.Fatal(err)
53 53
 	}
... ...
@@ -213,7 +213,7 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) {
213 213
 	})
214 214
 
215 215
 	// Windows doesn't support pausing of containers
216
-	if daemonPlatform != "windows" {
216
+	if testEnv.DaemonPlatform() != "windows" {
217 217
 		// pause running container
218 218
 		out, _ = dockerCmd(c, "run", "-itd", "busybox")
219 219
 		pausedID := strings.TrimSpace(out)
... ...
@@ -104,7 +104,7 @@ func (s *DockerSuite) TestRenameAnonymousContainer(c *check.C) {
104 104
 	dockerCmd(c, "start", "container1")
105 105
 
106 106
 	count := "-c"
107
-	if daemonPlatform == "windows" {
107
+	if testEnv.DaemonPlatform() == "windows" {
108 108
 		count = "-n"
109 109
 	}
110 110
 
... ...
@@ -253,7 +253,7 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *check.C) {
253 253
 	id1 := strings.TrimSpace(string(out1))
254 254
 	id2 := strings.TrimSpace(string(out2))
255 255
 	waitTimeout := 15 * time.Second
256
-	if daemonPlatform == "windows" {
256
+	if testEnv.DaemonPlatform() == "windows" {
257 257
 		waitTimeout = 150 * time.Second
258 258
 	}
259 259
 	err := waitInspect(id1, "{{ .State.Restarting }} {{ .State.Running }}", "false false", waitTimeout)
... ...
@@ -67,7 +67,7 @@ func (s *DockerSuite) TestRmiImgIDMultipleTag(c *check.C) {
67 67
 
68 68
 	// Wait for it to exit as cannot commit a running container on Windows, and
69 69
 	// it will take a few seconds to exit
70
-	if daemonPlatform == "windows" {
70
+	if testEnv.DaemonPlatform() == "windows" {
71 71
 		err := waitExited(containerID, 60*time.Second)
72 72
 		c.Assert(err, check.IsNil)
73 73
 	}
... ...
@@ -111,7 +111,7 @@ func (s *DockerSuite) TestRmiImgIDForce(c *check.C) {
111 111
 
112 112
 	// Wait for it to exit as cannot commit a running container on Windows, and
113 113
 	// it will take a few seconds to exit
114
-	if daemonPlatform == "windows" {
114
+	if testEnv.DaemonPlatform() == "windows" {
115 115
 		err := waitExited(containerID, 60*time.Second)
116 116
 		c.Assert(err, check.IsNil)
117 117
 	}
... ...
@@ -67,10 +67,10 @@ func (s *DockerSuite) TestRunLeakyFileDescriptors(c *check.C) {
67 67
 // this will fail when Internet access is unavailable
68 68
 func (s *DockerSuite) TestRunLookupGoogleDNS(c *check.C) {
69 69
 	testRequires(c, Network, NotArm)
70
-	if daemonPlatform == "windows" {
70
+	if testEnv.DaemonPlatform() == "windows" {
71 71
 		// nslookup isn't present in Windows busybox. Is built-in. Further,
72 72
 		// nslookup isn't present in nanoserver. Hence just use PowerShell...
73
-		dockerCmd(c, "run", WindowsBaseImage, "powershell", "Resolve-DNSName", "google.com")
73
+		dockerCmd(c, "run", testEnv.MinimalBaseImage(), "powershell", "Resolve-DNSName", "google.com")
74 74
 	} else {
75 75
 		dockerCmd(c, "run", "busybox", "nslookup", "google.com")
76 76
 	}
... ...
@@ -132,7 +132,7 @@ func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *check.C) {
132 132
 func (s *DockerSuite) TestRunWorkingDirectory(c *check.C) {
133 133
 	dir := "/root"
134 134
 	image := "busybox"
135
-	if daemonPlatform == "windows" {
135
+	if testEnv.DaemonPlatform() == "windows" {
136 136
 		dir = `C:/Windows`
137 137
 	}
138 138
 
... ...
@@ -155,9 +155,9 @@ func (s *DockerSuite) TestRunWorkingDirectory(c *check.C) {
155 155
 func (s *DockerSuite) TestRunWithoutNetworking(c *check.C) {
156 156
 	count := "-c"
157 157
 	image := "busybox"
158
-	if daemonPlatform == "windows" {
158
+	if testEnv.DaemonPlatform() == "windows" {
159 159
 		count = "-n"
160
-		image = WindowsBaseImage
160
+		image = testEnv.MinimalBaseImage()
161 161
 	}
162 162
 
163 163
 	// First using the long form --net
... ...
@@ -349,8 +349,8 @@ func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) {
349 349
 	)
350 350
 
351 351
 	// Create a file in a volume
352
-	if daemonPlatform == "windows" {
353
-		out, exitCode = dockerCmd(c, "run", "--name", "test-data", "--volume", `c:\some\dir`, WindowsBaseImage, "cmd", "/c", `echo hello > c:\some\dir\file`)
352
+	if testEnv.DaemonPlatform() == "windows" {
353
+		out, exitCode = dockerCmd(c, "run", "--name", "test-data", "--volume", `c:\some\dir`, testEnv.MinimalBaseImage(), "cmd", "/c", `echo hello > c:\some\dir\file`)
354 354
 	} else {
355 355
 		out, exitCode = dockerCmd(c, "run", "--name", "test-data", "--volume", "/some/dir", "busybox", "touch", "/some/dir/file")
356 356
 	}
... ...
@@ -359,8 +359,8 @@ func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) {
359 359
 	}
360 360
 
361 361
 	// Read the file from another container using --volumes-from to access the volume in the second container
362
-	if daemonPlatform == "windows" {
363
-		out, exitCode = dockerCmd(c, "run", "--volumes-from", "test-data", WindowsBaseImage, "cmd", "/c", `type c:\some\dir\file`)
362
+	if testEnv.DaemonPlatform() == "windows" {
363
+		out, exitCode = dockerCmd(c, "run", "--volumes-from", "test-data", testEnv.MinimalBaseImage(), "cmd", "/c", `type c:\some\dir\file`)
364 364
 	} else {
365 365
 		out, exitCode = dockerCmd(c, "run", "--volumes-from", "test-data", "busybox", "cat", "/some/dir/file")
366 366
 	}
... ...
@@ -391,7 +391,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
391 391
 	// In the case of Windows to Windows CI, if the machine is setup so that
392 392
 	// the temp directory is not the C: drive, this test is invalid and will
393 393
 	// not work.
394
-	if daemonPlatform == "windows" && strings.ToLower(dir[:1]) != "c" {
394
+	if testEnv.DaemonPlatform() == "windows" && strings.ToLower(dir[:1]) != "c" {
395 395
 		c.Skip("Requires TEMP to point to C: drive")
396 396
 	}
397 397
 
... ...
@@ -401,8 +401,8 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
401 401
 	}
402 402
 	f.Close()
403 403
 
404
-	if daemonPlatform == "windows" {
405
-		dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir %s\nRUN mklink /D c:\\test %s", WindowsBaseImage, dir, dir)
404
+	if testEnv.DaemonPlatform() == "windows" {
405
+		dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir %s\nRUN mklink /D c:\\test %s", testEnv.MinimalBaseImage(), dir, dir)
406 406
 		containerPath = `c:\test\test`
407 407
 		cmd = "tasklist"
408 408
 	} else {
... ...
@@ -429,8 +429,8 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *check.C) {
429 429
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
430 430
 	name := "test-volume-symlink2"
431 431
 
432
-	if daemonPlatform == "windows" {
433
-		dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir c:\\%s\nRUN mklink /D c:\\test c:\\%s", WindowsBaseImage, name, name)
432
+	if testEnv.DaemonPlatform() == "windows" {
433
+		dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir c:\\%s\nRUN mklink /D c:\\test c:\\%s", testEnv.MinimalBaseImage(), name, name)
434 434
 		containerPath = `c:\test\test`
435 435
 		cmd = "tasklist"
436 436
 	} else {
... ...
@@ -456,7 +456,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadonlyModeFails(c *check.C) {
456 456
 		volumeDir string
457 457
 		fileInVol string
458 458
 	)
459
-	if daemonPlatform == "windows" {
459
+	if testEnv.DaemonPlatform() == "windows" {
460 460
 		volumeDir = `c:/test` // Forward-slash as using busybox
461 461
 		fileInVol = `c:/test/file`
462 462
 	} else {
... ...
@@ -477,7 +477,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) {
477 477
 		volumeDir string
478 478
 		fileInVol string
479 479
 	)
480
-	if daemonPlatform == "windows" {
480
+	if testEnv.DaemonPlatform() == "windows" {
481 481
 		volumeDir = `c:/test` // Forward-slash as using busybox
482 482
 		fileInVol = `c:/test/file`
483 483
 	} else {
... ...
@@ -498,7 +498,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) {
498 498
 func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) {
499 499
 	testRequires(c, SameHostDaemon)
500 500
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
501
-	hostpath := testutil.RandomTmpDirPath("test", daemonPlatform)
501
+	hostpath := testutil.RandomTmpDirPath("test", testEnv.DaemonPlatform())
502 502
 	if err := os.MkdirAll(hostpath, 0755); err != nil {
503 503
 		c.Fatalf("Failed to create %s: %q", hostpath, err)
504 504
 	}
... ...
@@ -521,11 +521,11 @@ func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) {
521 521
 
522 522
 // Test for GH#10618
523 523
 func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) {
524
-	path1 := testutil.RandomTmpDirPath("test1", daemonPlatform)
525
-	path2 := testutil.RandomTmpDirPath("test2", daemonPlatform)
524
+	path1 := testutil.RandomTmpDirPath("test1", testEnv.DaemonPlatform())
525
+	path2 := testutil.RandomTmpDirPath("test2", testEnv.DaemonPlatform())
526 526
 
527 527
 	someplace := ":/someplace"
528
-	if daemonPlatform == "windows" {
528
+	if testEnv.DaemonPlatform() == "windows" {
529 529
 		// Windows requires that the source directory exists before calling HCS
530 530
 		testRequires(c, SameHostDaemon)
531 531
 		someplace = `:c:\someplace`
... ...
@@ -574,7 +574,7 @@ func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) {
574 574
 // Test for #1351
575 575
 func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *check.C) {
576 576
 	prefix := ""
577
-	if daemonPlatform == "windows" {
577
+	if testEnv.DaemonPlatform() == "windows" {
578 578
 		prefix = `c:`
579 579
 	}
580 580
 	dockerCmd(c, "run", "--name", "parent", "-v", prefix+"/test", "busybox", "touch", prefix+"/test/foo")
... ...
@@ -583,7 +583,7 @@ func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *check.C) {
583 583
 
584 584
 func (s *DockerSuite) TestRunMultipleVolumesFrom(c *check.C) {
585 585
 	prefix := ""
586
-	if daemonPlatform == "windows" {
586
+	if testEnv.DaemonPlatform() == "windows" {
587 587
 		prefix = `c:`
588 588
 	}
589 589
 	dockerCmd(c, "run", "--name", "parent1", "-v", prefix+"/test", "busybox", "touch", prefix+"/test/foo")
... ...
@@ -613,7 +613,7 @@ func (s *DockerSuite) TestRunVerifyContainerID(c *check.C) {
613 613
 // Test that creating a container with a volume doesn't crash. Regression test for #995.
614 614
 func (s *DockerSuite) TestRunCreateVolume(c *check.C) {
615 615
 	prefix := ""
616
-	if daemonPlatform == "windows" {
616
+	if testEnv.DaemonPlatform() == "windows" {
617 617
 		prefix = `c:`
618 618
 	}
619 619
 	dockerCmd(c, "run", "-v", prefix+"/var/lib/data", "busybox", "true")
... ...
@@ -669,9 +669,9 @@ func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *check.C) {
669 669
 		RUN ln -s home /foo
670 670
 		VOLUME ["/foo/bar"]`
671 671
 
672
-	if daemonPlatform == "windows" {
672
+	if testEnv.DaemonPlatform() == "windows" {
673 673
 		prefix = `c:`
674
-		dfContents = `FROM ` + WindowsBaseImage + `
674
+		dfContents = `FROM ` + testEnv.MinimalBaseImage() + `
675 675
 	    RUN mkdir c:\home
676 676
 		RUN mklink /D c:\foo c:\home
677 677
 		VOLUME ["c:/foo/bar"]
... ...
@@ -715,7 +715,7 @@ func (s *DockerSuite) TestRunExitCode(c *check.C) {
715 715
 
716 716
 func (s *DockerSuite) TestRunUserDefaults(c *check.C) {
717 717
 	expected := "uid=0(root) gid=0(root)"
718
-	if daemonPlatform == "windows" {
718
+	if testEnv.DaemonPlatform() == "windows" {
719 719
 		expected = "uid=1000(ContainerAdministrator) gid=1000(ContainerAdministrator)"
720 720
 	}
721 721
 	out, _ := dockerCmd(c, "run", "busybox", "id")
... ...
@@ -921,9 +921,9 @@ func (s *DockerSuite) TestRunEnvironmentOverride(c *check.C) {
921 921
 }
922 922
 
923 923
 func (s *DockerSuite) TestRunContainerNetwork(c *check.C) {
924
-	if daemonPlatform == "windows" {
924
+	if testEnv.DaemonPlatform() == "windows" {
925 925
 		// Windows busybox does not have ping. Use built in ping instead.
926
-		dockerCmd(c, "run", WindowsBaseImage, "ping", "-n", "1", "127.0.0.1")
926
+		dockerCmd(c, "run", testEnv.MinimalBaseImage(), "ping", "-n", "1", "127.0.0.1")
927 927
 	} else {
928 928
 		dockerCmd(c, "run", "busybox", "ping", "-c", "1", "127.0.0.1")
929 929
 	}
... ...
@@ -1221,7 +1221,7 @@ func (s *DockerSuite) TestRunModeHostname(c *check.C) {
1221 1221
 func (s *DockerSuite) TestRunRootWorkdir(c *check.C) {
1222 1222
 	out, _ := dockerCmd(c, "run", "--workdir", "/", "busybox", "pwd")
1223 1223
 	expected := "/\n"
1224
-	if daemonPlatform == "windows" {
1224
+	if testEnv.DaemonPlatform() == "windows" {
1225 1225
 		expected = "C:" + expected
1226 1226
 	}
1227 1227
 	if out != expected {
... ...
@@ -1230,9 +1230,9 @@ func (s *DockerSuite) TestRunRootWorkdir(c *check.C) {
1230 1230
 }
1231 1231
 
1232 1232
 func (s *DockerSuite) TestRunAllowBindMountingRoot(c *check.C) {
1233
-	if daemonPlatform == "windows" {
1233
+	if testEnv.DaemonPlatform() == "windows" {
1234 1234
 		// Windows busybox will fail with Permission Denied on items such as pagefile.sys
1235
-		dockerCmd(c, "run", "-v", `c:\:c:\host`, WindowsBaseImage, "cmd", "-c", "dir", `c:\host`)
1235
+		dockerCmd(c, "run", "-v", `c:\:c:\host`, testEnv.MinimalBaseImage(), "cmd", "-c", "dir", `c:\host`)
1236 1236
 	} else {
1237 1237
 		dockerCmd(c, "run", "-v", "/:/host", "busybox", "ls", "/host")
1238 1238
 	}
... ...
@@ -1241,7 +1241,7 @@ func (s *DockerSuite) TestRunAllowBindMountingRoot(c *check.C) {
1241 1241
 func (s *DockerSuite) TestRunDisallowBindMountingRootToRoot(c *check.C) {
1242 1242
 	mount := "/:/"
1243 1243
 	targetDir := "/host"
1244
-	if daemonPlatform == "windows" {
1244
+	if testEnv.DaemonPlatform() == "windows" {
1245 1245
 		mount = `c:\:c\`
1246 1246
 		targetDir = "c:/host" // Forward slash as using busybox
1247 1247
 	}
... ...
@@ -1753,15 +1753,15 @@ func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) {
1753 1753
 	}
1754 1754
 	out = strings.TrimSpace(out)
1755 1755
 	expected := "root"
1756
-	if daemonPlatform == "windows" {
1757
-		if strings.Contains(WindowsBaseImage, "windowsservercore") {
1756
+	if testEnv.DaemonPlatform() == "windows" {
1757
+		if strings.Contains(testEnv.MinimalBaseImage(), "windowsservercore") {
1758 1758
 			expected = `user manager\containeradministrator`
1759 1759
 		} else {
1760 1760
 			expected = `ContainerAdministrator` // nanoserver
1761 1761
 		}
1762 1762
 	}
1763 1763
 	if out != expected {
1764
-		c.Fatalf("Expected output %s, got %q. %s", expected, out, WindowsBaseImage)
1764
+		c.Fatalf("Expected output %s, got %q. %s", expected, out, testEnv.MinimalBaseImage())
1765 1765
 	}
1766 1766
 }
1767 1767
 
... ...
@@ -1769,7 +1769,7 @@ func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) {
1769 1769
 func (s *DockerSuite) TestRunWorkdirExistsAndIsFile(c *check.C) {
1770 1770
 	existingFile := "/bin/cat"
1771 1771
 	expected := "not a directory"
1772
-	if daemonPlatform == "windows" {
1772
+	if testEnv.DaemonPlatform() == "windows" {
1773 1773
 		existingFile = `\windows\system32\ntdll.dll`
1774 1774
 		expected = `Cannot mkdir: \windows\system32\ntdll.dll is not a directory.`
1775 1775
 	}
... ...
@@ -1785,7 +1785,7 @@ func (s *DockerSuite) TestRunExitOnStdinClose(c *check.C) {
1785 1785
 
1786 1786
 	meow := "/bin/cat"
1787 1787
 	delay := 60
1788
-	if daemonPlatform == "windows" {
1788
+	if testEnv.DaemonPlatform() == "windows" {
1789 1789
 		meow = "cat"
1790 1790
 	}
1791 1791
 	runCmd := exec.Command(dockerBinary, "run", "--name", name, "-i", "busybox", meow)
... ...
@@ -1932,7 +1932,7 @@ func (s *DockerSuite) TestRunEntrypoint(c *check.C) {
1932 1932
 
1933 1933
 func (s *DockerSuite) TestRunBindMounts(c *check.C) {
1934 1934
 	testRequires(c, SameHostDaemon)
1935
-	if daemonPlatform == "linux" {
1935
+	if testEnv.DaemonPlatform() == "linux" {
1936 1936
 		testRequires(c, DaemonIsLinux, NotUserNamespace)
1937 1937
 	}
1938 1938
 
... ...
@@ -1953,7 +1953,7 @@ func (s *DockerSuite) TestRunBindMounts(c *check.C) {
1953 1953
 	}
1954 1954
 
1955 1955
 	// test writing to bind mount
1956
-	if daemonPlatform == "windows" {
1956
+	if testEnv.DaemonPlatform() == "windows" {
1957 1957
 		dockerCmd(c, "run", "-v", fmt.Sprintf(`%s:c:\tmp:rw`, tmpDir), "busybox", "touch", "c:/tmp/holla")
1958 1958
 	} else {
1959 1959
 		dockerCmd(c, "run", "-v", fmt.Sprintf("%s:/tmp:rw", tmpDir), "busybox", "touch", "/tmp/holla")
... ...
@@ -1968,7 +1968,7 @@ func (s *DockerSuite) TestRunBindMounts(c *check.C) {
1968 1968
 	}
1969 1969
 
1970 1970
 	// Windows does not (and likely never will) support mounting a single file
1971
-	if daemonPlatform != "windows" {
1971
+	if testEnv.DaemonPlatform() != "windows" {
1972 1972
 		// test mount a file
1973 1973
 		dockerCmd(c, "run", "-v", fmt.Sprintf("%s/holla:/tmp/holla:rw", tmpDir), "busybox", "sh", "-c", "echo -n 'yotta' > /tmp/holla")
1974 1974
 		content := readFile(path.Join(tmpDir, "holla"), c) // Will fail if the file doesn't exist
... ...
@@ -1993,9 +1993,9 @@ func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *check.C) {
1993 1993
 	tmpCidFile := path.Join(tmpDir, "cid")
1994 1994
 
1995 1995
 	image := "emptyfs"
1996
-	if daemonPlatform == "windows" {
1996
+	if testEnv.DaemonPlatform() == "windows" {
1997 1997
 		// Windows can't support an emptyfs image. Just use the regular Windows image
1998
-		image = WindowsBaseImage
1998
+		image = testEnv.MinimalBaseImage()
1999 1999
 	}
2000 2000
 	out, _, err := dockerCmdWithError("run", "--cidfile", tmpCidFile, image)
2001 2001
 	if err == nil {
... ...
@@ -2039,7 +2039,7 @@ func (s *DockerSuite) TestRunCidFileCheckIDLength(c *check.C) {
2039 2039
 func (s *DockerSuite) TestRunSetMacAddress(c *check.C) {
2040 2040
 	mac := "12:34:56:78:9a:bc"
2041 2041
 	var out string
2042
-	if daemonPlatform == "windows" {
2042
+	if testEnv.DaemonPlatform() == "windows" {
2043 2043
 		out, _ = dockerCmd(c, "run", "-i", "--rm", fmt.Sprintf("--mac-address=%s", mac), "busybox", "sh", "-c", "ipconfig /all | grep 'Physical Address' | awk '{print $12}'")
2044 2044
 		mac = strings.Replace(strings.ToUpper(mac), ":", "-", -1) // To Windows-style MACs
2045 2045
 	} else {
... ...
@@ -2243,7 +2243,7 @@ func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) {
2243 2243
 		c.Fatalf("Data was copied on volumes-from but shouldn't be:\n%q", out)
2244 2244
 	}
2245 2245
 
2246
-	tmpDir := testutil.RandomTmpDirPath("docker_test_bind_mount_copy_data", daemonPlatform)
2246
+	tmpDir := testutil.RandomTmpDirPath("docker_test_bind_mount_copy_data", testEnv.DaemonPlatform())
2247 2247
 	if out, _, err := dockerCmdWithError("run", "-v", tmpDir+":/foo", "dataimage", "ls", "-lh", "/foo/bar"); err == nil || !strings.Contains(out, "No such file or directory") {
2248 2248
 		c.Fatalf("Data was copied on bind-mount but shouldn't be:\n%q", out)
2249 2249
 	}
... ...
@@ -2281,7 +2281,7 @@ func (s *DockerSuite) TestRunVolumesCleanPaths(c *check.C) {
2281 2281
 
2282 2282
 	out, err = inspectMountSourceField("dark_helmet", prefix+slash+`foo`)
2283 2283
 	c.Assert(err, check.IsNil)
2284
-	if !strings.Contains(strings.ToLower(out), strings.ToLower(volumesConfigPath)) {
2284
+	if !strings.Contains(strings.ToLower(out), strings.ToLower(testEnv.VolumesConfigPath())) {
2285 2285
 		c.Fatalf("Volume was not defined for %s/foo\n%q", prefix, out)
2286 2286
 	}
2287 2287
 
... ...
@@ -2292,7 +2292,7 @@ func (s *DockerSuite) TestRunVolumesCleanPaths(c *check.C) {
2292 2292
 
2293 2293
 	out, err = inspectMountSourceField("dark_helmet", prefix+slash+"bar")
2294 2294
 	c.Assert(err, check.IsNil)
2295
-	if !strings.Contains(strings.ToLower(out), strings.ToLower(volumesConfigPath)) {
2295
+	if !strings.Contains(strings.ToLower(out), strings.ToLower(testEnv.VolumesConfigPath())) {
2296 2296
 		c.Fatalf("Volume was not defined for %s/bar\n%q", prefix, out)
2297 2297
 	}
2298 2298
 }
... ...
@@ -2662,10 +2662,10 @@ func (s *DockerSuite) TestRunNonLocalMacAddress(c *check.C) {
2662 2662
 	args := []string{"run", "--mac-address", addr}
2663 2663
 	expected := addr
2664 2664
 
2665
-	if daemonPlatform != "windows" {
2665
+	if testEnv.DaemonPlatform() != "windows" {
2666 2666
 		args = append(args, "busybox", "ifconfig")
2667 2667
 	} else {
2668
-		args = append(args, WindowsBaseImage, "ipconfig", "/all")
2668
+		args = append(args, testEnv.MinimalBaseImage(), "ipconfig", "/all")
2669 2669
 		expected = strings.Replace(strings.ToUpper(addr), ":", "-", -1)
2670 2670
 	}
2671 2671
 
... ...
@@ -2758,7 +2758,7 @@ func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *check.C) {
2758 2758
 func (s *DockerSuite) TestRunRestartMaxRetries(c *check.C) {
2759 2759
 	out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false")
2760 2760
 	timeout := 10 * time.Second
2761
-	if daemonPlatform == "windows" {
2761
+	if testEnv.DaemonPlatform() == "windows" {
2762 2762
 		timeout = 120 * time.Second
2763 2763
 	}
2764 2764
 
... ...
@@ -3133,7 +3133,7 @@ func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *check.C) {
3133 3133
 	dockerCmd(c, "run", "--volumes-from", "parent:ro", "--name", "test-volumes-1", "busybox", "true")
3134 3134
 	dockerCmd(c, "run", "--volumes-from", "parent:rw", "--name", "test-volumes-2", "busybox", "true")
3135 3135
 
3136
-	if daemonPlatform != "windows" {
3136
+	if testEnv.DaemonPlatform() != "windows" {
3137 3137
 		mRO, err := inspectMountPoint("test-volumes-1", prefix+slash+"test")
3138 3138
 		c.Assert(err, checker.IsNil, check.Commentf("failed to inspect mount point"))
3139 3139
 		if mRO.RW {
... ...
@@ -3607,8 +3607,8 @@ func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *check.C
3607 3607
 
3608 3608
 // Issue #4681
3609 3609
 func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *check.C) {
3610
-	if daemonPlatform == "windows" {
3611
-		dockerCmd(c, "run", "--net=none", WindowsBaseImage, "ping", "-n", "1", "127.0.0.1")
3610
+	if testEnv.DaemonPlatform() == "windows" {
3611
+		dockerCmd(c, "run", "--net=none", testEnv.MinimalBaseImage(), "ping", "-n", "1", "127.0.0.1")
3612 3612
 	} else {
3613 3613
 		dockerCmd(c, "run", "--net=none", "busybox", "ping", "-c", "1", "127.0.0.1")
3614 3614
 	}
... ...
@@ -3874,7 +3874,7 @@ func (s *DockerSuite) TestRunNonExistingCmd(c *check.C) {
3874 3874
 // as that's when the check is made (and yes, by its design...)
3875 3875
 func (s *DockerSuite) TestCmdCannotBeInvoked(c *check.C) {
3876 3876
 	expected := 126
3877
-	if daemonPlatform == "windows" {
3877
+	if testEnv.DaemonPlatform() == "windows" {
3878 3878
 		expected = 127
3879 3879
 	}
3880 3880
 	name := "testCmdCannotBeInvoked"
... ...
@@ -4311,7 +4311,7 @@ func (s *DockerSuite) TestRunCredentialSpecFailures(c *check.C) {
4311 4311
 func (s *DockerSuite) TestRunCredentialSpecWellFormed(c *check.C) {
4312 4312
 	testRequires(c, DaemonIsWindows, SameHostDaemon)
4313 4313
 	validCS := readFile(`fixtures\credentialspecs\valid.json`, c)
4314
-	writeFile(filepath.Join(dockerBasePath, `credentialspecs\valid.json`), validCS, c)
4314
+	writeFile(filepath.Join(testEnv.DockerBasePath(), `credentialspecs\valid.json`), validCS, c)
4315 4315
 	dockerCmd(c, "run", `--security-opt=credentialspec=file://valid.json`, "busybox", "true")
4316 4316
 }
4317 4317
 
... ...
@@ -4321,7 +4321,7 @@ func (s *DockerSuite) TestRunCredentialSpecWellFormed(c *check.C) {
4321 4321
 func (s *DockerSuite) TestRunServicingContainer(c *check.C) {
4322 4322
 	testRequires(c, DaemonIsWindows, SameHostDaemon)
4323 4323
 
4324
-	out, _ := dockerCmd(c, "run", "-d", WindowsBaseImage, "cmd", "/c", "mkdir c:\\programdata\\Microsoft\\Windows\\ContainerUpdates\\000_000_d99f45d0-ffc8-4af7-bd9c-ea6a62e035c9_200 && sc control cexecsvc 255")
4324
+	out, _ := dockerCmd(c, "run", "-d", testEnv.MinimalBaseImage(), "cmd", "/c", "mkdir c:\\programdata\\Microsoft\\Windows\\ContainerUpdates\\000_000_d99f45d0-ffc8-4af7-bd9c-ea6a62e035c9_200 && sc control cexecsvc 255")
4325 4325
 	containerID := strings.TrimSpace(out)
4326 4326
 	err := waitExited(containerID, 60*time.Second)
4327 4327
 	c.Assert(err, checker.IsNil)
... ...
@@ -13,7 +13,7 @@ func (s *DockerSuite) TestTopMultipleArgs(c *check.C) {
13 13
 	cleanedContainerID := strings.TrimSpace(out)
14 14
 
15 15
 	var expected icmd.Expected
16
-	switch daemonPlatform {
16
+	switch testEnv.DaemonPlatform() {
17 17
 	case "windows":
18 18
 		expected = icmd.Expected{ExitCode: 1, Err: "Windows does not support arguments to top"}
19 19
 	default:
... ...
@@ -34,7 +34,7 @@ func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
34 34
 	// Windows will list the name of the launched executable which in this case is busybox.exe, without the parameters.
35 35
 	// Linux will display the command executed in the container
36 36
 	var lookingFor string
37
-	if daemonPlatform == "windows" {
37
+	if testEnv.DaemonPlatform() == "windows" {
38 38
 		lookingFor = "busybox.exe"
39 39
 	} else {
40 40
 		lookingFor = "top"
... ...
@@ -11,7 +11,7 @@ import (
11 11
 func (s *DockerSuite) TestUpdateRestartPolicy(c *check.C) {
12 12
 	out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "sh", "-c", "sleep 1 && false")
13 13
 	timeout := 60 * time.Second
14
-	if daemonPlatform == "windows" {
14
+	if testEnv.DaemonPlatform() == "windows" {
15 15
 		timeout = 180 * time.Second
16 16
 	}
17 17
 
... ...
@@ -33,7 +33,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) {
33 33
 	// TODO Windows CI: Investigate further why this fails on Windows to Windows CI.
34 34
 	testRequires(c, DaemonIsLinux)
35 35
 	path := "/foo"
36
-	if daemonPlatform == "windows" {
36
+	if testEnv.DaemonPlatform() == "windows" {
37 37
 		path = `c:\foo`
38 38
 	}
39 39
 	name := "testing"
... ...
@@ -46,7 +46,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) {
46 46
 	c.Assert(err, checker.IsNil)
47 47
 	c.Assert(status, checker.Equals, http.StatusCreated)
48 48
 
49
-	bindPath := testutil.RandomTmpDirPath("test", daemonPlatform)
49
+	bindPath := testutil.RandomTmpDirPath("test", testEnv.DaemonPlatform())
50 50
 	config = map[string]interface{}{
51 51
 		"Binds": []string{bindPath + ":" + path},
52 52
 	}
... ...
@@ -73,8 +73,8 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *check.C)
73 73
 	c.Assert(err, checker.IsNil)
74 74
 	c.Assert(status, checker.Equals, http.StatusCreated)
75 75
 
76
-	bindPath1 := testutil.RandomTmpDirPath("test1", daemonPlatform)
77
-	bindPath2 := testutil.RandomTmpDirPath("test2", daemonPlatform)
76
+	bindPath1 := testutil.RandomTmpDirPath("test1", testEnv.DaemonPlatform())
77
+	bindPath2 := testutil.RandomTmpDirPath("test2", testEnv.DaemonPlatform())
78 78
 
79 79
 	config = map[string]interface{}{
80 80
 		"Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"},
... ...
@@ -41,7 +41,7 @@ func newDockerHubPullSuite() *DockerHubPullSuite {
41 41
 func (s *DockerHubPullSuite) SetUpSuite(c *check.C) {
42 42
 	testRequires(c, DaemonIsLinux)
43 43
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
44
-		Experimental: experimentalDaemon,
44
+		Experimental: testEnv.ExperimentalDaemon(),
45 45
 	})
46 46
 	s.d.Start(c)
47 47
 }
... ...
@@ -80,7 +80,7 @@ func deleteAllNetworks(c *check.C) {
80 80
 		if n.Name == "bridge" || n.Name == "none" || n.Name == "host" {
81 81
 			continue
82 82
 		}
83
-		if daemonPlatform == "windows" && strings.ToLower(n.Name) == "nat" {
83
+		if testEnv.DaemonPlatform() == "windows" && strings.ToLower(n.Name) == "nat" {
84 84
 			// nat is a pre-defined network on Windows and cannot be removed
85 85
 			continue
86 86
 		}
... ...
@@ -290,7 +290,7 @@ func dockerCmdInDir(c *check.C, path string, args ...string) (string, int, error
290 290
 // validateArgs is a checker to ensure tests are not running commands which are
291 291
 // not supported on platforms. Specifically on Windows this is 'busybox top'.
292 292
 func validateArgs(args ...string) error {
293
-	if daemonPlatform != "windows" {
293
+	if testEnv.DaemonPlatform() != "windows" {
294 294
 		return nil
295 295
 	}
296 296
 	foundBusybox := -1
... ...
@@ -448,7 +448,7 @@ func fakeStorage(files map[string]string) (FakeStorage, error) {
448 448
 
449 449
 // fakeStorageWithContext returns either a local or remote (at daemon machine) file server
450 450
 func fakeStorageWithContext(ctx *FakeContext) (FakeStorage, error) {
451
-	if isLocalDaemon {
451
+	if testEnv.LocalDaemon() {
452 452
 		return newLocalFakeStorage(ctx)
453 453
 	}
454 454
 	return newRemoteFileServer(ctx)
... ...
@@ -1027,7 +1027,7 @@ func readFile(src string, c *check.C) (content string) {
1027 1027
 }
1028 1028
 
1029 1029
 func containerStorageFile(containerID, basename string) string {
1030
-	return filepath.Join(containerStoragePath, containerID, basename)
1030
+	return filepath.Join(testEnv.ContainerStoragePath(), containerID, basename)
1031 1031
 }
1032 1032
 
1033 1033
 // docker commands that use this function must be run with the '-d' switch.
... ...
@@ -1068,7 +1068,7 @@ func readContainerFileWithExec(containerID, filename string) ([]byte, error) {
1068 1068
 
1069 1069
 // daemonTime provides the current time on the daemon host
1070 1070
 func daemonTime(c *check.C) time.Time {
1071
-	if isLocalDaemon {
1071
+	if testEnv.LocalDaemon() {
1072 1072
 		return time.Now()
1073 1073
 	}
1074 1074
 
... ...
@@ -8,11 +8,10 @@ import (
8 8
 	"strconv"
9 9
 	"strings"
10 10
 
11
-	"golang.org/x/net/context"
12
-
13 11
 	"github.com/docker/docker/api/types"
14 12
 	"github.com/docker/docker/api/types/container"
15 13
 	"github.com/docker/docker/client"
14
+	"golang.org/x/net/context"
16 15
 )
17 16
 
18 17
 // Execution holds informations about the test execution environment.
... ...
@@ -50,7 +50,7 @@ func ensureSyscallTest(c *check.C) {
50 50
 
51 51
 	// if no match, must build in docker, which is significantly slower
52 52
 	// (slower mostly because of the vfs graphdriver)
53
-	if daemonPlatform != runtime.GOOS {
53
+	if testEnv.DaemonPlatform() != runtime.GOOS {
54 54
 		ensureSyscallTestBuild(c)
55 55
 		return
56 56
 	}
... ...
@@ -105,7 +105,7 @@ func ensureSyscallTestBuild(c *check.C) {
105 105
 
106 106
 func ensureNNPTest(c *check.C) {
107 107
 	protectedImages["nnp-test:latest"] = struct{}{}
108
-	if daemonPlatform != runtime.GOOS {
108
+	if testEnv.DaemonPlatform() != runtime.GOOS {
109 109
 		ensureNNPTestBuild(c)
110 110
 		return
111 111
 	}
... ...
@@ -29,7 +29,7 @@ func ensureHTTPServerImage() error {
29 29
 	}
30 30
 	defer os.RemoveAll(tmp)
31 31
 
32
-	goos := daemonPlatform
32
+	goos := testEnv.DaemonPlatform()
33 33
 	if goos == "" {
34 34
 		goos = "linux"
35 35
 	}
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func PlatformIs(platform string) bool {
17
-	return daemonPlatform == platform
17
+	return testEnv.DaemonPlatform() == platform
18 18
 }
19 19
 
20 20
 func ArchitectureIs(arch string) bool {
... ...
@@ -26,11 +26,11 @@ func ArchitectureIsNot(arch string) bool {
26 26
 }
27 27
 
28 28
 func StorageDriverIs(storageDriver string) bool {
29
-	return strings.HasPrefix(daemonStorageDriver, storageDriver)
29
+	return strings.HasPrefix(testEnv.DaemonStorageDriver(), storageDriver)
30 30
 }
31 31
 
32 32
 func StorageDriverIsNot(storageDriver string) bool {
33
-	return !strings.HasPrefix(daemonStorageDriver, storageDriver)
33
+	return !strings.HasPrefix(testEnv.DaemonStorageDriver(), storageDriver)
34 34
 }
35 35
 
36 36
 func DaemonIsWindows() bool {
... ...
@@ -42,11 +42,11 @@ func DaemonIsLinux() bool {
42 42
 }
43 43
 
44 44
 func ExperimentalDaemon() bool {
45
-	return experimentalDaemon
45
+	return testEnv.ExperimentalDaemon()
46 46
 }
47 47
 
48 48
 func NotExperimentalDaemon() bool {
49
-	return !experimentalDaemon
49
+	return !testEnv.ExperimentalDaemon()
50 50
 }
51 51
 
52 52
 func IsAmd64() bool {
... ...
@@ -70,7 +70,7 @@ func NotS390X() bool {
70 70
 }
71 71
 
72 72
 func SameHostDaemon() bool {
73
-	return isLocalDaemon
73
+	return testEnv.LocalDaemon()
74 74
 }
75 75
 
76 76
 func UnixCli() bool {
... ...
@@ -171,21 +171,21 @@ func UserNamespaceInKernel() bool {
171 171
 }
172 172
 
173 173
 func IsPausable() bool {
174
-	if daemonPlatform == "windows" {
175
-		return isolation == "hyperv"
174
+	if testEnv.DaemonPlatform() == "windows" {
175
+		return testEnv.Isolation() == "hyperv"
176 176
 	}
177 177
 	return true
178 178
 }
179 179
 
180 180
 func NotPausable() bool {
181
-	if daemonPlatform == "windows" {
182
-		return isolation == "process"
181
+	if testEnv.DaemonPlatform() == "windows" {
182
+		return testEnv.Isolation() == "process"
183 183
 	}
184 184
 	return false
185 185
 }
186 186
 
187 187
 func IsolationIs(expectedIsolation string) bool {
188
-	return daemonPlatform == "windows" && string(isolation) == expectedIsolation
188
+	return testEnv.DaemonPlatform() == "windows" && string(testEnv.Isolation()) == expectedIsolation
189 189
 }
190 190
 
191 191
 func IsolationIsHyperv() bool {
... ...
@@ -101,7 +101,7 @@ func overlay2Supported() bool {
101 101
 		return false
102 102
 	}
103 103
 
104
-	daemonV, err := kernel.ParseRelease(daemonKernelVersion)
104
+	daemonV, err := kernel.ParseRelease(testEnv.DaemonKernelVersion())
105 105
 	if err != nil {
106 106
 		return false
107 107
 	}
... ...
@@ -4,7 +4,7 @@ package main
4 4
 // the command is for a sleeping container based on the daemon platform.
5 5
 // The Windows busybox image does not have a `top` command.
6 6
 func sleepCommandForDaemonPlatform() []string {
7
-	if daemonPlatform == "windows" {
7
+	if testEnv.DaemonPlatform() == "windows" {
8 8
 		return []string{"sleep", "240"}
9 9
 	}
10 10
 	return []string{"top"}
... ...
@@ -1,12 +1,13 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"github.com/docker/docker/pkg/testutil/cmd"
5 4
 	"os/exec"
5
+
6
+	"github.com/docker/docker/pkg/testutil/cmd"
6 7
 )
7 8
 
8 9
 func getPrefixAndSlashFromDaemonPlatform() (prefix, slash string) {
9
-	if daemonPlatform == "windows" {
10
+	if testEnv.DaemonPlatform() == "windows" {
10 11
 		return "c:", `\`
11 12
 	}
12 13
 	return "", "/"