Commit d5da28da authored by Adam H. Leventhal's avatar Adam H. Leventhal Committed by Han-Wen Nienhuys

Add test for #115.

parent 778c9eb1
......@@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"testing"
"time"
......@@ -197,3 +198,33 @@ func TestDefaultNodeMount(t *testing.T) {
t.Fatalf("got %q, want %q", entries[0].Name(), "sub")
}
}
func TestLiveness(t *testing.T) {
dir, err := ioutil.TempDir("", "go-fuse")
if err != nil {
t.Fatalf("TempDir: %v", err)
}
defer os.RemoveAll(dir)
root := nodefs.NewDefaultNode()
s, _, err := nodefs.MountRoot(dir, root, nil)
if err != nil {
t.Fatalf("MountRoot: %v", err)
}
go s.Serve()
if err := s.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
defer s.Unmount()
if _, err := ioutil.ReadDir(dir); err != nil {
t.Fatalf("ReadDir: %v", err)
}
// We previously encountered a sitation where a finalizer would close our fd out from under us. Try to force both finalizers to run and object destruction to complete.
runtime.GC()
runtime.GC()
if _, err := ioutil.ReadDir(dir); err != nil {
t.Fatalf("ReadDir: %v", err)
}
}
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