gh-37883: Fix test_resource.test_fsize_ismax for systems with limited file sizes

This commit is contained in:
Shamil Abdulaev 2025-11-18 13:24:43 +03:00
parent 630cd37bfa
commit 77c932b298
No known key found for this signature in database
GPG key ID: F9F7726024C005E7
2 changed files with 7 additions and 8 deletions

View file

@ -35,13 +35,10 @@ def test_args(self):
@unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE')
def test_fsize_ismax(self):
(cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE)
# RLIMIT_FSIZE should be RLIM_INFINITY, which will be a really big
# number on a platform with large file support. On these platforms,
# we need to test that the get/setrlimit functions properly convert
# the number to a C long long and that the conversion doesn't raise
# an error.
self.assertGreater(resource.RLIM_INFINITY, 0)
self.assertEqual(resource.RLIM_INFINITY, max)
# Test that the get/setrlimit functions properly handle large values
# for RLIMIT_FSIZE. On platforms with large file support, max may be
# RLIM_INFINITY, but on systems with file size restrictions, it may
# be a smaller value.
self.assertLessEqual(cur, max)
resource.setrlimit(resource.RLIMIT_FSIZE, (max, max))
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
@ -155,7 +152,6 @@ def expected(cur):
"setting RLIMIT_FSIZE is not supported on VxWorks")
@unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE')
def test_fsize_negative(self):
self.assertGreater(resource.RLIM_INFINITY, 0)
(cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE)
for value in -5, -2**31, -2**32-5, -2**63, -2**64-5, -2**1000:
with self.subTest(value=value):

View file

@ -0,0 +1,3 @@
Fix ``test_resource.test_fsize_ismax`` to handle systems where
``RLIMIT_FSIZE`` max limit is less than ``RLIM_INFINITY``. Patched by
Shamil Abdulaev.