2014-02-25 20:17:48 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
2015-04-18 19:46:47 +03:00
|
|
|
|
2015-10-08 22:42:41 +03:00
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
2015-04-18 19:46:47 +03:00
|
|
|
"github.com/go-check/check"
|
2014-02-25 20:17:48 +04:00
|
|
|
)
|
|
|
|
|
2015-04-18 19:46:47 +03:00
|
|
|
func (s *DockerSuite) TestTopMultipleArgs(c *check.C) {
|
2015-08-28 20:36:42 +03:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2015-07-20 09:44:22 +03:00
|
|
|
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top")
|
2015-04-06 16:21:18 +03:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-08-31 16:53:05 +04:00
|
|
|
|
2015-07-20 09:44:22 +03:00
|
|
|
out, _ = dockerCmd(c, "top", cleanedContainerID, "-o", "pid")
|
2015-10-08 22:42:41 +03:00
|
|
|
c.Assert(out, checker.Contains, "PID", check.Commentf("did not see PID after top -o pid: %s", out))
|
2014-08-31 16:53:05 +04:00
|
|
|
}
|
|
|
|
|
2015-04-18 19:46:47 +03:00
|
|
|
func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
|
2015-08-28 20:36:42 +03:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2015-07-20 09:44:22 +03:00
|
|
|
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top")
|
2015-04-06 16:21:18 +03:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-02-25 20:17:48 +04:00
|
|
|
|
2015-07-20 09:44:22 +03:00
|
|
|
out1, _ := dockerCmd(c, "top", cleanedContainerID)
|
|
|
|
out2, _ := dockerCmd(c, "top", cleanedContainerID)
|
2015-10-08 22:42:41 +03:00
|
|
|
dockerCmd(c, "kill", cleanedContainerID)
|
2014-02-25 20:17:48 +04:00
|
|
|
|
2015-10-08 22:42:41 +03:00
|
|
|
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"))
|
2014-04-09 15:43:19 +04:00
|
|
|
}
|
|
|
|
|
2015-04-18 19:46:47 +03:00
|
|
|
func (s *DockerSuite) TestTopPrivileged(c *check.C) {
|
2015-09-18 20:41:12 +03:00
|
|
|
testRequires(c, DaemonIsLinux, NotUserNamespace)
|
2015-07-20 09:44:22 +03:00
|
|
|
out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top")
|
2015-04-06 16:21:18 +03:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-04-09 15:43:19 +04:00
|
|
|
|
2015-07-20 09:44:22 +03:00
|
|
|
out1, _ := dockerCmd(c, "top", cleanedContainerID)
|
|
|
|
out2, _ := dockerCmd(c, "top", cleanedContainerID)
|
2015-10-08 22:42:41 +03:00
|
|
|
dockerCmd(c, "kill", cleanedContainerID)
|
2014-04-09 15:43:19 +04:00
|
|
|
|
2015-10-08 22:42:41 +03:00
|
|
|
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"))
|
2014-02-25 20:17:48 +04:00
|
|
|
}
|