https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/256

Index: tests/test-helpers.c
--- tests/test-helpers.c.orig
+++ tests/test-helpers.c
@@ -61,6 +61,33 @@ count_open_fds(void)
 	assert(error == 0 && "sysctl KERN_PROC_NFDS failed.");
 	return nfds;
 }
+#elif defined(__OpenBSD__)
+#include <sys/sysctl.h>
+
+/*
+ * On OpenBSD, get file descriptor information using sysctl()
+ */
+int
+count_open_fds(void)
+{
+	int error;
+	int mib[6];
+	size_t size;
+
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_FILE;
+	mib[2] = KERN_FILE_BYPID;
+	mib[3] = getpid();
+	mib[4] = sizeof(struct kinfo_file);
+	mib[5] = 0;
+
+	/* find the size required to store all the entries */
+	error = sysctl(mib, 6, NULL, &size, NULL, 0);
+	assert(error != -1 && "sysctl KERN_FILE_BYPID failed.");
+
+	/* return the current number of entries */
+	return size / sizeof(struct kinfo_file);
+}
 #else
 int
 count_open_fds(void)
