From owner-svn-src-head@FreeBSD.ORG Thu Oct 23 06:18:29 2014 Return-Path: Delivered-To: svn-src-head@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 15E90987; Thu, 23 Oct 2014 06:18:29 +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 EBAC9ED8; Thu, 23 Oct 2014 06:18:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9N6ISV6035129; Thu, 23 Oct 2014 06:18:28 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9N6ISU6035128; Thu, 23 Oct 2014 06:18:28 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201410230618.s9N6ISU6035128@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Thu, 23 Oct 2014 06:18:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273520 - 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-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Oct 2014 06:18:29 -0000 Author: ngie Date: Thu Oct 23 06:18:28 2014 New Revision: 273520 URL: https://svnweb.freebsd.org/changeset/base/273520 Log: Port t_pipe2.c to FreeBSD - Omit the pipe2_nosigpipe testcase on FreeBSD (FreeBSD doesn't have O_NOSIGPIPE). - Convert "fcntl(n, F_CLOSEM)" to "closefrom(n)". - Save and restore the resource limit on the number of files (RLIMIT_NOFILE). In collaboration with: pho Sponsored by: EMC / Isilon Storage Division Modified: head/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c Modified: head/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c Thu Oct 23 06:13:42 2014 (r273519) +++ head/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c Thu Oct 23 06:18:28 2014 (r273520) @@ -53,7 +53,11 @@ run(int flags) while ((i = open("/", O_RDONLY)) < 3) ATF_REQUIRE(i != -1); +#if defined(__FreeBSD__) + closefrom(3); +#else ATF_REQUIRE(fcntl(3, F_CLOSEM) != -1); +#endif ATF_REQUIRE(pipe2(fd, flags) == 0); @@ -76,6 +80,7 @@ run(int flags) ATF_REQUIRE((fcntl(fd[1], F_GETFL) & O_NONBLOCK) == 0); } +#if !defined(__FreeBSD__) if (flags & O_NOSIGPIPE) { ATF_REQUIRE(fcntl(fd[0], F_GETNOSIGPIPE) != 0); ATF_REQUIRE(fcntl(fd[1], F_GETNOSIGPIPE) != 0); @@ -83,6 +88,7 @@ run(int flags) ATF_REQUIRE(fcntl(fd[0], F_GETNOSIGPIPE) == 0); ATF_REQUIRE(fcntl(fd[1], F_GETNOSIGPIPE) == 0); } +#endif ATF_REQUIRE(close(fd[0]) != -1); ATF_REQUIRE(close(fd[1]) != -1); @@ -110,9 +116,14 @@ ATF_TC_BODY(pipe2_consume, tc) { struct rlimit rl; int err, filedes[2]; +#if defined(__FreeBSD__) + int old; + closefrom(4); +#else err = fcntl(4, F_CLOSEM); ATF_REQUIRE(err == 0); +#endif err = getrlimit(RLIMIT_NOFILE, &rl); ATF_REQUIRE(err == 0); @@ -121,12 +132,19 @@ ATF_TC_BODY(pipe2_consume, tc) * file descriptor limit in the middle of a pipe2() call - i.e. * before the call only a single descriptor may be openend. */ +#if defined(__FreeBSD__) + old = rl.rlim_cur; +#endif rl.rlim_cur = 4; err = setrlimit(RLIMIT_NOFILE, &rl); ATF_REQUIRE(err == 0); err = pipe2(filedes, O_CLOEXEC); ATF_REQUIRE(err == -1); +#if defined(__FreeBSD__) + rl.rlim_cur = old; + err = setrlimit(RLIMIT_NOFILE, &rl); +#endif } ATF_TC(pipe2_nonblock); @@ -151,6 +169,7 @@ ATF_TC_BODY(pipe2_cloexec, tc) run(O_CLOEXEC); } +#if defined(__NetBSD__) ATF_TC(pipe2_nosigpipe); ATF_TC_HEAD(pipe2_nosigpipe, tc) { @@ -161,6 +180,7 @@ ATF_TC_BODY(pipe2_nosigpipe, tc) { run(O_NOSIGPIPE); } +#endif ATF_TC(pipe2_einval); ATF_TC_HEAD(pipe2_einval, tc) @@ -181,7 +201,9 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, pipe2_consume); ATF_TP_ADD_TC(tp, pipe2_nonblock); ATF_TP_ADD_TC(tp, pipe2_cloexec); +#if defined(__NetBSD__) ATF_TP_ADD_TC(tp, pipe2_nosigpipe); +#endif ATF_TP_ADD_TC(tp, pipe2_einval); return atf_no_error();