summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/sys/t_dup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libc/sys/t_dup.c')
-rw-r--r--src/regress/lib/libc/sys/t_dup.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/regress/lib/libc/sys/t_dup.c b/src/regress/lib/libc/sys/t_dup.c
index 4021a4f6e4..c998c228b4 100644
--- a/src/regress/lib/libc/sys/t_dup.c
+++ b/src/regress/lib/libc/sys/t_dup.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t_dup.c,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */ 1/* $OpenBSD: t_dup.c,v 1.2 2020/11/09 23:18:51 bluhm Exp $ */
2/* $NetBSD: t_dup.c,v 1.9 2017/01/13 20:31:53 christos Exp $ */ 2/* $NetBSD: t_dup.c,v 1.9 2017/01/13 20:31:53 christos Exp $ */
3 3
4/*- 4/*-
@@ -212,12 +212,18 @@ ATF_TC_BODY(dup3_err, tc)
212 ATF_REQUIRE(fd >= 0); 212 ATF_REQUIRE(fd >= 0);
213 213
214 errno = 0; 214 errno = 0;
215 /* Adjusted for OpenBSD, initially != -1 */ 215#ifdef __OpenBSD__
216 ATF_REQUIRE(dup3(fd, fd, O_CLOEXEC) == -1); 216 ATF_REQUIRE(dup3(fd, fd, O_CLOEXEC) == -1);
217#else
218 ATF_REQUIRE(dup3(fd, fd, O_CLOEXEC) != -1);
219#endif
217 220
218 errno = 0; 221 errno = 0;
219 /* Adjusted for OpenBSD, initially EBADF */ 222#ifdef __OpenBSD__
220 ATF_REQUIRE_ERRNO(EINVAL, dup3(-1, -1, O_CLOEXEC) == -1); 223 ATF_REQUIRE_ERRNO(EINVAL, dup3(-1, -1, O_CLOEXEC) == -1);
224#else
225 ATF_REQUIRE_ERRNO(EBADF, dup3(-1, -1, O_CLOEXEC) == -1);
226#endif
221 227
222 errno = 0; 228 errno = 0;
223 ATF_REQUIRE_ERRNO(EBADF, dup3(fd, -1, O_CLOEXEC) == -1); 229 ATF_REQUIRE_ERRNO(EBADF, dup3(fd, -1, O_CLOEXEC) == -1);
@@ -302,8 +308,11 @@ ATF_TC_BODY(dup_max, tc)
302 * reached. Ater that dup(2) family 308 * reached. Ater that dup(2) family
303 * should fail with EMFILE. 309 * should fail with EMFILE.
304 */ 310 */
305 /* Adjusted for OpenBSD, initially 0 */ 311#ifdef __OpenBSD__
306 (void)closefrom(STDERR_FILENO + 1); 312 (void)closefrom(STDERR_FILENO + 1);
313#else
314 (void)closefrom(0);
315#endif
307 (void)memset(&res, 0, sizeof(struct rlimit)); 316 (void)memset(&res, 0, sizeof(struct rlimit));
308 317
309 n = 10; 318 n = 10;
@@ -316,14 +325,20 @@ ATF_TC_BODY(dup_max, tc)
316 if (buf == NULL) 325 if (buf == NULL)
317 _exit(EX_OSERR); 326 _exit(EX_OSERR);
318 327
319 /* Adjusted for OpenBSD, initially mkstemp(path) */ 328#ifdef __OpenBSD__
320 buf[0] = open(path, O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR); 329 buf[0] = open(path, O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR);
330#else
331 buf[0] = mkstemp(path);
332#endif
321 333
322 if (buf[0] < 0) 334 if (buf[0] < 0)
323 _exit(EX_OSERR); 335 _exit(EX_OSERR);
324 336
325 /* Adjusted for OpenBSD, initially i < n */ 337#ifdef __OpenBSD__
326 for (i = 1; i < n - (STDERR_FILENO + 1); i++) { 338 for (i = 1; i < n - (STDERR_FILENO + 1); i++) {
339#else
340 for (i = 1; i < n; i++) {
341#endif
327 342
328 buf[i] = open(path, O_RDONLY); 343 buf[i] = open(path, O_RDONLY);
329 344