]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: respect RLIMIT_CORE hard limit
authorLiam Brady <lbrady@labn.net>
Tue, 29 Oct 2024 12:50:17 +0000 (08:50 -0400)
committerLiam Brady <lbrady@labn.net>
Tue, 29 Oct 2024 17:07:57 +0000 (13:07 -0400)
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 <lbrady@labn.net>
tests/topotests/conftest.py

index 44536e945efe49f61a2015d62e38975f37c8fba2..dafd19c283aacdbc2d8ce2f4e1254c3b9ac00bf5 100755 (executable)
@@ -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
     # ---------------------------------------------------