From 93ae58c61ccf816d2c6b824e78022ee72bffea24 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Thu, 1 Aug 2024 07:09:02 -0400 Subject: [PATCH] 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 --- glance/tests/unit/common/test_format_inspector.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glance/tests/unit/common/test_format_inspector.py b/glance/tests/unit/common/test_format_inspector.py index fce9a1a973..308d1ce121 100644 --- a/glance/tests/unit/common/test_format_inspector.py +++ b/glance/tests/unit/common/test_format_inspector.py @@ -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)