Fix fallocate test on newer util-linux
Newer util-linux raises an error when calling fallocate with the -n option if the target file does not already exist. This is because the -n option directs it to retain the file's existing size. A non-existent file does not have an existing size. fallocate in older releases of util-linux creates a zero-sized file in this case. This results in _can_fallocate() always returning false, and therefore never preallocating. While this may reasonably be argued to be a regression in util-linux, the -n option doesn't make sense here anyway, so we remove it. Closes-Bug: #1543181 Change-Id: Ie96fa71e7d2641d30572b8eda5609dd3ca5b6708
This commit is contained in:
parent
eff769e6e7
commit
33749d2875
|
@ -115,7 +115,7 @@ class _ImageTestCase(object):
|
|||
image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE)
|
||||
|
||||
self.assertEqual(fake_processutils.fake_execute_get_log(),
|
||||
['fallocate -n -l 1 %s.fallocate_test' % self.PATH,
|
||||
['fallocate -l 1 %s.fallocate_test' % self.PATH,
|
||||
'fallocate -n -l %s %s' % (self.SIZE, self.PATH),
|
||||
'fallocate -n -l %s %s' % (self.SIZE, self.PATH)])
|
||||
|
||||
|
|
|
@ -264,9 +264,9 @@ class Image(object):
|
|||
"""
|
||||
can_fallocate = getattr(self.__class__, 'can_fallocate', None)
|
||||
if can_fallocate is None:
|
||||
_out, err = utils.trycmd('fallocate', '-n', '-l', '1',
|
||||
self.path + '.fallocate_test')
|
||||
fileutils.delete_if_exists(self.path + '.fallocate_test')
|
||||
test_path = self.path + '.fallocate_test'
|
||||
_out, err = utils.trycmd('fallocate', '-l', '1', test_path)
|
||||
fileutils.delete_if_exists(test_path)
|
||||
can_fallocate = not err
|
||||
self.__class__.can_fallocate = can_fallocate
|
||||
if not can_fallocate:
|
||||
|
|
Loading…
Reference in New Issue