[OE-core] [PATCH] selftest/wic: Fix/cleanup class setup code

Richard Purdie richard.purdie at linuxfoundation.org
Thu Jul 26 12:30:55 UTC 2018


The code was using Wic instead of WicTestCase for image_is_ready and
native_sysroot which was confusing some tests. Fix image_is_ready.

For native_sysroot, convert the only user to just run the call itself
as there is no point in executing this for all the other tests which
don't use the value.

Whilst here, move _get_image_env_path to the base class alongside
its parent variabe and fix it to use WicTestCase.

Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/selftest/cases/wic.py | 31 ++++++++++++++---------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index cfee9d1e71d..36ee5e5a146 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -65,27 +65,24 @@ class WicTestCase(OESelftestTestCase):
     """Wic test class."""
 
     image_is_ready = False
-    native_sysroot = None
     wicenv_cache = {}
 
     def setUpLocal(self):
         """This code is executed before each test method."""
         self.resultdir = self.builddir + "/wic-tmp/"
         super(WicTestCase, self).setUpLocal()
-        if not self.native_sysroot:
-            Wic.native_sysroot = get_bb_var('STAGING_DIR_NATIVE', 'wic-tools')
 
         # Do this here instead of in setUpClass as the base setUp does some
         # clean up which can result in the native tools built earlier in
         # setUpClass being unavailable.
-        if not Wic.image_is_ready:
+        if not WicTestCase.image_is_ready:
             if get_bb_var('USE_NLS') == 'yes':
                 bitbake('wic-tools')
             else:
                 self.skipTest('wic-tools cannot be built due its (intltool|gettext)-native dependency and NLS disable')
 
             bitbake('core-image-minimal')
-            Wic.image_is_ready = True
+            WicTestCase.image_is_ready = True
 
         rmtree(self.resultdir, ignore_errors=True)
 
@@ -94,6 +91,16 @@ class WicTestCase(OESelftestTestCase):
         rmtree(self.resultdir, ignore_errors=True)
         super(WicTestCase, self).tearDownLocal()
 
+    def _get_image_env_path(self, image):
+        """Generate and obtain the path to <image>.env"""
+        if image not in WicTestCase.wicenv_cache:
+            self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status)
+            bb_vars = get_bb_vars(['STAGING_DIR', 'MACHINE'], image)
+            stdir = bb_vars['STAGING_DIR']
+            machine = bb_vars['MACHINE']
+            WicTestCase.wicenv_cache[image] = os.path.join(stdir, machine, 'imgdata')
+        return WicTestCase.wicenv_cache[image]
+
 class Wic(WicTestCase):
 
     @OETestID(1552)
@@ -534,16 +541,6 @@ class Wic2(WicTestCase):
         self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
         self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap")))
 
-    def _get_image_env_path(self, image):
-        """Generate and obtain the path to <image>.env"""
-        if image not in self.wicenv_cache:
-            self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status)
-            bb_vars = get_bb_vars(['STAGING_DIR', 'MACHINE'], image)
-            stdir = bb_vars['STAGING_DIR']
-            machine = bb_vars['MACHINE']
-            self.wicenv_cache[image] = os.path.join(stdir, machine, 'imgdata')
-        return self.wicenv_cache[image]
-
     @OETestID(1347)
     def test_image_env(self):
         """Test generation of <image>.env files."""
@@ -683,9 +680,11 @@ class Wic2(WicTestCase):
 
         wicimg = wicout[0]
 
+        native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools")
+
         # verify partition size with wic
         res = runCmd("parted -m %s unit mib p 2>/dev/null" % wicimg,
-                     native_sysroot=self.native_sysroot)
+                     native_sysroot=native_sysroot)
 
         # parse parted output which looks like this:
         # BYT;\n
-- 
2.17.1




More information about the Openembedded-core mailing list