6db32fde |
package main
import (
"strings" |
dc944ea7 |
|
72269acf |
"github.com/docker/docker/pkg/integration/checker" |
dc944ea7 |
"github.com/go-check/check" |
6db32fde |
)
|
dc944ea7 |
func (s *DockerSuite) TestTopMultipleArgs(c *check.C) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
eef6eda7 |
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top") |
475c6531 |
cleanedContainerID := strings.TrimSpace(out) |
d7dd35bb |
|
eef6eda7 |
out, _ = dockerCmd(c, "top", cleanedContainerID, "-o", "pid") |
72269acf |
c.Assert(out, checker.Contains, "PID", check.Commentf("did not see PID after top -o pid: %s", out)) |
d7dd35bb |
}
|
dc944ea7 |
func (s *DockerSuite) TestTopNonPrivileged(c *check.C) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
eef6eda7 |
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top") |
475c6531 |
cleanedContainerID := strings.TrimSpace(out) |
6db32fde |
|
eef6eda7 |
out1, _ := dockerCmd(c, "top", cleanedContainerID)
out2, _ := dockerCmd(c, "top", cleanedContainerID) |
72269acf |
dockerCmd(c, "kill", cleanedContainerID) |
6db32fde |
|
72269acf |
c.Assert(out1, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the first time"))
c.Assert(out2, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the second time")) |
031fcb31 |
}
|
dc944ea7 |
func (s *DockerSuite) TestTopPrivileged(c *check.C) { |
ea3afdad |
testRequires(c, DaemonIsLinux, NotUserNamespace) |
eef6eda7 |
out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top") |
475c6531 |
cleanedContainerID := strings.TrimSpace(out) |
031fcb31 |
|
eef6eda7 |
out1, _ := dockerCmd(c, "top", cleanedContainerID)
out2, _ := dockerCmd(c, "top", cleanedContainerID) |
72269acf |
dockerCmd(c, "kill", cleanedContainerID) |
031fcb31 |
|
72269acf |
c.Assert(out1, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the first time"))
c.Assert(out2, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the second time")) |
6db32fde |
} |