[v5,11/11] tests: use fdescfs at *BSD to count fds

Submitted by Leonid Bobrov via wayland-devel on Feb. 13, 2019, 11:39 a.m.

Details

Message ID 20190213113916.75159-11-mazocomp@disroot.org
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Wayland

Not browsing as part of any series.

Commit Message

Leonid Bobrov via wayland-devel Feb. 13, 2019, 11:39 a.m.
Signed-off-by: Leonid Bobrov <mazocomp@disroot.org>
---
 tests/test-helpers.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

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);