gh-63016: fix failing mmap.flush tests on FreeBSD (#143230)

Fix `mmap.flush` tests introduced in 1af21ea320
where some flag combinations are not supported on FreeBSD.
This commit is contained in:
AN Long 2025-12-29 00:36:52 +09:00 committed by GitHub
parent 3ca1f2a370
commit c3bfe5d5aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1173,7 +1173,13 @@ def test_flush_parameters(self):
if hasattr(mmap, 'MS_INVALIDATE'):
m.flush(PAGESIZE * 2, flags=mmap.MS_INVALIDATE)
if hasattr(mmap, 'MS_ASYNC') and hasattr(mmap, 'MS_INVALIDATE'):
m.flush(0, PAGESIZE, flags=mmap.MS_ASYNC | mmap.MS_INVALIDATE)
if sys.platform == 'freebsd':
# FreeBSD doesn't support this combination
with self.assertRaises(OSError) as cm:
m.flush(0, PAGESIZE, flags=mmap.MS_ASYNC | mmap.MS_INVALIDATE)
self.assertEqual(cm.exception.errno, errno.EINVAL)
else:
m.flush(0, PAGESIZE, flags=mmap.MS_ASYNC | mmap.MS_INVALIDATE)
@unittest.skipUnless(sys.platform == 'linux', 'Linux only')
@support.requires_linux_version(5, 17, 0)