xref: /freebsd/tests/sys/kern/pipe/pipe_overcommit1_test.c (revision e30a620063b852f51e8955dd6f993680d5da6223)
1*e30a6200SEnji Cooper /*-
2*e30a6200SEnji Cooper  * Copyright (C) 2005 Michael J. Silbersack <silby@freebsd.org>
3*e30a6200SEnji Cooper  *  All rights reserved.
4*e30a6200SEnji Cooper  *
5*e30a6200SEnji Cooper  * Redistribution and use in source and binary forms, with or without
6*e30a6200SEnji Cooper  * modification, are permitted provided that the following conditions
7*e30a6200SEnji Cooper  * are met:
8*e30a6200SEnji Cooper  * 1. Redistributions of source code must retain the above copyright
9*e30a6200SEnji Cooper  *    notice(s), this list of conditions and the following disclaimer as
10*e30a6200SEnji Cooper  *    the first lines of this file unmodified other than the possible
11*e30a6200SEnji Cooper  *    addition of one or more copyright notices.
12*e30a6200SEnji Cooper  * 2. Redistributions in binary form must reproduce the above copyright
13*e30a6200SEnji Cooper  *    notice(s), this list of conditions and the following disclaimer in the
14*e30a6200SEnji Cooper  *    documentation and/or other materials provided with the distribution.
15*e30a6200SEnji Cooper  *
16*e30a6200SEnji Cooper  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17*e30a6200SEnji Cooper  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18*e30a6200SEnji Cooper  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19*e30a6200SEnji Cooper  * DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
20*e30a6200SEnji Cooper  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21*e30a6200SEnji Cooper  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22*e30a6200SEnji Cooper  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23*e30a6200SEnji Cooper  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*e30a6200SEnji Cooper  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*e30a6200SEnji Cooper  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26*e30a6200SEnji Cooper  * DAMAGE.
27*e30a6200SEnji Cooper  */
28*e30a6200SEnji Cooper 
29*e30a6200SEnji Cooper #include <sys/param.h>
30*e30a6200SEnji Cooper #include <stdio.h>
31*e30a6200SEnji Cooper #include <stdlib.h>
32*e30a6200SEnji Cooper #include <unistd.h>
33*e30a6200SEnji Cooper 
34*e30a6200SEnji Cooper /*
35*e30a6200SEnji Cooper  * $FreeBSD$
36*e30a6200SEnji Cooper  * This program just allocates as many pipes as it can to ensure
37*e30a6200SEnji Cooper  * that using up all pipe memory doesn't cause a panic.
38*e30a6200SEnji Cooper  */
39*e30a6200SEnji Cooper 
40*e30a6200SEnji Cooper int
41*e30a6200SEnji Cooper main(void)
42*e30a6200SEnji Cooper {
43*e30a6200SEnji Cooper 	int pipes[10000], returnval;
44*e30a6200SEnji Cooper 	unsigned int i;
45*e30a6200SEnji Cooper 
46*e30a6200SEnji Cooper 	for (i = 0; i < nitems(pipes); i++) {
47*e30a6200SEnji Cooper 		returnval = pipe(&pipes[i]);
48*e30a6200SEnji Cooper 	}
49*e30a6200SEnji Cooper 	printf("PASS\n");
50*e30a6200SEnji Cooper 
51*e30a6200SEnji Cooper 	exit(0);
52*e30a6200SEnji Cooper }
53