1 /* 2 * Copyright © 2014 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 * 23 * Authors: 24 * Daniel Vetter <[email protected]> 25 * 26 */ 27 28 #include "igt.h" 29 #include <sys/types.h> 30 #include <sys/stat.h> 31 #include <sys/resource.h> 32 #include <sys/time.h> 33 #include <fcntl.h> 34 #include <limits.h> 35 36 igt_simple_main 37 { 38 int fd; 39 40 igt_require(igt_allow_unlimited_files()); 41 42 fd = drm_open_driver(DRIVER_INTEL); 43 44 igt_fork(n, 1) { 45 igt_drop_root(); 46 47 for (int i = 0; ; i++) { 48 int leak = open("/dev/null", O_RDONLY); 49 uint32_t handle; 50 51 if (__gem_create(fd, 4096, &handle) == 0) 52 gem_close(fd, handle); 53 54 if (leak < 0) { 55 igt_info("fd exhaustion after %i rounds.\n", i); 56 igt_assert(__gem_create(fd, 4096, 57 &handle) < 0); 58 break; 59 } 60 } 61 62 /* The child will free all the fds when exiting, so no need to 63 * clean up to mess to ensure that the parent can at least run 64 * the exit handlers. */ 65 } 66 67 igt_waitchildren(); 68 69 close(fd); 70 } 71