aboutsummaryrefslogtreecommitdiff
path: root/tests/test_helpers
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-09-25 14:57:04 +0200
committerJakob Unterwurzacher2016-09-25 16:43:17 +0200
commitf8da264222f7348c6b9e6dd9d372200f850d2878 (patch)
tree58913c702493dd8b1839822fae17289358bddaa4 /tests/test_helpers
parent7bbf6ad6eae47974b1162af13915785a541b9bb9 (diff)
tests: smarter error handling in ResetTmpDir
Look at the error code from os.Remove and decide about the right thing to do. Gets rid of spurious fusermount error messages.
Diffstat (limited to 'tests/test_helpers')
-rw-r--r--tests/test_helpers/helpers.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index 7e1f4e8..5c71d30 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -54,10 +54,18 @@ func ResetTmpDir(plaintextNames bool) {
d := filepath.Join(TmpDir, e.Name())
err = os.Remove(d)
if err != nil {
- if testing.Verbose() {
- fmt.Printf("%v, trying umount\n", d, err)
+ pe := err.(*os.PathError)
+ if pe.Err == syscall.EBUSY {
+ if testing.Verbose() {
+ fmt.Printf("Remove failed: %v. Maybe still mounted?\n", pe)
+ }
+ err = UnmountErr(d)
+ if err != nil {
+ panic(err)
+ }
+ } else if pe.Err != syscall.ENOTEMPTY {
+ panic("Unhandled error: " + pe.Err.Error())
}
- UnmountErr(d)
err = os.RemoveAll(d)
if err != nil {
panic(err)