From 08425980d6272227618b03392e192e9f85aec2ce Mon Sep 17 00:00:00 2001 From: Nehal J Wani Date: Sun, 24 Mar 2019 10:14:46 +0530 Subject: [PATCH] Use vmmap for reading memory maps on macOS Call to .memory_maps() fails on Azure pipelines with: Traceback (most recent call last): ... return cext.proc_memory_maps(self.pid) OSError: [Errno 22] Invalid argument Also, support for memory_maps() has been removed for macOS starting psutil-v5.6.x xref: https://github.com/giampaolo/psutil/issues/1291 --- recipe/run_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/recipe/run_test.py b/recipe/run_test.py index e9b6fec..42f5982 100644 --- a/recipe/run_test.py +++ b/recipe/run_test.py @@ -2,6 +2,7 @@ import re import psutil import platform +import subprocess libname = re.escape(os.environ['CONDA_PREFIX']) + '.*(libgmp.*.(dylib|so))' @@ -14,5 +15,10 @@ from Cryptodome.Math import _IntegerGMP as IntegerGMP # Make sure that gmp is indeed loaded in memory - p = psutil.Process(os.getpid()) - assert any(bool(re.match(libname, x.path)) for x in p.memory_maps()) + if psutil.MACOS: + vmmap_out = subprocess.check_output(['vmmap', '-w', str(os.getpid())]) + assert re.search(re.compile(libname), vmmap_out.decode('utf-8')) + + if psutil.LINUX: + p = psutil.Process(os.getpid()) + assert any(bool(re.match(libname, x.path)) for x in p.memory_maps())