Files
StarPilot/openpilot/starpilot/flm/tests/test_worker_limits.py
T
firestar5683 6601a500e3 Fleet-learning analysis workers
Analyze closed recordings in bounded workers, validate static vehicle context, and retain actionable progress and failures. Honor finite and unlimited process resource limits.
2026-10-03 22:34:37 +00:00

22 lines
1.1 KiB
Python

from unittest.mock import patch
from openpilot.starpilot.flm import operation_worker as worker
def test_unlimited_linux_limits_get_finite_ceiling():
with patch.object(worker.sys, "platform", "linux"), patch.object(worker.os, "nice"), \
patch.object(worker.resource, "getrlimit", return_value=(-1, -1)), \
patch.object(worker.resource, "setrlimit") as set_limit:
worker._limits()
assert set_limit.call_args_list[0].args == (worker.resource.RLIMIT_AS, (worker.LINUX_ADDRESS_SPACE_BYTES, -1))
assert set_limit.call_args_list[1].args == (worker.resource.RLIMIT_CPU, (worker.LINUX_CPU_SECONDS, -1))
def test_existing_tighter_linux_limits_are_preserved():
with patch.object(worker.sys, "platform", "linux"), patch.object(worker.os, "nice"), \
patch.object(worker.resource, "getrlimit", side_effect=[(1000000, 2000000), (-1, 60)]), \
patch.object(worker.resource, "setrlimit") as set_limit:
worker._limits()
assert set_limit.call_args_list[0].args == (worker.resource.RLIMIT_AS, (1000000, 2000000))
assert set_limit.call_args_list[1].args == (worker.resource.RLIMIT_CPU, (60, 60))