Path: blob/main/tests/sys/kern/pipe/pipe_overcommit1_test.c
39488 views
/*-1* Copyright (C) 2005 Michael J. Silbersack <[email protected]>2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice(s), this list of conditions and the following disclaimer as9* the first lines of this file unmodified other than the possible10* addition of one or more copyright notices.11* 2. Redistributions in binary form must reproduce the above copyright12* notice(s), this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE18* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR21* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER22* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH25* DAMAGE.26*/2728#include <sys/param.h>29#include <stdio.h>30#include <stdlib.h>31#include <unistd.h>3233/*34* This program just allocates as many pipes as it can to ensure35* that using up all pipe memory doesn't cause a panic.36*/3738int39main(void)40{41int pipes[10000];42unsigned int i;4344for (i = 0; i < nitems(pipes); i++)45(void)pipe(&pipes[i]);46printf("PASS\n");4748exit(0);49}505152