Commit 672815b2 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

tests: fix TestReaddirTypeFixup leaking broken mounts

After running the test suite, `df` used to report this:

  df: /tmp/TestReaddirTypeFixup090721515: Transport endpoint is not connected

To catch problems like this earlier, testMount() now reports failures to umount
cleanly, and catches the problem with TestReaddirTypeFixup:

  $ go test ./fs -run TestReaddirTypeFixup
  [...]
      mem_test.go:37: testMount: Unmount failed: /usr/bin/fusermount: failed to unmount /tmp/TestReaddirTypeFixup175482633: Device or resource busy

TestReaddirTypeFixup was missing ds.Close(), which was also added,
tests pass now and don't leave broken mounts behind.

Change-Id: Ib5d96c8531b11080cf8da526b917446388537956
parent 6ae4ba6c
......@@ -33,8 +33,12 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, *fuse.S
t.Fatal(err)
}
return mntDir, server, func() {
server.Unmount()
os.Remove(mntDir)
if err := server.Unmount(); err != nil {
t.Errorf("testMount: Unmount failed: %v", err)
}
if err := os.Remove(mntDir); err != nil {
t.Errorf("testMount: Remove failed: %v", err)
}
}
}
......
......@@ -71,6 +71,7 @@ func TestReaddirTypeFixup(t *testing.T) {
if errno != 0 {
t.Fatalf("readdir: %v", err)
}
defer ds.Close()
for ds.HasNext() {
e, err := ds.Next()
......
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