From 8bc80862603bd5d1b0dcb7a0472935215f167f09 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 4 Apr 2019 15:16:11 -0700 Subject: 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 Reviewed-by: Chris Wilson --- tests/i915/gem_concurrent_all.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'tests/i915/gem_concurrent_all.c') diff --git a/tests/i915/gem_concurrent_all.c b/tests/i915/gem_concurrent_all.c index 6049372d..3ddaab82 100644 --- a/tests/i915/gem_concurrent_all.c +++ b/tests/i915/gem_concurrent_all.c @@ -1678,26 +1678,6 @@ num_buffers(uint64_t max, return n; } -static bool allow_unlimited_files(void) -{ - struct rlimit rlim; - unsigned nofile_rlim = 1024*1024; - - FILE *file = fopen("/proc/sys/fs/file-max", "r"); - if (file) { - igt_assert(fscanf(file, "%u", &nofile_rlim) == 1); - igt_info("System limit for open files is %u\n", nofile_rlim); - fclose(file); - } - - if (getrlimit(RLIMIT_NOFILE, &rlim)) - return false; - - rlim.rlim_cur = nofile_rlim; - rlim.rlim_max = nofile_rlim; - return setrlimit(RLIMIT_NOFILE, &rlim) == 0; -} - igt_main { const struct access_mode modes[] = { @@ -1821,7 +1801,7 @@ igt_main all = true; igt_fixture { - allow_unlimited_files(); + igt_allow_unlimited_files(); fd = drm_open_driver(DRIVER_INTEL); igt_require_gem(fd); -- cgit v1.2.3