Merge "Follow up punch_hole patch"
This commit is contained in:
commit
15ccb776d7
@ -975,14 +975,13 @@ class _LibcWrapper(object):
|
|||||||
# spurious AttributeError.
|
# spurious AttributeError.
|
||||||
func_handle = load_libc_function(
|
func_handle = load_libc_function(
|
||||||
func_name, fail_if_missing=True)
|
func_name, fail_if_missing=True)
|
||||||
|
self._func_handle = func_handle
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# We pass fail_if_missing=True to load_libc_function and
|
# We pass fail_if_missing=True to load_libc_function and
|
||||||
# then ignore the error. It's weird, but otherwise we have
|
# then ignore the error. It's weird, but otherwise we have
|
||||||
# to check if self._func_handle is noop_libc_function, and
|
# to check if self._func_handle is noop_libc_function, and
|
||||||
# that's even weirder.
|
# that's even weirder.
|
||||||
pass
|
pass
|
||||||
else:
|
|
||||||
self._func_handle = func_handle
|
|
||||||
self._loaded = True
|
self._loaded = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -7980,6 +7980,15 @@ class TestFallocate(unittest.TestCase):
|
|||||||
# work the way you'd expect with ctypes :-/
|
# work the way you'd expect with ctypes :-/
|
||||||
self.assertEqual(sys_fallocate_mock.mock_calls[0][1][2].value, 0)
|
self.assertEqual(sys_fallocate_mock.mock_calls[0][1][2].value, 0)
|
||||||
self.assertEqual(sys_fallocate_mock.mock_calls[0][1][3].value, 0)
|
self.assertEqual(sys_fallocate_mock.mock_calls[0][1][3].value, 0)
|
||||||
|
sys_fallocate_mock.reset_mock()
|
||||||
|
|
||||||
|
# negative size will be adjusted as 0
|
||||||
|
utils.fallocate(0, -1, 0)
|
||||||
|
self.assertEqual(
|
||||||
|
[mock.call(0, utils.FALLOC_FL_KEEP_SIZE, mock.ANY, mock.ANY)],
|
||||||
|
sys_fallocate_mock.mock_calls)
|
||||||
|
self.assertEqual(sys_fallocate_mock.mock_calls[0][1][2].value, 0)
|
||||||
|
self.assertEqual(sys_fallocate_mock.mock_calls[0][1][3].value, 0)
|
||||||
|
|
||||||
|
|
||||||
@patch.object(os, 'fstatvfs')
|
@patch.object(os, 'fstatvfs')
|
||||||
@ -8171,6 +8180,8 @@ class TestPunchHole(unittest.TestCase):
|
|||||||
|
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
utils.punch_hole(0, 1, -1)
|
utils.punch_hole(0, 1, -1)
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
utils.punch_hole(0, 1 << 64, 1)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
utils.punch_hole(0, -1, 1)
|
utils.punch_hole(0, -1, 1)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
|
Loading…
Reference in New Issue
Block a user