diff options
author | Jakob Unterwurzacher | 2019-01-02 01:09:09 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-01-02 01:09:09 +0100 |
commit | 772afa93f98aa77959995e42564b898057c59b87 (patch) | |
tree | 974b667fb481b87ef4ea6f2375d2dc7c48fd12fe /tests/test_helpers/mount_unmount.go | |
parent | 5aa1755cbc55d17a5b4b71faa1e0bba34fe83d8b (diff) |
tests: add fd leak retry logic to UnmountErr, really return error
Give the gocryptfs process one extra millisecond to close
files. Allows us to drop several other sleeps.
UnmountErr now really returns an error when it detects an fd leak
instead of just printing a message.
Diffstat (limited to 'tests/test_helpers/mount_unmount.go')
-rw-r--r-- | tests/test_helpers/mount_unmount.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/test_helpers/mount_unmount.go b/tests/test_helpers/mount_unmount.go index 1142666..cce763a 100644 --- a/tests/test_helpers/mount_unmount.go +++ b/tests/test_helpers/mount_unmount.go @@ -141,14 +141,22 @@ func UnmountErr(dir string) (err error) { for i := 1; i <= max; i++ { if pid > 0 { fdsNow = ListFds(pid) + if len(fdsNow) > len(fds) { + // File close on FUSE is asynchronous, closing a socket + // when testing -ctlsock as well. Wait one extra millisecond + // and hope that all close commands get through to the gocryptfs + // process. + time.Sleep(1 * time.Millisecond) + fdsNow = ListFds(pid) + } } cmd := exec.Command(UnmountScript, "-u", dir) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr err = cmd.Run() if err == nil { - if pid > 0 && len(fdsNow) > len(fds) { - fmt.Printf("FD leak? Details:\nold=%v \nnew=%v\n", fds, fdsNow) + if len(fdsNow) > len(fds) { + return fmt.Errorf("FD leak? pid=%d dir=%q, fds:\nold=%v \nnew=%v\n", pid, dir, fds, fdsNow) } return nil } |