[PATCH v5 11/11] tests: use fdescfs at *BSD to count fds
Leonid Bobrov
mazocomp at disroot.org
Wed Feb 13 11:39:16 UTC 2019
Signed-off-by: Leonid Bobrov <mazocomp at disroot.org>
---
tests/test-helpers.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tests/test-helpers.c b/tests/test-helpers.c
index f0c5b28..137c0b8 100644
--- a/tests/test-helpers.c
+++ b/tests/test-helpers.c
@@ -47,6 +47,11 @@
#else
#include <errno.h>
#include <dirent.h>
+# ifdef __linux__
+# define OPEN_FDS_DIR "/proc/self/fd"
+# else
+# define OPEN_FDS_DIR "/dev/fd"
+# endif
#endif
#include "test-runner.h"
@@ -75,8 +80,8 @@ count_open_fds(void)
struct dirent *ent;
int count = 0;
- dir = opendir("/proc/self/fd");
- assert(dir && "opening /proc/self/fd failed.");
+ dir = opendir(OPEN_FDS_DIR);
+ assert(dir && "opening " OPEN_FDS_DIR " failed.");
errno = 0;
while ((ent = readdir(dir))) {
@@ -85,7 +90,7 @@ count_open_fds(void)
continue;
count++;
}
- assert(errno == 0 && "reading /proc/self/fd failed.");
+ assert(errno == 0 && "reading " OPEN_FDS_DIR " failed.");
closedir(dir);
--
2.20.1
More information about the wayland-devel
mailing list