Skip to contentSkip to conversation

manifest.py: Add tests to empty image

PATCH Milan Shah 1 participant 1 message Jan 18, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Milan Shah

author
#1 lore raw

Hi All,

This is a gentle reminder to review this patch.

Quoted 73 lines · Milan Shah

An oe-selftest test is added to ensure meta-selftest/recipes-test/images/test-empty-image.bb builds and is empty.

It is just a test that ensures that an empty image has no packages in it (i.e. nothing in the manifest)

See [YOCTO #8455] for details.

---
 meta/lib/oeqa/selftest/cases/manifest.py | 45 ++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
meta/lib/oeqa/selftest/cases/manifest.py +13 -0
index 5d13f35468..d9b8612628 100644
@@ -162,3 +162,48 @@ class VerifyManifest(OESelftestTestCase):
             self.logger.debug(logmsg)
             self.logger.info(msg)
             self.fail(logmsg)
+
+class VerifyEmptyManifest(OESelftestTestCase):
+    '''Tests for the manifest files of an empty image'''
+
+    @classmethod
+    def setUpClass(self):
+
+        # the setup should bitbake test-empty-image
+        super(VerifyEmptyManifest, self).setUpClass()
+        self.buildtarget = 'test-empty-image'
+        self.classname = 'VerifyEmptyManifest'
+
+        self.logger.info("{}: doing bitbake {} as a prerequisite of the

test"\

meta/lib/oeqa/selftest/cases/manifest.py +11 -0
+                .format(self.classname, self.buildtarget))
+        if bitbake(self.buildtarget).status:
+            self.logger.debug("{} Failed to setup {}"\
+                    .format(self.classname, self.buildtarget))
+            self.skipTest("{}: Cannot setup testing scenario"\
+                    .format(self.classname))
+
+
+    @classmethod
+    def test_image_manifest_empty(self):
+        '''Verifying the image manifest file is empty, this may take a

build'''

meta/lib/oeqa/selftest/cases/manifest.py +21 -1
+
+        # get manifest location based on target to query about
+        try:
+            mdir = VerifyManifest.get_dir_from_bb_var('DEPLOY_DIR_IMAGE',
+                                                self.buildtarget)
+            mfilename = get_bb_var("IMAGE_LINK_NAME", self.buildtarget)\
+                    + ".manifest"
+            mpath = os.path.join(mdir, mfilename)
+            self.logger.info("Manifest file path is: {}" .format(mpath))
+
+            if not os.path.isfile(mpath): raise IOError
+            if not os.path.getsize(mpath) == 0: raise OSError
+
+        except OSError:
+            raise self.skipTest("{}: manifest file is not empty"\
+                .format(self.classname))
+
+        except IOError:
+                msg = "{}: Error cannot find manifests in dir:\n{}"\
+                        .format(self.classname, mdir)
+                self.fail(msg)
--

2.25.1