Auto-detect qemu-img qed support for unit tests

This will let downstream distros with qemu-img versions
that don't support the qed format pass unit tests without
having to patch this test out.

Change-Id: I50907c90686366cab12be072b53c65b048b7c510
This commit is contained in:
Eric Harney 2024-08-01 07:09:02 -04:00
parent 7e75dc9e9a
commit 93ae58c61c

View File

@ -179,7 +179,14 @@ class TestFormatInspectors(test_utils.BaseTestCase):
# a local file.
self.assertLess(fmt.actual_size, file_size)
def qed_supported(self):
output = subprocess.check_output('qemu-img create --help', shell=True)
return b' qed ' in output
def test_qed_always_unsafe(self):
if not self.qed_supported():
raise self.skipException('qed format not supported by qemu-img')
img = self._create_img('qed', 10 * units.Mi)
fmt = format_inspector.get_inspector('qed').from_file(img)
self.assertTrue(fmt.format_match)