From 13764748a854d77b13764bd083af720444774617 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 12 Jun 2014 19:11:51 +0000 Subject: [PATCH] add test Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) Upstream-commit: 9494643bf1fcd38974266555e59e1b2d2573c418 Component: engine --- .../integration-cli/docker_cli_run_test.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/components/engine/integration-cli/docker_cli_run_test.go b/components/engine/integration-cli/docker_cli_run_test.go index 545ad371ee..d8e04de8c2 100644 --- a/components/engine/integration-cli/docker_cli_run_test.go +++ b/components/engine/integration-cli/docker_cli_run_test.go @@ -885,3 +885,34 @@ func TestRunUnprivilegedWithChroot(t *testing.T) { logDone("run - unprivileged with chroot") } + +func TestModeHostname(t *testing.T) { + cmd := exec.Command(dockerBinary, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname") + + out, _, err := runCommandWithOutput(cmd) + if err != nil { + t.Fatal(err, out) + } + + if actual := strings.Trim(out, "\r\n"); actual != "testhostname" { + t.Fatalf("expected 'testhostname', but says: '%s'", actual) + } + + cmd = exec.Command(dockerBinary, "run", "--net=host", "busybox", "cat", "/etc/hostname") + + out, _, err = runCommandWithOutput(cmd) + if err != nil { + t.Fatal(err, out) + } + hostname, err := os.Hostname() + if err != nil { + t.Fatal(err) + } + if actual := strings.Trim(out, "\r\n"); actual != hostname { + t.Fatalf("expected '%s', but says: '%s'", hostname, actual) + } + + deleteAllContainers() + + logDone("run - hostname and several network modes") +}