Sfoglia il codice sorgente

Test infrastructure for cross platform

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 9 anni fa
parent
commit
cd18e7bb73

+ 35 - 0
integration-cli/docker_cli_version_test.go

@@ -26,3 +26,38 @@ func (s *DockerSuite) TestVersionEnsureSucceeds(c *check.C) {
 		}
 	}
 }
+
+// ensure the Windows daemon return the correct platform string
+func (s *DockerSuite) TestVersionPlatform_w(c *check.C) {
+	testRequires(c, DaemonIsWindows)
+	testVersionPlatform(c, "windows/amd64")
+}
+
+// ensure the Linux daemon return the correct platform string
+func (s *DockerSuite) TestVersionPlatform_l(c *check.C) {
+	testRequires(c, DaemonIsLinux)
+	testVersionPlatform(c, "linux/amd64")
+}
+
+func testVersionPlatform(c *check.C, platform string) {
+	out, _ := dockerCmd(c, "version")
+	expected := "OS/Arch:      " + platform
+
+	split := strings.Split(out, "\n")
+	if len(split) < 14 { // To avoid invalid indexing in loop below
+		c.Errorf("got %d lines from version", len(split))
+	}
+
+	// Verify the second 'OS/Arch' matches the platform. Experimental has
+	// more lines of output than 'regular'
+	bFound := false
+	for i := 14; i < len(split); i++ {
+		if strings.Contains(split[i], expected) {
+			bFound = true
+			break
+		}
+	}
+	if !bFound {
+		c.Errorf("Could not find server '%s' in '%s'", expected, out)
+	}
+}

+ 8 - 0
integration-cli/requirements.go

@@ -24,6 +24,14 @@ type testRequirement struct {
 var (
 	daemonExecDriver string
 
+	DaemonIsWindows = testRequirement{
+		func() bool { return daemonPlatform == "windows" },
+		"Test requires a Windows daemon",
+	}
+	DaemonIsLinux = testRequirement{
+		func() bool { return daemonPlatform == "linux" },
+		"Test requires a Linux daemon",
+	}
 	SameHostDaemon = testRequirement{
 		func() bool { return isLocalDaemon },
 		"Test requires docker daemon to runs on the same machine as CLI",