Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -26,3 +26,38 @@ func (s *DockerSuite) TestVersionEnsureSucceeds(c *check.C) {
|
| 26 | 26 |
} |
| 27 | 27 |
} |
| 28 | 28 |
} |
| 29 |
+ |
|
| 30 |
+// ensure the Windows daemon return the correct platform string |
|
| 31 |
+func (s *DockerSuite) TestVersionPlatform_w(c *check.C) {
|
|
| 32 |
+ testRequires(c, DaemonIsWindows) |
|
| 33 |
+ testVersionPlatform(c, "windows/amd64") |
|
| 34 |
+} |
|
| 35 |
+ |
|
| 36 |
+// ensure the Linux daemon return the correct platform string |
|
| 37 |
+func (s *DockerSuite) TestVersionPlatform_l(c *check.C) {
|
|
| 38 |
+ testRequires(c, DaemonIsLinux) |
|
| 39 |
+ testVersionPlatform(c, "linux/amd64") |
|
| 40 |
+} |
|
| 41 |
+ |
|
| 42 |
+func testVersionPlatform(c *check.C, platform string) {
|
|
| 43 |
+ out, _ := dockerCmd(c, "version") |
|
| 44 |
+ expected := "OS/Arch: " + platform |
|
| 45 |
+ |
|
| 46 |
+ split := strings.Split(out, "\n") |
|
| 47 |
+ if len(split) < 14 { // To avoid invalid indexing in loop below
|
|
| 48 |
+ c.Errorf("got %d lines from version", len(split))
|
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ // Verify the second 'OS/Arch' matches the platform. Experimental has |
|
| 52 |
+ // more lines of output than 'regular' |
|
| 53 |
+ bFound := false |
|
| 54 |
+ for i := 14; i < len(split); i++ {
|
|
| 55 |
+ if strings.Contains(split[i], expected) {
|
|
| 56 |
+ bFound = true |
|
| 57 |
+ break |
|
| 58 |
+ } |
|
| 59 |
+ } |
|
| 60 |
+ if !bFound {
|
|
| 61 |
+ c.Errorf("Could not find server '%s' in '%s'", expected, out)
|
|
| 62 |
+ } |
|
| 63 |
+} |
| ... | ... |
@@ -24,6 +24,14 @@ type testRequirement struct {
|
| 24 | 24 |
var ( |
| 25 | 25 |
daemonExecDriver string |
| 26 | 26 |
|
| 27 |
+ DaemonIsWindows = testRequirement{
|
|
| 28 |
+ func() bool { return daemonPlatform == "windows" },
|
|
| 29 |
+ "Test requires a Windows daemon", |
|
| 30 |
+ } |
|
| 31 |
+ DaemonIsLinux = testRequirement{
|
|
| 32 |
+ func() bool { return daemonPlatform == "linux" },
|
|
| 33 |
+ "Test requires a Linux daemon", |
|
| 34 |
+ } |
|
| 27 | 35 |
SameHostDaemon = testRequirement{
|
| 28 | 36 |
func() bool { return isLocalDaemon },
|
| 29 | 37 |
"Test requires docker daemon to runs on the same machine as CLI", |