Module Name: src Committed By: martin Date: Wed May 16 13:48:35 UTC 2012
Modified Files: src/tests/lib/libc/sys: t_pipe2.c Log Message: Simplify the test for PR kern/4645 and make it independend of resource settings. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/sys/t_pipe2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/lib/libc/sys/t_pipe2.c diff -u src/tests/lib/libc/sys/t_pipe2.c:1.6 src/tests/lib/libc/sys/t_pipe2.c:1.7 --- src/tests/lib/libc/sys/t_pipe2.c:1.6 Wed May 16 11:45:08 2012 +++ src/tests/lib/libc/sys/t_pipe2.c Wed May 16 13:48:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_pipe2.c,v 1.6 2012/05/16 11:45:08 wiz Exp $ */ +/* $NetBSD: t_pipe2.c,v 1.7 2012/05/16 13:48:35 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_pipe2.c,v 1.6 2012/05/16 11:45:08 wiz Exp $"); +__RCSID("$NetBSD: t_pipe2.c,v 1.7 2012/05/16 13:48:35 martin Exp $"); #include <atf-c.h> #include <fcntl.h> @@ -109,26 +109,27 @@ ATF_TC_HEAD(pipe2_consume, tc) ATF_TC_BODY(pipe2_consume, tc) { struct rlimit rl; - size_t i, n; + int err, filedes[2]; - getrlimit(RLIMIT_NOFILE, &rl); + err = fcntl(4, F_CLOSEM); + ATF_REQUIRE(err == 0); + + err = getrlimit(RLIMIT_NOFILE, &rl); + ATF_REQUIRE(err == 0); /* - * Each pipe2 call will allocate two filedescriptors, make sure we - * run into the limit... + * The heart of this test is to run against the number of open + * file descriptor limit in the middle of a pipe2() call - i.e. + * before the call only a single descriptor may be openend. */ - n = rl.rlim_cur/2+1; + rl.rlim_cur = 4; + err = setrlimit(RLIMIT_NOFILE, &rl); + ATF_REQUIRE(err == 0); /* * atf_tc_skip("The test case causes a panic (PR kern/46457)"); */ - - for (i = 0; i < n; i++) { - - int fildes[2]; - - if (pipe2(fildes, O_CLOEXEC) == -1) - return; - } + err = pipe2(filedes, O_CLOEXEC); + ATF_REQUIRE(err == -1); } ATF_TC(pipe2_nonblock);