summaryrefslogtreecommitdiff
path: root/tests/test_helpers
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-01-02 01:09:09 +0100
committerJakob Unterwurzacher2019-01-02 01:09:09 +0100
commit772afa93f98aa77959995e42564b898057c59b87 (patch)
tree974b667fb481b87ef4ea6f2375d2dc7c48fd12fe /tests/test_helpers
parent5aa1755cbc55d17a5b4b71faa1e0bba34fe83d8b (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')
-rw-r--r--tests/test_helpers/mount_unmount.go12
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
}