From owner-svn-src-all@FreeBSD.ORG Sat Nov 1 17:19:44 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 47D627A1; Sat, 1 Nov 2014 17:19:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 341D6DC7; Sat, 1 Nov 2014 17:19:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA1HJitW035651; Sat, 1 Nov 2014 17:19:44 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA1HJiua035650; Sat, 1 Nov 2014 17:19:44 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201411011719.sA1HJiua035650@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 1 Nov 2014 17:19:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273937 - head/contrib/netbsd-tests/lib/libc/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Nov 2014 17:19:44 -0000 Author: ngie Date: Sat Nov 1 17:19:43 2014 New Revision: 273937 URL: https://svnweb.freebsd.org/changeset/base/273937 Log: 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 Modified: head/contrib/netbsd-tests/lib/libc/sys/t_dup.c Modified: head/contrib/netbsd-tests/lib/libc/sys/t_dup.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_dup.c Sat Nov 1 17:14:29 2014 (r273936) +++ head/contrib/netbsd-tests/lib/libc/sys/t_dup.c Sat Nov 1 17:19:43 2014 (r273937) @@ -45,8 +45,14 @@ __RCSID("$NetBSD: t_dup.c,v 1.8 2012/03/ #include #include +#ifdef __FreeBSD__ +#include +#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);