Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Upstream-commit: 9494643bf1fcd38974266555e59e1b2d2573c418
Component: engine
This commit is contained in:
Victor Vieux
2014-06-12 19:11:51 +00:00
parent 455e8c968c
commit 13764748a8
@@ -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")
}