Skip to content

Commit

Permalink
Add a test for leaking filedescriptors.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwen committed Sep 8, 2011
1 parent a5fe8b5 commit 8c9613f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions unionfs/unionfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,3 +944,30 @@ func TestDoubleOpen(t *testing.T) {
t.Errorf("r/w and r/o file are not synchronized: got %q want %q", string(b), want)
}
}


func TestFdLeak(t *testing.T) {
beforeEntries, err := ioutil.ReadDir("/proc/self/fd")
CheckSuccess(err)

wd, clean := setupUfs(t)
err = ioutil.WriteFile(wd+"/ro/file", []byte("blablabla"), 0644)
CheckSuccess(err)

contents, err := ioutil.ReadFile(wd + "/mount/file")
CheckSuccess(err)

err = ioutil.WriteFile(wd + "/mount/file", contents, 0644)
CheckSuccess(err)

clean()

afterEntries, err := ioutil.ReadDir("/proc/self/fd")
CheckSuccess(err)

if len(afterEntries) != len(beforeEntries) {
t.Errorf("/proc/self/fd changed size: after %v before %v", len(beforeEntries), len(afterEntries))
}
}


0 comments on commit 8c9613f

Please sign in to comment.