https://marc.info/?l=openbsd-tech&m=175126829818350&w=2

Index: usr/src/test/os-tests/tests/oclo/oclo_errors.c
--- usr/src/test/os-tests/tests/oclo/oclo_errors.c.orig
+++ usr/src/test/os-tests/tests/oclo/oclo_errors.c
@@ -24,17 +24,22 @@
  *  o accept4()
  */
 
-#include <stdlib.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
 #include <err.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stdbool.h>
 #include <errno.h>
-#include <string.h>
 #include <fcntl.h>
 #include <limits.h>
-#include <sys/socket.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
+#define strerrorname_np(e) (sys_errlist[e])
+
 static bool
 oclo_check(const char *desc, const char *act, int ret, int e)
 {
@@ -42,7 +47,7 @@ oclo_check(const char *desc, const char *act, int ret,
 		warnx("TEST FAILED: %s: fd was %s!", desc, act);
 		return (false);
 	} else if (errno != EINVAL) {
-		int e = errno;
+		e = errno;
 		warnx("TEST FAILED: %s: failed with %s, expected "
 		    "EINVAL", desc, strerrorname_np(e));
 		return (false);
@@ -60,14 +65,15 @@ oclo_dup3(const char *desc, int flags)
 	return (oclo_check(desc, "duplicated", fd, errno));
 }
 
+#ifdef F_DUP3FD
 static bool
 oclo_dup3fd(const char *desc, int flags)
 {
-	int fd = fcntl(STDERR_FILENO, F_DUP3FD, 23, flags);
+	int fd = fcntl(STDERR_FILENO, F_DUP3FD | (flags << F_DUP3FD_SHIFT), 23);
 	return (oclo_check(desc, "duplicated", fd, errno));
 }
+#endif
 
-
 static bool
 oclo_pipe2(const char *desc, int flags)
 {
@@ -139,6 +145,7 @@ main(void)
 		ret = EXIT_FAILURE;
 	}
 
+#ifdef F_DUP3FD
 	if (!oclo_dup3fd("fcntl(FDUP3FD): 0x7777", 0x7777)) {
 		ret = EXIT_FAILURE;
 	}
@@ -151,8 +158,8 @@ main(void)
 	if (!oclo_dup3fd("fcntl(FDUP3FD): INT_MAX", INT_MAX)) {
 		ret = EXIT_FAILURE;
 	}
+#endif
 
-
 	if (!oclo_pipe2("pipe2(): O_RDWR", O_RDWR)) {
 		ret = EXIT_FAILURE;
 	}
@@ -173,9 +180,11 @@ main(void)
 		ret = EXIT_FAILURE;
 	}
 
+#if 0	/* XXX */
 	if (!oclo_socket("socket(): 3 << 25", 3 << 25)) {
 		ret = EXIT_FAILURE;
 	}
+#endif
 
 	if (!oclo_accept("accept4(): INT32_MAX", INT32_MAX)) {
 		ret = EXIT_FAILURE;
