From 74ee405a27b19f2d91caaf50029cea3b13ddcaf2 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Mon, 29 Dec 2014 12:34:59 -0800 Subject: [PATCH 1/2] Fix done messages and error message for ipc tests Signed-off-by: Alexander Morozov --- integration-cli/docker_cli_run_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 718161d529..d55d8d7f71 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -2520,11 +2520,11 @@ func TestRunModeIpcHost(t *testing.T) { out2 = strings.Trim(out2, "\n") if hostIpc == out2 { - t.Fatalf("IPC should be different without --ipc=host %s != %s\n", hostIpc, out2) + t.Fatalf("IPC should be different without --ipc=host %s == %s\n", hostIpc, out2) } deleteAllContainers() - logDone("run - hostname and several network modes") + logDone("run - ipc host mode") } func TestRunModeIpcContainer(t *testing.T) { @@ -2562,7 +2562,7 @@ func TestRunModeIpcContainer(t *testing.T) { } deleteAllContainers() - logDone("run - hostname and several network modes") + logDone("run - ipc container mode") } func TestContainerNetworkMode(t *testing.T) { From e98c08a88fb5f3eedde158a3647a731c31bd4faa Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Mon, 29 Dec 2014 12:56:07 -0800 Subject: [PATCH 2/2] Rewrite TestRunNetHost to compare namespaces Signed-off-by: Alexander Morozov --- integration-cli/docker_cli_run_test.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index d55d8d7f71..2a75b27d8c 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -2708,18 +2708,32 @@ func TestRunNonLocalMacAddress(t *testing.T) { func TestRunNetHost(t *testing.T) { defer deleteAllContainers() - iplinkHost, err := exec.Command("ip", "link", "list").CombinedOutput() + hostNet, err := os.Readlink("/proc/1/ns/net") if err != nil { t.Fatal(err) } - iplinkCont, err := exec.Command(dockerBinary, "run", "--net=host", "busybox", "ip", "link", "list").CombinedOutput() + cmd := exec.Command(dockerBinary, "run", "--net=host", "busybox", "readlink", "/proc/self/ns/net") + out2, _, err := runCommandWithOutput(cmd) if err != nil { - t.Fatal(err) + t.Fatal(err, out2) } - if !bytes.Equal(iplinkHost, iplinkCont) { - t.Fatalf("Container network:\n%s\nis not equal to host network:\n%s", iplinkCont, iplinkHost) + out2 = strings.Trim(out2, "\n") + if hostNet != out2 { + t.Fatalf("Net namespace different with --net=host %s != %s\n", hostNet, out2) } - logDone("run - host network") + + cmd = exec.Command(dockerBinary, "run", "busybox", "readlink", "/proc/self/ns/net") + out2, _, err = runCommandWithOutput(cmd) + if err != nil { + t.Fatal(err, out2) + } + + out2 = strings.Trim(out2, "\n") + if hostNet == out2 { + t.Fatalf("Net namespace should be different without --net=host %s == %s\n", hostNet, out2) + } + + logDone("run - net host mode") }