From d5a74d2a3e1f1203fd9adeb669c122631438cb31 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Tue, 1 Jan 2019 23:57:44 +0100 Subject: [PATCH] tests: ListFds(): filter out pipe and eventpoll fds These are created on demand by the Go runtime and are usually not interesting. --- tests/test_helpers/mount_unmount.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_helpers/mount_unmount.go b/tests/test_helpers/mount_unmount.go index 0ece781..1142666 100644 --- a/tests/test_helpers/mount_unmount.go +++ b/tests/test_helpers/mount_unmount.go @@ -8,6 +8,7 @@ import ( "os/exec" "os/signal" "runtime" + "strings" "syscall" "testing" "time" @@ -182,6 +183,7 @@ func ListFds(pid int) []string { log.Panic(err) } var out []string + hidden := 0 for _, n := range names { fdPath := dir + "/" + n fi, err := os.Lstat(fdPath) @@ -200,7 +202,16 @@ func ListFds(pid int) []string { // fd was closed in the meantime continue } + if strings.HasPrefix(target, "pipe:") || strings.HasPrefix(target, "anon_inode:[eventpoll]") { + // The Go runtime creates pipes on demand for splice(), which + // creates spurious test failures. Ignore all pipes. + // Also get rid of the "eventpoll" fd that is always there and not + // interesting. + hidden++ + continue + } out = append(out, n+"="+target) } + out = append(out, fmt.Sprintf("(hidden:%d)", hidden)) return out }