Skip to content

Commit

Permalink
fix test on bsd
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 28, 2024
1 parent 7e513f0 commit 4b1e7c9
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,34 +641,38 @@ def test_memory_maps(self):
ext_maps = p.memory_maps(grouped=False)

for nt in maps:
if not nt.path.startswith('['):
if QEMU_USER and "/bin/qemu-" in nt.path:
continue
if not (BSD and nt.path == "pvclock"):
assert os.path.isabs(nt.path), nt.path
if POSIX:
try:
assert os.path.exists(nt.path) or os.path.islink(
nt.path
), nt.path
except AssertionError:
if not LINUX:
raise
# https://github.com/giampaolo/psutil/issues/759
with open_text('/proc/self/smaps') as f:
data = f.read()
if f"{nt.path} (deleted)" not in data:
raise
elif '64' not in os.path.basename(nt.path):
# XXX - On Windows we have this strange behavior with
# 64 bit dlls: they are visible via explorer but cannot
# be accessed via os.stat() (wtf?).
try:
st = os.stat(nt.path)
except FileNotFoundError:
pass
else:
assert stat.S_ISREG(st.st_mode), nt.path
if nt.path.startswith('['):
continue
if BSD and nt.path == "pvclock":
continue
if QEMU_USER and "/bin/qemu-" in nt.path:
continue
assert os.path.isabs(nt.path), nt.path

if POSIX:
try:
assert os.path.exists(nt.path) or os.path.islink(
nt.path
), nt.path
except AssertionError:
if not LINUX:
raise
# https://github.com/giampaolo/psutil/issues/759
with open_text('/proc/self/smaps') as f:
data = f.read()
if f"{nt.path} (deleted)" not in data:
raise
elif '64' not in os.path.basename(nt.path):
# XXX - On Windows we have this strange behavior with
# 64 bit dlls: they are visible via explorer but cannot
# be accessed via os.stat() (wtf?).
try:
st = os.stat(nt.path)
except FileNotFoundError:
pass
else:
assert stat.S_ISREG(st.st_mode), nt.path

for nt in ext_maps:
for fname in nt._fields:
value = getattr(nt, fname)
Expand Down

0 comments on commit 4b1e7c9

Please sign in to comment.