Browse code

Merge pull request #8998 from yoheiueda/dont-remove-tmpdir

Fix the unit test not to remove /tmp

Alexandr Morozov authored on 2014/11/07 01:59:02
Showing 1 changed files
... ...
@@ -38,12 +38,13 @@ BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`)
38 38
 	)
39 39
 
40 40
 	dir := os.TempDir()
41
+	etcOsRelease = filepath.Join(dir, "etcOsRelease")
42
+
41 43
 	defer func() {
44
+		os.Remove(etcOsRelease)
42 45
 		etcOsRelease = backup
43
-		os.RemoveAll(dir)
44 46
 	}()
45 47
 
46
-	etcOsRelease = filepath.Join(dir, "etcOsRelease")
47 48
 	for expect, osRelease := range map[string][]byte{
48 49
 		"Ubuntu 14.04 LTS": ubuntuTrusty,
49 50
 		"Gentoo/Linux":     gentoo,
... ...
@@ -92,13 +93,13 @@ func TestIsContainerized(t *testing.T) {
92 92
 	)
93 93
 
94 94
 	dir := os.TempDir()
95
+	proc1Cgroup = filepath.Join(dir, "proc1Cgroup")
96
+
95 97
 	defer func() {
98
+		os.Remove(proc1Cgroup)
96 99
 		proc1Cgroup = backup
97
-		os.RemoveAll(dir)
98 100
 	}()
99 101
 
100
-	proc1Cgroup = filepath.Join(dir, "proc1Cgroup")
101
-
102 102
 	if err := ioutil.WriteFile(proc1Cgroup, nonContainerizedProc1Cgroup, 0600); err != nil {
103 103
 		t.Fatalf("failed to write to %s: %v", proc1Cgroup, err)
104 104
 	}