From cd18e7bb739b7681507aca48fec36db9104a5e89 Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 27 Aug 2015 15:08:00 -0700 Subject: [PATCH] Test infrastructure for cross platform Signed-off-by: John Howard --- integration-cli/docker_cli_version_test.go | 35 ++++++++++++++++++++++ integration-cli/requirements.go | 8 +++++ 2 files changed, 43 insertions(+) diff --git a/integration-cli/docker_cli_version_test.go b/integration-cli/docker_cli_version_test.go index f2d8b6514d..1d8fe120b6 100644 --- a/integration-cli/docker_cli_version_test.go +++ b/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) + } +} diff --git a/integration-cli/requirements.go b/integration-cli/requirements.go index ce080d50d5..28b277a1d2 100644 --- a/integration-cli/requirements.go +++ b/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",