summaryrefslogtreecommitdiff
path: root/tests/i915/gem_fd_exhaustion.c
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2019-04-04 15:16:11 -0700
committerLucas De Marchi <lucas.demarchi@intel.com>2019-04-05 10:00:45 -0700
commit8bc80862603bd5d1b0dcb7a0472935215f167f09 (patch)
treef095731ce601ac3492add9a876cb5d108b22135e /tests/i915/gem_fd_exhaustion.c
parent019f892e5d1a0a9643cb726c47ce2d99c14b444f (diff)
lib: add igt_allow_unlimited_files()
Share the implementation to tweak the maximum number of open files. The version in tests/i915/gem_exec_reuse.c was a little bit different, but I don't think it needs to be because it would still return a failure if any of the calls to setrlimit() fail. So I'm using the other one. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/i915/gem_fd_exhaustion.c')
-rw-r--r--tests/i915/gem_fd_exhaustion.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/tests/i915/gem_fd_exhaustion.c b/tests/i915/gem_fd_exhaustion.c
index 559590b1..9704fa02 100644
--- a/tests/i915/gem_fd_exhaustion.c
+++ b/tests/i915/gem_fd_exhaustion.c
@@ -60,26 +60,6 @@ static int write_sysctl(const char *path, unsigned int val)
return -errno;
}
-static bool allow_unlimited_files(void)
-{
- unsigned int nofile_rlim = 1024*1024;
- struct rlimit rlim;
- unsigned int buf;
-
- buf = read_sysctl("/proc/sys/fs/file-max");
- if (buf > 0)
- nofile_rlim = buf;
- original_nr_open = read_sysctl("/proc/sys/fs/nr_open");
- igt_assert(write_sysctl("/proc/sys/fs/nr_open", nofile_rlim) == 0);
-
- if (getrlimit(RLIMIT_NOFILE, &rlim))
- return false;
-
- rlim.rlim_cur = nofile_rlim;
- rlim.rlim_max = nofile_rlim;
- return setrlimit(RLIMIT_NOFILE, &rlim) == 0;
-}
-
static void restore_original_sysctl(int sig)
{
if (original_nr_open > 0)
@@ -90,7 +70,7 @@ igt_simple_main
{
int fd;
- igt_require(allow_unlimited_files());
+ igt_require(igt_allow_unlimited_files());
fd = drm_open_driver(DRIVER_INTEL);