From b4dc01b3ded25b68e08f82ae455e89c086385dc3 Mon Sep 17 00:00:00 2001 From: Liam Brady Date: Tue, 29 Oct 2024 08:50:17 -0400 Subject: [PATCH] tests: respect RLIMIT_CORE hard limit In the case that the RLIMIT_CORE hard limit cannot be raised on a system, do not fail due to an exception. Instead, attempt to increase the soft limit to as large a value as possible (e.g. to the set hard limit). Signed-off-by: Liam Brady --- tests/topotests/conftest.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/topotests/conftest.py b/tests/topotests/conftest.py index 44536e945efe..dafd19c283aa 100755 --- a/tests/topotests/conftest.py +++ b/tests/topotests/conftest.py @@ -522,9 +522,14 @@ def pytest_configure(config): is_xdist = True is_worker = True - resource.setrlimit( - resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY) - ) + try: + resource.setrlimit( + resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY) + ) + except ValueError: + # The hard limit cannot be raised. Raise the soft limit to previous hard limit + core_rlimits = resource.getrlimit(resource.RLIMIT_CORE) + resource.setrlimit(resource.RLIMIT_CORE, (core_rlimits[1], core_rlimits[1])) # ----------------------------------------------------- # Set some defaults for the pytest.ini [pytest] section # ---------------------------------------------------