Browse code

Add a test for the multiple arguments passed to `docker top`

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)

Erik Hollensbe authored on 2014/08/31 21:53:05
Showing 1 changed files
... ...
@@ -7,6 +7,25 @@ import (
7 7
 	"testing"
8 8
 )
9 9
 
10
+func TestTopMultipleArgs(t *testing.T) {
11
+	runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "sleep", "20")
12
+	out, _, err := runCommandWithOutput(runCmd)
13
+	errorOut(err, t, fmt.Sprintf("failed to start the container: %v", err))
14
+
15
+	cleanedContainerID := stripTrailingCharacters(out)
16
+	defer deleteContainer(cleanedContainerID)
17
+
18
+	topCmd := exec.Command(dockerBinary, "top", cleanedContainerID, "-o", "pid")
19
+	out, _, err = runCommandWithOutput(topCmd)
20
+	errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out, err))
21
+
22
+	if !strings.Contains(out, "PID") {
23
+		errorOut(nil, t, fmt.Sprintf("did not see PID after top -o pid"))
24
+	}
25
+
26
+	logDone("top - multiple arguments")
27
+}
28
+
10 29
 func TestTopNonPrivileged(t *testing.T) {
11 30
 	runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "sleep", "20")
12 31
 	out, _, err := runCommandWithOutput(runCmd)