From 5151a11ab643cc2940377c0dc56376efb7d2ef59 Mon Sep 17 00:00:00 2001 From: AN Long Date: Sun, 28 Dec 2025 01:41:14 +0800 Subject: [PATCH 1/2] gh-63016: Skip some mmap tests on FreeBSD --- Lib/test/test_mmap.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index bc3593ce4ba992..587486cf5c9a08 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1173,7 +1173,9 @@ 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 + 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) From ba674d53ceca4388cd50ef25a8a9bd9a5044237b Mon Sep 17 00:00:00 2001 From: AN Long Date: Sun, 28 Dec 2025 02:11:57 +0800 Subject: [PATCH 2/2] Check the error on FreeBSD --- Lib/test/test_mmap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 587486cf5c9a08..48bf246cadd2f8 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1173,8 +1173,12 @@ 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'): - if sys.platform != 'freebsd': + 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')