From 772afa93f98aa77959995e42564b898057c59b87 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 2 Jan 2019 01:09:09 +0100 Subject: 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. --- tests/test_helpers/mount_unmount.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests/test_helpers') 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 } -- cgit v1.2.3