From bd1f17ca9f210b318e28d7ed233698b950d564b8 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 10 Apr 2016 19:43:37 +0200 Subject: tests: clean up leftover mounts in resetTmpDir Failure in the example filesystems tests can leave them mounted. --- integration_tests/helpers.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go index df4c82a..bdb781f 100644 --- a/integration_tests/helpers.go +++ b/integration_tests/helpers.go @@ -23,10 +23,17 @@ const gocryptfsBinary = "../gocryptfs" // resetTmpDir - delete old tmp dir, create new one, write gocryptfs.diriv func resetTmpDir(plaintextNames bool) { - fu := exec.Command("fusermount", "-z", "-u", defaultPlainDir) - fu.Run() - err := os.RemoveAll(tmpDir) + // Try to unmount everything + entries, err := ioutil.ReadDir(tmpDir) + if err == nil { + for _, e := range entries { + fu := exec.Command("fusermount", "-z", "-u", filepath.Join(tmpDir, e.Name())) + fu.Run() + } + } + + err = os.RemoveAll(tmpDir) if err != nil { fmt.Println("resetTmpDir: RemoveAll:" + err.Error()) os.Exit(1) @@ -162,6 +169,8 @@ func testMkdirRmdir(t *testing.T, plainDir string) { } err = syscall.Rmdir(dir) if err != nil { + // Make sure the directory can cleaned up by the next test run + os.Chmod(dir, 0700) t.Fatal(err) } } -- cgit v1.2.3