From 8cf9d15b823d91d2a74fc83832fccca2219342c9 Mon Sep 17 00:00:00 2001 From: Ivan Metlushko Date: Wed, 24 Jun 2020 09:08:41 +0700 Subject: [PATCH 1/2] test: use pgrep for better compatibility pidof is not available on BSD system, while pgrep is present on BSD, Linux and macOS --- test/functional/test_runner.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 41f9bde183e..2fa48006f41 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -396,11 +396,12 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage= args = args or [] # Warn if bitcoind is already running - # pidof might fail or return an empty string if bitcoind is not running try: - if subprocess.check_output(["pidof", "bitcoind"]) not in [b'']: + # pgrep exits with code zero when one or more matching processes found + if subprocess.run(["pgrep", "-x", "bitcoind"], stdout=subprocess.DEVNULL).returncode == 0: print("%sWARNING!%s There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!" % (BOLD[1], BOLD[0])) - except (OSError, subprocess.SubprocessError): + except OSError: + # pgrep not supported pass # Warn if there is a cache directory From 3a7e79478ab41af7c53ce14d9fca9815bffe1f73 Mon Sep 17 00:00:00 2001 From: Ivan Metlushko Date: Wed, 24 Jun 2020 17:49:04 +0700 Subject: [PATCH 2/2] test: retry when write to a socket fails on macOS If the socket is tearing down macOS will return EPROTOTYPE instead of EPIPE. Because python doesn't handle this internally we have to do a workaround and retry the request. See https://bugs.python.org/issue33450 --- test/functional/test_framework/authproxy.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py index 05308931e3b..81eb8812345 100644 --- a/test/functional/test_framework/authproxy.py +++ b/test/functional/test_framework/authproxy.py @@ -115,6 +115,8 @@ class AuthServiceProxy(): except OSError as e: retry = ( '[WinError 10053] An established connection was aborted by the software in your host machine' in str(e)) + # Workaround for a bug on macOS. See https://bugs.python.org/issue33450 + retry = retry or ('[Errno 41] Protocol wrong type for socket' in str(e)) if retry: self.__conn.close() self.__conn.request(method, path, postdata, headers)