Browse code

add test

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)

Victor Vieux authored on 2014/04/02 06:07:40
Showing 1 changed files
... ...
@@ -64,3 +64,28 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
64 64
 
65 65
 	logDone("diff - check if ignored files show up in diff")
66 66
 }
67
+
68
+func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
69
+	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sleep 0")
70
+	cid, _, err := runCommandWithOutput(runCmd)
71
+	errorOut(err, t, fmt.Sprintf("%s", err))
72
+	cleanCID := stripTrailingCharacters(cid)
73
+
74
+	diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
75
+	out, _, err := runCommandWithOutput(diffCmd)
76
+	errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err))
77
+	go deleteContainer(cleanCID)
78
+
79
+	expected := map[string]bool{
80
+		"C /dev":      true,
81
+		"A /dev/full": true, // busybox
82
+		"C /dev/ptmx": true, // libcontainer
83
+		"A /dev/kmsg": true, // lxc
84
+	}
85
+
86
+	for _, line := range strings.Split(out, "\n") {
87
+		if line != "" && !expected[line] {
88
+			t.Errorf("'%s' is shown in the diff but shouldn't", line)
89
+		}
90
+	}
91
+}