github.com/damirazo/docker@v1.9.0/integration-cli/docker_cli_top_test.go (about) 1 package main 2 3 import ( 4 "strings" 5 6 "github.com/docker/docker/pkg/integration/checker" 7 "github.com/go-check/check" 8 ) 9 10 func (s *DockerSuite) TestTopMultipleArgs(c *check.C) { 11 testRequires(c, DaemonIsLinux) 12 out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top") 13 cleanedContainerID := strings.TrimSpace(out) 14 15 out, _ = dockerCmd(c, "top", cleanedContainerID, "-o", "pid") 16 c.Assert(out, checker.Contains, "PID", check.Commentf("did not see PID after top -o pid: %s", out)) 17 } 18 19 func (s *DockerSuite) TestTopNonPrivileged(c *check.C) { 20 testRequires(c, DaemonIsLinux) 21 out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top") 22 cleanedContainerID := strings.TrimSpace(out) 23 24 out1, _ := dockerCmd(c, "top", cleanedContainerID) 25 out2, _ := dockerCmd(c, "top", cleanedContainerID) 26 dockerCmd(c, "kill", cleanedContainerID) 27 28 c.Assert(out1, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the first time")) 29 c.Assert(out2, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the second time")) 30 } 31 32 func (s *DockerSuite) TestTopPrivileged(c *check.C) { 33 testRequires(c, DaemonIsLinux, NotUserNamespace) 34 out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top") 35 cleanedContainerID := strings.TrimSpace(out) 36 37 out1, _ := dockerCmd(c, "top", cleanedContainerID) 38 out2, _ := dockerCmd(c, "top", cleanedContainerID) 39 dockerCmd(c, "kill", cleanedContainerID) 40 41 c.Assert(out1, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the first time")) 42 c.Assert(out2, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the second time")) 43 }