]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-63016: fix failing `mmap.flush` tests on FreeBSD (#143230)
authorAN Long <aisk@users.noreply.github.com>
Sun, 28 Dec 2025 15:36:52 +0000 (00:36 +0900)
committerGitHub <noreply@github.com>
Sun, 28 Dec 2025 15:36:52 +0000 (16:36 +0100)
Fix `mmap.flush` tests introduced in 1af21ea32043ad5bd4eaacd48a1718d4e0bef945
where some flag combinations are not supported on FreeBSD.

Lib/test/test_mmap.py

index bc3593ce4ba9923c3900ceffd71db3f07f00f70b..48bf246cadd2f8e094df4fa27a417921eb6bfecc 100644 (file)
@@ -1173,7 +1173,13 @@ class MmapTests(unittest.TestCase):
             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)