Skip to content

Commit

Permalink
Merge pull request moby#21151 from mountkin/optimize-test
Browse files Browse the repository at this point in the history
optimize slow tests
  • Loading branch information
cpuguy83 committed Mar 14, 2016
2 parents fa8417d + 7369ddd commit 01f1651
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
32 changes: 14 additions & 18 deletions integration-cli/docker_cli_run_test.go
Expand Up @@ -2753,9 +2753,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *check.C) {
// Not applicable on Windows which does not support --read-only
testRequires(c, DaemonIsLinux)

for _, f := range []string{"/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname", "/sys/kernel", "/dev/.dont.touch.me"} {
testReadOnlyFile(f, c)
}
testReadOnlyFile(c, "/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname", "/sys/kernel", "/dev/.dont.touch.me")
}

func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {
Expand All @@ -2775,26 +2773,24 @@ func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {
}
}

func testReadOnlyFile(filename string, c *check.C) {
func testReadOnlyFile(c *check.C, filenames ...string) {
// Not applicable on Windows which does not support --read-only
testRequires(c, DaemonIsLinux, NotUserNamespace)
touch := "touch " + strings.Join(filenames, " ")
out, _, err := dockerCmdWithError("run", "--read-only", "--rm", "busybox", "sh", "-c", touch)
c.Assert(err, checker.NotNil)

out, _, err := dockerCmdWithError("run", "--read-only", "--rm", "busybox", "touch", filename)
if err == nil {
c.Fatal("expected container to error on run with read only error")
}
expected := "Read-only file system"
if !strings.Contains(string(out), expected) {
c.Fatalf("expected output from failure to contain %s but contains %s", expected, out)
for _, f := range filenames {
expected := "touch: " + f + ": Read-only file system"
c.Assert(out, checker.Contains, expected)
}

out, _, err = dockerCmdWithError("run", "--read-only", "--privileged", "--rm", "busybox", "touch", filename)
if err == nil {
c.Fatal("expected container to error on run with read only error")
}
expected = "Read-only file system"
if !strings.Contains(string(out), expected) {
c.Fatalf("expected output from failure to contain %s but contains %s", expected, out)
out, _, err = dockerCmdWithError("run", "--read-only", "--privileged", "--rm", "busybox", "sh", "-c", touch)
c.Assert(err, checker.NotNil)

for _, f := range filenames {
expected := "touch: " + f + ": Read-only file system"
c.Assert(out, checker.Contains, expected)
}
}

Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_cli_run_unix_test.go
Expand Up @@ -911,12 +911,12 @@ func (s *DockerSuite) TestRunApparmorProcDirectory(c *check.C) {
testRequires(c, SameHostDaemon, Apparmor)

// running w seccomp unconfined tests the apparmor profile
runCmd := exec.Command(dockerBinary, "run", "--security-opt", "seccomp:unconfined", "debian:jessie", "chmod", "777", "/proc/1/cgroup")
runCmd := exec.Command(dockerBinary, "run", "--security-opt", "seccomp:unconfined", "busybox", "chmod", "777", "/proc/1/cgroup")
if out, _, err := runCommandWithOutput(runCmd); err == nil || !(strings.Contains(out, "Permission denied") || strings.Contains(out, "Operation not permitted")) {
c.Fatalf("expected chmod 777 /proc/1/cgroup to fail, got %s: %v", out, err)
}

runCmd = exec.Command(dockerBinary, "run", "--security-opt", "seccomp:unconfined", "debian:jessie", "chmod", "777", "/proc/1/attr/current")
runCmd = exec.Command(dockerBinary, "run", "--security-opt", "seccomp:unconfined", "busybox", "chmod", "777", "/proc/1/attr/current")
if out, _, err := runCommandWithOutput(runCmd); err == nil || !(strings.Contains(out, "Permission denied") || strings.Contains(out, "Operation not permitted")) {
c.Fatalf("expected chmod 777 /proc/1/attr/current to fail, got %s: %v", out, err)
}
Expand Down

0 comments on commit 01f1651

Please sign in to comment.