github.com/crquan/docker@v1.8.1/integration-cli/docker_cli_top_test.go (about) 1 package main 2 3 import ( 4 "strings" 5 6 "github.com/go-check/check" 7 ) 8 9 func (s *DockerSuite) TestTopMultipleArgs(c *check.C) { 10 out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top") 11 12 cleanedContainerID := strings.TrimSpace(out) 13 14 out, _ = dockerCmd(c, "top", cleanedContainerID, "-o", "pid") 15 if !strings.Contains(out, "PID") { 16 c.Fatalf("did not see PID after top -o pid: %s", out) 17 } 18 19 } 20 21 func (s *DockerSuite) TestTopNonPrivileged(c *check.C) { 22 out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top") 23 cleanedContainerID := strings.TrimSpace(out) 24 25 out1, _ := dockerCmd(c, "top", cleanedContainerID) 26 out2, _ := dockerCmd(c, "top", cleanedContainerID) 27 out, _ = dockerCmd(c, "kill", cleanedContainerID) 28 29 if !strings.Contains(out1, "top") && !strings.Contains(out2, "top") { 30 c.Fatal("top should've listed `top` in the process list, but failed twice") 31 } else if !strings.Contains(out1, "top") { 32 c.Fatal("top should've listed `top` in the process list, but failed the first time") 33 } else if !strings.Contains(out2, "top") { 34 c.Fatal("top should've listed `top` in the process list, but failed the second itime") 35 } 36 37 } 38 39 func (s *DockerSuite) TestTopPrivileged(c *check.C) { 40 out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top") 41 cleanedContainerID := strings.TrimSpace(out) 42 43 out1, _ := dockerCmd(c, "top", cleanedContainerID) 44 out2, _ := dockerCmd(c, "top", cleanedContainerID) 45 out, _ = dockerCmd(c, "kill", cleanedContainerID) 46 47 if !strings.Contains(out1, "top") && !strings.Contains(out2, "top") { 48 c.Fatal("top should've listed `top` in the process list, but failed twice") 49 } else if !strings.Contains(out1, "top") { 50 c.Fatal("top should've listed `top` in the process list, but failed the first time") 51 } else if !strings.Contains(out2, "top") { 52 c.Fatal("top should've listed `top` in the process list, but failed the second itime") 53 } 54 55 }