Changeset View
Changeset View
Standalone View
Standalone View
graphics/wayland/files/patch-tests_test-helpers.c
--- tests/test-helpers.c.orig 2020-02-11 23:46:03 UTC | --- tests/test-helpers.c.orig 2020-02-11 23:46:03 UTC | ||||
+++ tests/test-helpers.c | +++ tests/test-helpers.c | ||||
@@ -25,6 +25,12 @@ | @@ -25,6 +25,8 @@ | ||||
#include "config.h" | #include "config.h" | ||||
+#include "../config.h" | +#include "../config.h" | ||||
+ | + | ||||
+#ifdef HAVE_SYS_PARAM_H | |||||
+#include <sys/param.h> | |||||
+#endif | |||||
+ | |||||
#include <assert.h> | #include <assert.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <dirent.h> | #include <dirent.h> | ||||
@@ -41,6 +47,16 @@ | @@ -41,6 +43,16 @@ | ||||
#include "test-runner.h" | #include "test-runner.h" | ||||
+#ifdef __FreeBSD__ | +#ifdef __FreeBSD__ | ||||
+/* FreeBSD uses fdescfs (which must be mounted using: | +/* FreeBSD uses fdescfs (which must be mounted using: | ||||
+ * mount -t fdescfs fdescfs /dev/fd | + * mount -t fdescfs fdescfs /dev/fd | ||||
+ * before the test suite can be run). */ | + * before the test suite can be run). */ | ||||
+#define OPEN_FDS_DIR "/dev/fd" | +#define OPEN_FDS_DIR "/dev/fd" | ||||
+#else | +#else | ||||
+/* Linux. */ | +/* Linux. */ | ||||
+#define OPEN_FDS_DIR "/proc/self/fd" | +#define OPEN_FDS_DIR "/proc/self/fd" | ||||
+#endif | +#endif | ||||
+ | + | ||||
int | int | ||||
count_open_fds(void) | count_open_fds(void) | ||||
{ | { | ||||
@@ -48,8 +64,8 @@ count_open_fds(void) | @@ -48,8 +60,8 @@ count_open_fds(void) | ||||
struct dirent *ent; | struct dirent *ent; | ||||
int count = 0; | int count = 0; | ||||
- dir = opendir("/proc/self/fd"); | - dir = opendir("/proc/self/fd"); | ||||
- assert(dir && "opening /proc/self/fd failed."); | - assert(dir && "opening /proc/self/fd failed."); | ||||
+ dir = opendir(OPEN_FDS_DIR); | + dir = opendir(OPEN_FDS_DIR); | ||||
+ assert(dir && "opening " OPEN_FDS_DIR " failed."); | + assert(dir && "opening " OPEN_FDS_DIR " failed."); | ||||
errno = 0; | errno = 0; | ||||
while ((ent = readdir(dir))) { | while ((ent = readdir(dir))) { | ||||
@@ -58,7 +74,7 @@ count_open_fds(void) | @@ -58,7 +70,7 @@ count_open_fds(void) | ||||
continue; | continue; | ||||
count++; | count++; | ||||
} | } | ||||
- assert(errno == 0 && "reading /proc/self/fd failed."); | - assert(errno == 0 && "reading /proc/self/fd failed."); | ||||
+ assert(errno == 0 && "reading " OPEN_FDS_DIR " failed."); | + assert(errno == 0 && "reading " OPEN_FDS_DIR " failed."); | ||||
closedir(dir); | closedir(dir); | ||||