Skip to contentSkip to conversation

oeqa/selftest/imagefeatures: improve test_hypervisor_fmts

PATCH New Ross Burton 1 participant 1 message Oct 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oeqa/selftest/imagefeatures: improve test_hypervisor_fmts

If this test fails then the output doesn't help in any meaningful way, so improve the test to output the unparsable JSON and display unexpected output.

---
 meta/lib/oeqa/selftest/cases/imagefeatures.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/cases/imagefeatures.py +6 -2
index 8213d63e375..cf2a42aab5c 100644
@@ -161,8 +161,12 @@ class ImageFeatures(OESelftestTestCase):
             sysroot = get_bb_var('STAGING_DIR_NATIVE', 'core-image-minimal')
             result = runCmd('qemu-img info --output json %s' % image_path,
                             native_sysroot=sysroot)
-            self.assertTrue(json.loads(result.output).get('format') == itype,
-                            msg="Could not parse '%s'" % result.output)
+            try:
+                data = json.loads(result.output)
+                self.assertEqual(data.get('format'), itype,
+                                 msg="Unexpected format in '%s'" % (result.output))
+            except json.decoder.JSONDecodeError:
+                self.fail("Could not parse '%ss'" % result.output)
 
     def test_long_chain_conversion(self):
         """
Signature · 1 line
2.20.1