Commit 8c9613f5 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add a test for leaking filedescriptors.

parent a5fe8b5a
......@@ -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))
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment