Use prefix naming for docker_cli_run_test.go

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
Alexandr Morozov 2014-09-19 12:21:25 +04:00
parent e91de29e08
commit aa536b27a7
1 changed files with 80 additions and 80 deletions

View File

@ -22,7 +22,7 @@ import (
)
// "test123" should be printed by docker run
func TestDockerRunEchoStdout(t *testing.T) {
func TestRunEchoStdout(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "busybox", "echo", "test123")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -39,7 +39,7 @@ func TestDockerRunEchoStdout(t *testing.T) {
}
// "test" should be printed
func TestDockerRunEchoStdoutWithMemoryLimit(t *testing.T) {
func TestRunEchoStdoutWithMemoryLimit(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-m", "2786432", "busybox", "echo", "test")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -59,7 +59,7 @@ func TestDockerRunEchoStdoutWithMemoryLimit(t *testing.T) {
}
// "test" should be printed
func TestDockerRunEchoStdoutWitCPULimit(t *testing.T) {
func TestRunEchoStdoutWitCPULimit(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-c", "1000", "busybox", "echo", "test")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -76,7 +76,7 @@ func TestDockerRunEchoStdoutWitCPULimit(t *testing.T) {
}
// "test" should be printed
func TestDockerRunEchoStdoutWithCPUAndMemoryLimit(t *testing.T) {
func TestRunEchoStdoutWithCPUAndMemoryLimit(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-c", "1000", "-m", "2786432", "busybox", "echo", "test")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -93,7 +93,7 @@ func TestDockerRunEchoStdoutWithCPUAndMemoryLimit(t *testing.T) {
}
// "test" should be printed
func TestDockerRunEchoNamedContainer(t *testing.T) {
func TestRunEchoNamedContainer(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "--name", "testfoonamedcontainer", "busybox", "echo", "test")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -114,7 +114,7 @@ func TestDockerRunEchoNamedContainer(t *testing.T) {
}
// docker run should not leak file descriptors
func TestDockerRunLeakyFileDescriptors(t *testing.T) {
func TestRunLeakyFileDescriptors(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "busybox", "ls", "-C", "/proc/self/fd")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -133,7 +133,7 @@ func TestDockerRunLeakyFileDescriptors(t *testing.T) {
// it should be possible to ping Google DNS resolver
// this will fail when Internet access is unavailable
func TestDockerRunPingGoogle(t *testing.T) {
func TestRunPingGoogle(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "busybox", "ping", "-c", "1", "8.8.8.8")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -149,7 +149,7 @@ func TestDockerRunPingGoogle(t *testing.T) {
// the exit code should be 0
// some versions of lxc might make this test fail
func TestDockerRunExitCodeZero(t *testing.T) {
func TestRunExitCodeZero(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "busybox", "true")
exitCode, err := runCommand(runCmd)
errorOut(err, t, fmt.Sprintf("%s", err))
@ -165,7 +165,7 @@ func TestDockerRunExitCodeZero(t *testing.T) {
// the exit code should be 1
// some versions of lxc might make this test fail
func TestDockerRunExitCodeOne(t *testing.T) {
func TestRunExitCodeOne(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "busybox", "false")
exitCode, err := runCommand(runCmd)
if err != nil && !strings.Contains("exit status 1", fmt.Sprintf("%s", err)) {
@ -219,7 +219,7 @@ func TestRunStdinPipe(t *testing.T) {
}
// the container's ID should be printed when starting a container in detached mode
func TestDockerRunDetachedContainerIDPrinting(t *testing.T) {
func TestRunDetachedContainerIDPrinting(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -251,7 +251,7 @@ func TestDockerRunDetachedContainerIDPrinting(t *testing.T) {
}
// the working directory should be set correctly
func TestDockerRunWorkingDirectory(t *testing.T) {
func TestRunWorkingDirectory(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-w", "/root", "busybox", "pwd")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
if err != nil {
@ -281,7 +281,7 @@ func TestDockerRunWorkingDirectory(t *testing.T) {
}
// pinging Google's DNS resolver should fail when we disable the networking
func TestDockerRunWithoutNetworking(t *testing.T) {
func TestRunWithoutNetworking(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "--net=none", "busybox", "ping", "-c", "1", "8.8.8.8")
out, _, exitCode, err := runCommandWithStdoutStderr(runCmd)
if err != nil && exitCode != 1 {
@ -307,7 +307,7 @@ func TestDockerRunWithoutNetworking(t *testing.T) {
}
// Regression test for #4741
func TestDockerRunWithVolumesAsFiles(t *testing.T) {
func TestRunWithVolumesAsFiles(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "--name", "test-data", "--volume", "/etc/hosts:/target-file", "busybox", "true")
out, stderr, exitCode, err := runCommandWithStdoutStderr(runCmd)
if err != nil && exitCode != 0 {
@ -325,7 +325,7 @@ func TestDockerRunWithVolumesAsFiles(t *testing.T) {
}
// Regression test for #4979
func TestDockerRunWithVolumesFromExited(t *testing.T) {
func TestRunWithVolumesFromExited(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "--name", "test-data", "--volume", "/some/dir", "busybox", "touch", "/some/dir/file")
out, stderr, exitCode, err := runCommandWithStdoutStderr(runCmd)
if err != nil && exitCode != 0 {
@ -343,7 +343,7 @@ func TestDockerRunWithVolumesFromExited(t *testing.T) {
}
// Regression test for #4830
func TestDockerRunWithRelativePath(t *testing.T) {
func TestRunWithRelativePath(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-v", "tmp:/other-tmp", "busybox", "true")
if _, _, _, err := runCommandWithStdoutStderr(runCmd); err == nil {
t.Fatalf("relative path should result in an error")
@ -354,7 +354,7 @@ func TestDockerRunWithRelativePath(t *testing.T) {
logDone("run - volume with relative path")
}
func TestVolumesMountedAsReadonly(t *testing.T) {
func TestRunVolumesMountedAsReadonly(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-v", "/test:/test:ro", "busybox", "touch", "/test/somefile")
if code, err := runCommand(cmd); err == nil || code == 0 {
t.Fatalf("run should fail because volume is ro: exit code %d", code)
@ -365,7 +365,7 @@ func TestVolumesMountedAsReadonly(t *testing.T) {
logDone("run - volumes as readonly mount")
}
func TestVolumesFromInReadonlyMode(t *testing.T) {
func TestRunVolumesFromInReadonlyMode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--name", "parent", "-v", "/test", "busybox", "true")
if _, err := runCommand(cmd); err != nil {
t.Fatal(err)
@ -382,7 +382,7 @@ func TestVolumesFromInReadonlyMode(t *testing.T) {
}
// Regression test for #1201
func TestVolumesFromInReadWriteMode(t *testing.T) {
func TestRunVolumesFromInReadWriteMode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--name", "parent", "-v", "/test", "busybox", "true")
if _, err := runCommand(cmd); err != nil {
t.Fatal(err)
@ -398,7 +398,7 @@ func TestVolumesFromInReadWriteMode(t *testing.T) {
logDone("run - volumes from as read write mount")
}
func TestVolumesFromInheritsReadOnly(t *testing.T) {
func TestRunVolumesFromInheritsReadOnly(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--name", "parent", "-v", "/test:/test:ro", "busybox", "true")
if _, err := runCommand(cmd); err != nil {
t.Fatal(err)
@ -416,7 +416,7 @@ func TestVolumesFromInheritsReadOnly(t *testing.T) {
}
// Test for #1351
func TestApplyVolumesFromBeforeVolumes(t *testing.T) {
func TestRunApplyVolumesFromBeforeVolumes(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--name", "parent", "-v", "/test", "busybox", "touch", "/test/foo")
if _, err := runCommand(cmd); err != nil {
t.Fatal(err)
@ -432,7 +432,7 @@ func TestApplyVolumesFromBeforeVolumes(t *testing.T) {
logDone("run - volumes from mounted first")
}
func TestMultipleVolumesFrom(t *testing.T) {
func TestRunMultipleVolumesFrom(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--name", "parent1", "-v", "/test", "busybox", "touch", "/test/foo")
if _, err := runCommand(cmd); err != nil {
t.Fatal(err)
@ -455,7 +455,7 @@ func TestMultipleVolumesFrom(t *testing.T) {
}
// this tests verifies the ID format for the container
func TestVerifyContainerID(t *testing.T) {
func TestRunVerifyContainerID(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
out, exit, err := runCommandWithOutput(cmd)
if err != nil {
@ -478,7 +478,7 @@ func TestVerifyContainerID(t *testing.T) {
}
// Test that creating a container with a volume doesn't crash. Regression test for #995.
func TestCreateVolume(t *testing.T) {
func TestRunCreateVolume(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-v", "/var/lib/data", "busybox", "true")
if _, err := runCommand(cmd); err != nil {
t.Fatal(err)
@ -491,7 +491,7 @@ func TestCreateVolume(t *testing.T) {
// Test that creating a volume with a symlink in its path works correctly. Test for #5152.
// Note that this bug happens only with symlinks with a target that starts with '/'.
func TestCreateVolumeWithSymlink(t *testing.T) {
func TestRunCreateVolumeWithSymlink(t *testing.T) {
buildCmd := exec.Command(dockerBinary, "build", "-t", "docker-test-createvolumewithsymlink", "-")
buildCmd.Stdin = strings.NewReader(`FROM busybox
RUN mkdir /foo && ln -s /foo /bar`)
@ -533,7 +533,7 @@ func TestCreateVolumeWithSymlink(t *testing.T) {
}
// Tests that a volume path that has a symlink exists in a container mounting it with `--volumes-from`.
func TestVolumesFromSymlinkPath(t *testing.T) {
func TestRunVolumesFromSymlinkPath(t *testing.T) {
buildCmd := exec.Command(dockerBinary, "build", "-t", "docker-test-volumesfromsymlinkpath", "-")
buildCmd.Stdin = strings.NewReader(`FROM busybox
RUN mkdir /baz && ln -s /baz /foo
@ -562,7 +562,7 @@ func TestVolumesFromSymlinkPath(t *testing.T) {
logDone("run - volumes-from symlink path")
}
func TestExitCode(t *testing.T) {
func TestRunExitCode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "/bin/sh", "-c", "exit 72")
exit, err := runCommand(cmd)
@ -578,7 +578,7 @@ func TestExitCode(t *testing.T) {
logDone("run - correct exit code")
}
func TestUserDefaultsToRoot(t *testing.T) {
func TestRunUserDefaultsToRoot(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "id")
out, _, err := runCommandWithOutput(cmd)
@ -593,7 +593,7 @@ func TestUserDefaultsToRoot(t *testing.T) {
logDone("run - default user")
}
func TestUserByName(t *testing.T) {
func TestRunUserByName(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-u", "root", "busybox", "id")
out, _, err := runCommandWithOutput(cmd)
@ -608,7 +608,7 @@ func TestUserByName(t *testing.T) {
logDone("run - user by name")
}
func TestUserByID(t *testing.T) {
func TestRunUserByID(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-u", "1", "busybox", "id")
out, _, err := runCommandWithOutput(cmd)
@ -623,7 +623,7 @@ func TestUserByID(t *testing.T) {
logDone("run - user by id")
}
func TestUserByIDBig(t *testing.T) {
func TestRunUserByIDBig(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-u", "2147483648", "busybox", "id")
out, _, err := runCommandWithOutput(cmd)
@ -638,7 +638,7 @@ func TestUserByIDBig(t *testing.T) {
logDone("run - user by id, id too big")
}
func TestUserByIDNegative(t *testing.T) {
func TestRunUserByIDNegative(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-u", "-1", "busybox", "id")
out, _, err := runCommandWithOutput(cmd)
@ -653,7 +653,7 @@ func TestUserByIDNegative(t *testing.T) {
logDone("run - user by id, id negative")
}
func TestUserByIDZero(t *testing.T) {
func TestRunUserByIDZero(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-u", "0", "busybox", "id")
out, _, err := runCommandWithOutput(cmd)
@ -668,7 +668,7 @@ func TestUserByIDZero(t *testing.T) {
logDone("run - user by id, zero uid")
}
func TestUserNotFound(t *testing.T) {
func TestRunUserNotFound(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-u", "notme", "busybox", "id")
_, err := runCommand(cmd)
@ -701,7 +701,7 @@ func TestRunTwoConcurrentContainers(t *testing.T) {
logDone("run - two concurrent containers")
}
func TestEnvironment(t *testing.T) {
func TestRunEnvironment(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-h", "testing", "-e=FALSE=true", "-e=TRUE", "-e=TRICKY", "-e=HOME=", "busybox", "env")
cmd.Env = append(os.Environ(),
"TRUE=false",
@ -744,7 +744,7 @@ func TestEnvironment(t *testing.T) {
logDone("run - verify environment")
}
func TestContainerNetwork(t *testing.T) {
func TestRunContainerNetwork(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "ping", "-c", "1", "127.0.0.1")
if _, err := runCommand(cmd); err != nil {
t.Fatal(err)
@ -756,7 +756,7 @@ func TestContainerNetwork(t *testing.T) {
}
// Issue #4681
func TestLoopbackWhenNetworkDisabled(t *testing.T) {
func TestRunLoopbackWhenNetworkDisabled(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--net=none", "busybox", "ping", "-c", "1", "127.0.0.1")
if _, err := runCommand(cmd); err != nil {
t.Fatal(err)
@ -767,7 +767,7 @@ func TestLoopbackWhenNetworkDisabled(t *testing.T) {
logDone("run - test container loopback when networking disabled")
}
func TestNetHostNotAllowedWithLinks(t *testing.T) {
func TestRunNetHostNotAllowedWithLinks(t *testing.T) {
_, _, err := cmd(t, "run", "--name", "linked", "busybox", "true")
cmd := exec.Command(dockerBinary, "run", "--net=host", "--link", "linked:linked", "busybox", "true")
@ -781,7 +781,7 @@ func TestNetHostNotAllowedWithLinks(t *testing.T) {
logDone("run - don't allow --net=host to be used with links")
}
func TestLoopbackOnlyExistsWhenNetworkingDisabled(t *testing.T) {
func TestRunLoopbackOnlyExistsWhenNetworkingDisabled(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--net=none", "busybox", "ip", "-o", "-4", "a", "show", "up")
out, _, err := runCommandWithOutput(cmd)
if err != nil {
@ -812,7 +812,7 @@ func TestLoopbackOnlyExistsWhenNetworkingDisabled(t *testing.T) {
logDone("run - test loopback only exists when networking disabled")
}
func TestPrivilegedCanMknod(t *testing.T) {
func TestRunPrivilegedCanMknod(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--privileged", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err != nil {
@ -827,7 +827,7 @@ func TestPrivilegedCanMknod(t *testing.T) {
logDone("run - test privileged can mknod")
}
func TestUnPrivilegedCanMknod(t *testing.T) {
func TestRunUnPrivilegedCanMknod(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err != nil {
@ -842,7 +842,7 @@ func TestUnPrivilegedCanMknod(t *testing.T) {
logDone("run - test un-privileged can mknod")
}
func TestCapDropInvalid(t *testing.T) {
func TestRunCapDropInvalid(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-drop=CHPASS", "busybox", "ls")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
@ -852,7 +852,7 @@ func TestCapDropInvalid(t *testing.T) {
logDone("run - test --cap-drop=CHPASS invalid")
}
func TestCapDropCannotMknod(t *testing.T) {
func TestRunCapDropCannotMknod(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-drop=MKNOD", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
@ -867,7 +867,7 @@ func TestCapDropCannotMknod(t *testing.T) {
logDone("run - test --cap-drop=MKNOD cannot mknod")
}
func TestCapDropCannotMknodLowerCase(t *testing.T) {
func TestRunCapDropCannotMknodLowerCase(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-drop=mknod", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
@ -882,7 +882,7 @@ func TestCapDropCannotMknodLowerCase(t *testing.T) {
logDone("run - test --cap-drop=mknod cannot mknod lowercase")
}
func TestCapDropALLCannotMknod(t *testing.T) {
func TestRunCapDropALLCannotMknod(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-drop=ALL", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
@ -897,7 +897,7 @@ func TestCapDropALLCannotMknod(t *testing.T) {
logDone("run - test --cap-drop=ALL cannot mknod")
}
func TestCapDropALLAddMknodCannotMknod(t *testing.T) {
func TestRunCapDropALLAddMknodCannotMknod(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-drop=ALL", "--cap-add=MKNOD", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err != nil {
@ -912,7 +912,7 @@ func TestCapDropALLAddMknodCannotMknod(t *testing.T) {
logDone("run - test --cap-drop=ALL --cap-add=MKNOD can mknod")
}
func TestCapAddInvalid(t *testing.T) {
func TestRunCapAddInvalid(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-add=CHPASS", "busybox", "ls")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
@ -922,7 +922,7 @@ func TestCapAddInvalid(t *testing.T) {
logDone("run - test --cap-add=CHPASS invalid")
}
func TestCapAddCanDownInterface(t *testing.T) {
func TestRunCapAddCanDownInterface(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-add=NET_ADMIN", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err != nil {
@ -937,7 +937,7 @@ func TestCapAddCanDownInterface(t *testing.T) {
logDone("run - test --cap-add=NET_ADMIN can set eth0 down")
}
func TestCapAddALLCanDownInterface(t *testing.T) {
func TestRunCapAddALLCanDownInterface(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-add=ALL", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err != nil {
@ -952,7 +952,7 @@ func TestCapAddALLCanDownInterface(t *testing.T) {
logDone("run - test --cap-add=ALL can set eth0 down")
}
func TestCapAddALLDropNetAdminCanDownInterface(t *testing.T) {
func TestRunCapAddALLDropNetAdminCanDownInterface(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--cap-add=ALL", "--cap-drop=NET_ADMIN", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
@ -967,7 +967,7 @@ func TestCapAddALLDropNetAdminCanDownInterface(t *testing.T) {
logDone("run - test --cap-add=ALL --cap-drop=NET_ADMIN cannot set eth0 down")
}
func TestPrivilegedCanMount(t *testing.T) {
func TestRunPrivilegedCanMount(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--privileged", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok")
out, _, err := runCommandWithOutput(cmd)
@ -983,7 +983,7 @@ func TestPrivilegedCanMount(t *testing.T) {
logDone("run - test privileged can mount")
}
func TestUnPrivilegedCannotMount(t *testing.T) {
func TestRunUnPrivilegedCannotMount(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok")
out, _, err := runCommandWithOutput(cmd)
@ -999,7 +999,7 @@ func TestUnPrivilegedCannotMount(t *testing.T) {
logDone("run - test un-privileged cannot mount")
}
func TestSysNotWritableInNonPrivilegedContainers(t *testing.T) {
func TestRunSysNotWritableInNonPrivilegedContainers(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "touch", "/sys/kernel/profiling")
if code, err := runCommand(cmd); err == nil || code == 0 {
t.Fatal("sys should not be writable in a non privileged container")
@ -1010,7 +1010,7 @@ func TestSysNotWritableInNonPrivilegedContainers(t *testing.T) {
logDone("run - sys not writable in non privileged container")
}
func TestSysWritableInPrivilegedContainers(t *testing.T) {
func TestRunSysWritableInPrivilegedContainers(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--privileged", "busybox", "touch", "/sys/kernel/profiling")
if code, err := runCommand(cmd); err != nil || code != 0 {
t.Fatalf("sys should be writable in privileged container")
@ -1021,7 +1021,7 @@ func TestSysWritableInPrivilegedContainers(t *testing.T) {
logDone("run - sys writable in privileged container")
}
func TestProcNotWritableInNonPrivilegedContainers(t *testing.T) {
func TestRunProcNotWritableInNonPrivilegedContainers(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "touch", "/proc/sysrq-trigger")
if code, err := runCommand(cmd); err == nil || code == 0 {
t.Fatal("proc should not be writable in a non privileged container")
@ -1032,7 +1032,7 @@ func TestProcNotWritableInNonPrivilegedContainers(t *testing.T) {
logDone("run - proc not writable in non privileged container")
}
func TestProcWritableInPrivilegedContainers(t *testing.T) {
func TestRunProcWritableInPrivilegedContainers(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--privileged", "busybox", "touch", "/proc/sysrq-trigger")
if code, err := runCommand(cmd); err != nil || code != 0 {
t.Fatalf("proc should be writable in privileged container")
@ -1054,7 +1054,7 @@ func TestRunWithCpuset(t *testing.T) {
logDone("run - cpuset 0")
}
func TestDeviceNumbers(t *testing.T) {
func TestRunDeviceNumbers(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "sh", "-c", "ls -l /dev/null")
out, _, err := runCommandWithOutput(cmd)
@ -1075,7 +1075,7 @@ func TestDeviceNumbers(t *testing.T) {
logDone("run - test device numbers")
}
func TestThatCharacterDevicesActLikeCharacterDevices(t *testing.T) {
func TestRunThatCharacterDevicesActLikeCharacterDevices(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "sh", "-c", "dd if=/dev/zero of=/zero bs=1k count=5 2> /dev/null ; du -h /zero")
out, _, err := runCommandWithOutput(cmd)
@ -1103,7 +1103,7 @@ func TestRunUnprivilegedWithChroot(t *testing.T) {
logDone("run - unprivileged with chroot")
}
func TestAddingOptionalDevices(t *testing.T) {
func TestRunAddingOptionalDevices(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--device", "/dev/zero:/dev/nulo", "busybox", "sh", "-c", "ls /dev/nulo")
out, _, err := runCommandWithOutput(cmd)
@ -1119,7 +1119,7 @@ func TestAddingOptionalDevices(t *testing.T) {
logDone("run - test --device argument")
}
func TestModeHostname(t *testing.T) {
func TestRunModeHostname(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname")
out, _, err := runCommandWithOutput(cmd)
@ -1150,7 +1150,7 @@ func TestModeHostname(t *testing.T) {
logDone("run - hostname and several network modes")
}
func TestRootWorkdir(t *testing.T) {
func TestRunRootWorkdir(t *testing.T) {
s, _, err := cmd(t, "run", "--workdir", "/", "busybox", "pwd")
if err != nil {
t.Fatal(s, err)
@ -1164,7 +1164,7 @@ func TestRootWorkdir(t *testing.T) {
logDone("run - workdir /")
}
func TestAllowBindMountingRoot(t *testing.T) {
func TestRunAllowBindMountingRoot(t *testing.T) {
s, _, err := cmd(t, "run", "-v", "/:/host", "busybox", "ls", "/host")
if err != nil {
t.Fatal(s, err)
@ -1175,7 +1175,7 @@ func TestAllowBindMountingRoot(t *testing.T) {
logDone("run - bind mount / as volume")
}
func TestDisallowBindMountingRootToRoot(t *testing.T) {
func TestRunDisallowBindMountingRootToRoot(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-v", "/:/", "busybox", "ls", "/host")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
@ -1188,7 +1188,7 @@ func TestDisallowBindMountingRootToRoot(t *testing.T) {
}
// Test recursive bind mount works by default
func TestDockerRunWithVolumesIsRecursive(t *testing.T) {
func TestRunWithVolumesIsRecursive(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "docker_recursive_mount_test")
if err != nil {
t.Fatal(err)
@ -1225,7 +1225,7 @@ func TestDockerRunWithVolumesIsRecursive(t *testing.T) {
logDone("run - volumes are bind mounted recursively")
}
func TestDnsDefaultOptions(t *testing.T) {
func TestRunDnsDefaultOptions(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "busybox", "cat", "/etc/resolv.conf")
actual, _, err := runCommandWithOutput(cmd)
@ -1247,7 +1247,7 @@ func TestDnsDefaultOptions(t *testing.T) {
logDone("run - dns default options")
}
func TestDnsOptions(t *testing.T) {
func TestRunDnsOptions(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "--dns=127.0.0.1", "--dns-search=mydomain", "busybox", "cat", "/etc/resolv.conf")
out, _, err := runCommandWithOutput(cmd)
@ -1275,7 +1275,7 @@ func TestDnsOptions(t *testing.T) {
logDone("run - dns options")
}
func TestDnsOptionsBasedOnHostResolvConf(t *testing.T) {
func TestRunDnsOptionsBasedOnHostResolvConf(t *testing.T) {
resolvConf, err := ioutil.ReadFile("/etc/resolv.conf")
if os.IsNotExist(err) {
t.Fatalf("/etc/resolv.conf does not exist")
@ -1349,7 +1349,7 @@ func TestRunAddHost(t *testing.T) {
}
// Regression test for #6983
func TestAttachStdErrOnlyTTYMode(t *testing.T) {
func TestRunAttachStdErrOnlyTTYMode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-t", "-a", "stderr", "busybox", "true")
exitCode, err := runCommand(cmd)
@ -1365,7 +1365,7 @@ func TestAttachStdErrOnlyTTYMode(t *testing.T) {
}
// Regression test for #6983
func TestAttachStdOutOnlyTTYMode(t *testing.T) {
func TestRunAttachStdOutOnlyTTYMode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-t", "-a", "stdout", "busybox", "true")
exitCode, err := runCommand(cmd)
@ -1381,7 +1381,7 @@ func TestAttachStdOutOnlyTTYMode(t *testing.T) {
}
// Regression test for #6983
func TestAttachStdOutAndErrTTYMode(t *testing.T) {
func TestRunAttachStdOutAndErrTTYMode(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-t", "-a", "stdout", "-a", "stderr", "busybox", "true")
exitCode, err := runCommand(cmd)
@ -1396,7 +1396,7 @@ func TestAttachStdOutAndErrTTYMode(t *testing.T) {
logDone("run - Attach stderr and stdout with -t")
}
func TestState(t *testing.T) {
func TestRunState(t *testing.T) {
defer deleteAllContainers()
cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
@ -1463,7 +1463,7 @@ func TestState(t *testing.T) {
}
// Test for #1737
func TestCopyVolumeUidGid(t *testing.T) {
func TestRunCopyVolumeUidGid(t *testing.T) {
name := "testrunvolumesuidgid"
defer deleteImages(name)
defer deleteAllContainers()
@ -1492,7 +1492,7 @@ func TestCopyVolumeUidGid(t *testing.T) {
}
// Test for #1582
func TestCopyVolumeContent(t *testing.T) {
func TestRunCopyVolumeContent(t *testing.T) {
name := "testruncopyvolumecontent"
defer deleteImages(name)
defer deleteAllContainers()
@ -1609,7 +1609,7 @@ func TestRunExitOnStdinClose(t *testing.T) {
}
// Test for #2267
func TestWriteHostsFileAndNotCommit(t *testing.T) {
func TestRunWriteHostsFileAndNotCommit(t *testing.T) {
name := "writehosts"
cmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "sh", "-c", "echo test2267 >> /etc/hosts && cat /etc/hosts")
out, _, err := runCommandWithOutput(cmd)
@ -1636,7 +1636,7 @@ func TestWriteHostsFileAndNotCommit(t *testing.T) {
}
// Test for #2267
func TestWriteHostnameFileAndNotCommit(t *testing.T) {
func TestRunWriteHostnameFileAndNotCommit(t *testing.T) {
name := "writehostname"
cmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "sh", "-c", "echo test2267 >> /etc/hostname && cat /etc/hostname")
out, _, err := runCommandWithOutput(cmd)
@ -1663,7 +1663,7 @@ func TestWriteHostnameFileAndNotCommit(t *testing.T) {
}
// Test for #2267
func TestWriteResolvFileAndNotCommit(t *testing.T) {
func TestRunWriteResolvFileAndNotCommit(t *testing.T) {
name := "writeresolv"
cmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "sh", "-c", "echo test2267 >> /etc/resolv.conf && cat /etc/resolv.conf")
out, _, err := runCommandWithOutput(cmd)
@ -1703,7 +1703,7 @@ func TestRunWithBadDevice(t *testing.T) {
logDone("run - error with bad device")
}
func TestEntrypoint(t *testing.T) {
func TestRunEntrypoint(t *testing.T) {
name := "entrypoint"
cmd := exec.Command(dockerBinary, "run", "--name", name, "--entrypoint", "/bin/echo", "busybox", "-n", "foobar")
out, _, err := runCommandWithOutput(cmd)
@ -1717,7 +1717,7 @@ func TestEntrypoint(t *testing.T) {
logDone("run - entrypoint")
}
func TestBindMounts(t *testing.T) {
func TestRunBindMounts(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "docker-test-container")
if err != nil {
t.Fatal(err)
@ -1766,7 +1766,7 @@ func TestBindMounts(t *testing.T) {
logDone("run - bind mounts")
}
func TestMutableNetworkFiles(t *testing.T) {
func TestRunMutableNetworkFiles(t *testing.T) {
defer deleteAllContainers()
for _, fn := range []string{"resolv.conf", "hosts"} {
@ -1838,7 +1838,7 @@ func TestMutableNetworkFiles(t *testing.T) {
}
}
func TestHostsLinkedContainerUpdate(t *testing.T) {
func TestRunHostsLinkedContainerUpdate(t *testing.T) {
deleteAllContainers()
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "-d", "--name", "c1", "busybox", "sh", "-c", "while true; do sleep 1; done"))
if err != nil {
@ -2013,7 +2013,7 @@ func TestRunPortInUse(t *testing.T) {
}
// Regression test for #7792
func TestMountOrdering(t *testing.T) {
func TestRunMountOrdering(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "docker_nested_mount_test")
if err != nil {
t.Fatal(err)