1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/docker_cli_top_test.go
Jessica Frazelle ea3afdad61 add test-integration-cli specifics for userns
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2015-10-09 20:50:27 -04:00

58 lines
2 KiB
Go

package main
import (
"strings"
"github.com/go-check/check"
)
func (s *DockerSuite) TestTopMultipleArgs(c *check.C) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top")
cleanedContainerID := strings.TrimSpace(out)
out, _ = dockerCmd(c, "top", cleanedContainerID, "-o", "pid")
if !strings.Contains(out, "PID") {
c.Fatalf("did not see PID after top -o pid: %s", out)
}
}
func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top")
cleanedContainerID := strings.TrimSpace(out)
out1, _ := dockerCmd(c, "top", cleanedContainerID)
out2, _ := dockerCmd(c, "top", cleanedContainerID)
out, _ = dockerCmd(c, "kill", cleanedContainerID)
if !strings.Contains(out1, "top") && !strings.Contains(out2, "top") {
c.Fatal("top should've listed `top` in the process list, but failed twice")
} else if !strings.Contains(out1, "top") {
c.Fatal("top should've listed `top` in the process list, but failed the first time")
} else if !strings.Contains(out2, "top") {
c.Fatal("top should've listed `top` in the process list, but failed the second itime")
}
}
func (s *DockerSuite) TestTopPrivileged(c *check.C) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top")
cleanedContainerID := strings.TrimSpace(out)
out1, _ := dockerCmd(c, "top", cleanedContainerID)
out2, _ := dockerCmd(c, "top", cleanedContainerID)
out, _ = dockerCmd(c, "kill", cleanedContainerID)
if !strings.Contains(out1, "top") && !strings.Contains(out2, "top") {
c.Fatal("top should've listed `top` in the process list, but failed twice")
} else if !strings.Contains(out1, "top") {
c.Fatal("top should've listed `top` in the process list, but failed the first time")
} else if !strings.Contains(out2, "top") {
c.Fatal("top should've listed `top` in the process list, but failed the second itime")
}
}