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