Browse code

Fix --net none test closes #16356

Signed-off-by: Lei Jitang <leijitang@huawei.com>

Lei Jitang authored on 2015/09/19 09:49:36
Showing 1 changed files
... ...
@@ -3,6 +3,7 @@
3 3
 package main
4 4
 
5 5
 import (
6
+	"bytes"
6 7
 	"encoding/json"
7 8
 	"fmt"
8 9
 	"io/ioutil"
... ...
@@ -1492,11 +1493,16 @@ func (s *DockerDaemonSuite) TestRunContainerWithBridgeNone(c *check.C) {
1492 1492
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
1493 1493
 	c.Assert(strings.Contains(out, "eth0"), check.Equals, false,
1494 1494
 		check.Commentf("There shouldn't be eth0 in container in bridge mode when bridge network is disabled: %s", out))
1495
-
1495
+	cmd := exec.Command("ip", "l")
1496
+	stdout := bytes.NewBuffer(nil)
1497
+	cmd.Stdout = stdout
1498
+	if err := cmd.Run(); err != nil {
1499
+		c.Fatal("Failed to get host network interface")
1500
+	}
1496 1501
 	out, err = s.d.Cmd("run", "--rm", "--net=host", "busybox", "ip", "l")
1497 1502
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
1498
-	c.Assert(strings.Contains(out, "eth0"), check.Equals, true,
1499
-		check.Commentf("There should be eth0 in container when --net=host when bridge network is disabled: %s", out))
1503
+	c.Assert(out, check.Equals, fmt.Sprintf("%s", stdout),
1504
+		check.Commentf("The network interfaces in container should be the same with host when --net=host when bridge network is disabled: %s", out))
1500 1505
 }
1501 1506
 
1502 1507
 func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) {
... ...
@@ -1618,7 +1624,9 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedSyslogAddress(c *check.C) {
1618 1618
 }
1619 1619
 
1620 1620
 func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *check.C) {
1621
-	c.Assert(s.d.Start("--log-driver=json-file", "--log-opt=max-size=1k"), check.IsNil)
1621
+	if err := s.d.StartWithBusybox("--log-driver=json-file", "--log-opt=max-size=1k"); err != nil {
1622
+		c.Fatal(err)
1623
+	}
1622 1624
 	out, err := s.d.Cmd("run", "-d", "--name=logtest", "busybox", "top")
1623 1625
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s, err: %v", out, err))
1624 1626
 	out, err = s.d.Cmd("inspect", "-f", "{{ .HostConfig.LogConfig.Config }}", "logtest")