From 8a982eea85406a85dc53d864409c4dc143a1c55a Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:54:38 +0100 Subject: [PATCH] qa: Add `skip_if_no_lsof_on_nonlinux` helper and use it where needed Some functional tests on non-Linux platforms rely on the `lsof` utility. However, we treat all other functional test dependencies, such as additional Python modules, as optional, and skip dependent tests if those are unavailable. This change makes `lsof` optional as well. --- test/functional/feature_bind_extra.py | 1 + test/functional/rpc_bind.py | 1 + test/functional/test_framework/test_framework.py | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/test/functional/feature_bind_extra.py b/test/functional/feature_bind_extra.py index 91f846d6f69..2b81e9210e0 100755 --- a/test/functional/feature_bind_extra.py +++ b/test/functional/feature_bind_extra.py @@ -33,6 +33,7 @@ class BindExtraTest(BitcoinTestFramework): def skip_test_if_missing_module(self): self.skip_if_platform_not_posix() + self.skip_if_no_lsof_on_nonlinux() def setup_network(self): loopback_ipv4 = addr_to_hex("127.0.0.1") diff --git a/test/functional/rpc_bind.py b/test/functional/rpc_bind.py index 517df5d9c3f..3caf23dd118 100755 --- a/test/functional/rpc_bind.py +++ b/test/functional/rpc_bind.py @@ -17,6 +17,7 @@ class RPCBindTest(BitcoinTestFramework): def skip_test_if_missing_module(self): self.skip_if_platform_not_posix() + self.skip_if_no_lsof_on_nonlinux() def setup_network(self): self.add_nodes(self.num_nodes, None) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 64dcbfd7ec5..a145614b860 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -1027,6 +1027,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): if platform.system() != "Linux": raise SkipTest("not on a Linux system") + def skip_if_no_lsof_on_nonlinux(self): + """Skip the running test if the lsof utility is not available on non-Linux platforms.""" + if sys.platform != "linux" and shutil.which("lsof") is None: + raise SkipTest("lsof not available") + def skip_if_platform_not_posix(self): """Skip the running test if we are not on a POSIX platform""" if os.name != 'posix':