diff options
author | ngie <ngie@FreeBSD.org> | 2014-11-01 17:19:43 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2014-11-01 17:19:43 +0000 |
commit | 4e2c8a8ae0090b2855f8bd07da04456f07047955 (patch) | |
tree | a2fc15b7b6813afb9eab15afc642a731453f2e1c /contrib/netbsd-tests/lib/libc/sys/t_dup.c | |
parent | b50020b4808cf26dbffc60913477989a31b0bf4a (diff) | |
download | FreeBSD-src-4e2c8a8ae0090b2855f8bd07da04456f07047955.zip FreeBSD-src-4e2c8a8ae0090b2855f8bd07da04456f07047955.tar.gz |
Port lib/libc/sys/t_dup to FreeBSD/Linux
- The requirements differ between FreeBSD/Linux when dealing with oldd/newd
being equal (both fail with EINVAL, not EBADF)
- Add an EBADF testcase
- Fix compilation issues on clang
In collaboration with: pho
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/sys/t_dup.c')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/sys/t_dup.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_dup.c b/contrib/netbsd-tests/lib/libc/sys/t_dup.c index a2623c0..d8125ab 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_dup.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_dup.c @@ -45,8 +45,14 @@ __RCSID("$NetBSD: t_dup.c,v 1.8 2012/03/18 07:00:51 jruoho Exp $"); #include <unistd.h> #include <sysexits.h> +#ifdef __FreeBSD__ +#include <stdbool.h> +#endif + static char path[] = "dup"; +#ifdef __NetBSD__ static void check_mode(bool, bool, bool); +#endif static void check_mode(bool _dup, bool _dup2, bool _dup3) @@ -207,10 +213,24 @@ ATF_TC_BODY(dup3_err, tc) ATF_REQUIRE(fd >= 0); errno = 0; +#if defined(__FreeBSD__) || defined(__linux__) + /* + * FreeBSD and linux return EINVAL, because... + * + * [EINVAL] The oldd argument is equal to the newd argument. + */ + ATF_REQUIRE(dup3(fd, fd, O_CLOEXEC) == -1); +#else ATF_REQUIRE(dup3(fd, fd, O_CLOEXEC) != -1); +#endif errno = 0; +#if defined(__FreeBSD__) || defined(__linux__) + ATF_REQUIRE_ERRNO(EINVAL, dup3(-1, -1, O_CLOEXEC) == -1); + ATF_REQUIRE_ERRNO(EBADF, dup3(fd, -1, O_CLOEXEC) == -1); +#else ATF_REQUIRE_ERRNO(EBADF, dup3(-1, -1, O_CLOEXEC) == -1); +#endif errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup3(fd, -1, O_CLOEXEC) == -1); |