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':