summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-04-10 19:43:37 +0200
committerJakob Unterwurzacher2016-04-10 21:31:15 +0200
commitbd1f17ca9f210b318e28d7ed233698b950d564b8 (patch)
treefc5baac0ef1825e86b21179e2506c54ac9b34223
parentdb72fcea41f01f24ac3edb1cbf86d6b0be60f137 (diff)
tests: clean up leftover mounts in resetTmpDir
Failure in the example filesystems tests can leave them mounted.
-rw-r--r--integration_tests/helpers.go15
1 files 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)
}
}