Fix the unit test not to remove /tmp

Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>
This commit is contained in:
Yohei Ueda 2014-11-07 02:17:02 +09:00
parent bf0a0e9ca7
commit 3a138a9b5e

View file

@ -38,12 +38,13 @@ BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`)
) )
dir := os.TempDir() dir := os.TempDir()
etcOsRelease = filepath.Join(dir, "etcOsRelease")
defer func() { defer func() {
os.Remove(etcOsRelease)
etcOsRelease = backup etcOsRelease = backup
os.RemoveAll(dir)
}() }()
etcOsRelease = filepath.Join(dir, "etcOsRelease")
for expect, osRelease := range map[string][]byte{ for expect, osRelease := range map[string][]byte{
"Ubuntu 14.04 LTS": ubuntuTrusty, "Ubuntu 14.04 LTS": ubuntuTrusty,
"Gentoo/Linux": gentoo, "Gentoo/Linux": gentoo,
@ -92,13 +93,13 @@ func TestIsContainerized(t *testing.T) {
) )
dir := os.TempDir() dir := os.TempDir()
defer func() {
proc1Cgroup = backup
os.RemoveAll(dir)
}()
proc1Cgroup = filepath.Join(dir, "proc1Cgroup") proc1Cgroup = filepath.Join(dir, "proc1Cgroup")
defer func() {
os.Remove(proc1Cgroup)
proc1Cgroup = backup
}()
if err := ioutil.WriteFile(proc1Cgroup, nonContainerizedProc1Cgroup, 0600); err != nil { if err := ioutil.WriteFile(proc1Cgroup, nonContainerizedProc1Cgroup, 0600); err != nil {
t.Fatalf("failed to write to %s: %v", proc1Cgroup, err) t.Fatalf("failed to write to %s: %v", proc1Cgroup, err)
} }