aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2021-03-18 09:25:58 +0000
committerAlexander Richardson <alexander.richardson@cl.cam.ac.uk>2021-09-10 11:35:54 +0000
commit644efe9517eb48d18decc33d5bed5276fcdd2f5a (patch)
tree6ef3d2f9ba28917432e3fd091bb8a8bb65df7a92
parentshm: Add mmap+memmove fallback if mremap() does not exist (diff)
downloadwayland-644efe9517eb48d18decc33d5bed5276fcdd2f5a.tar
wayland-644efe9517eb48d18decc33d5bed5276fcdd2f5a.tar.gz
wayland-644efe9517eb48d18decc33d5bed5276fcdd2f5a.tar.bz2
wayland-644efe9517eb48d18decc33d5bed5276fcdd2f5a.tar.lz
wayland-644efe9517eb48d18decc33d5bed5276fcdd2f5a.tar.xz
wayland-644efe9517eb48d18decc33d5bed5276fcdd2f5a.tar.zst
wayland-644efe9517eb48d18decc33d5bed5276fcdd2f5a.zip
Use /dev/fd instead of /proc/self/fd
/dev/fd exists on all operating systems I can test (Linux, FreeBSD, macOS), whereas /proc/self/fd only appears to exist on Linux. Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
-rw-r--r--tests/test-helpers.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/test-helpers.c b/tests/test-helpers.c
index 20b6690..4cdd1fc 100644
--- a/tests/test-helpers.c
+++ b/tests/test-helpers.c
@@ -48,8 +48,12 @@ count_open_fds(void)
struct dirent *ent;
int count = 0;
- dir = opendir("/proc/self/fd");
- assert(dir && "opening /proc/self/fd failed.");
+ /*
+ * Using /dev/fd instead of /proc/self/fd should allow this code to
+ * work on non-Linux operating systems.
+ */
+ dir = opendir("/dev/fd");
+ assert(dir && "opening /dev/fd failed.");
errno = 0;
while ((ent = readdir(dir))) {
@@ -58,7 +62,7 @@ count_open_fds(void)
continue;
count++;
}
- assert(errno == 0 && "reading /proc/self/fd failed.");
+ assert(errno == 0 && "reading /dev/fd failed.");
closedir(dir);