1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 00:39:46 +00:00

selftest/wic: Fix/cleanup class setup code

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.

(From OE-Core rev: 3e83364ed7031d53f281216214b04c7acace844a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2018-07-26 12:03:46 +00:00
parent 1b56227d77
commit d9087c7c47
+15 -16
View File
@@ -65,27 +65,24 @@ class WicTestCase(OESelftestTestCase):
"""Wic test class.""" """Wic test class."""
image_is_ready = False image_is_ready = False
native_sysroot = None
wicenv_cache = {} wicenv_cache = {}
def setUpLocal(self): def setUpLocal(self):
"""This code is executed before each test method.""" """This code is executed before each test method."""
self.resultdir = self.builddir + "/wic-tmp/" self.resultdir = self.builddir + "/wic-tmp/"
super(WicTestCase, self).setUpLocal() 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 # 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 # clean up which can result in the native tools built earlier in
# setUpClass being unavailable. # setUpClass being unavailable.
if not Wic.image_is_ready: if not WicTestCase.image_is_ready:
if get_bb_var('USE_NLS') == 'yes': if get_bb_var('USE_NLS') == 'yes':
bitbake('wic-tools') bitbake('wic-tools')
else: else:
self.skipTest('wic-tools cannot be built due its (intltool|gettext)-native dependency and NLS disable') self.skipTest('wic-tools cannot be built due its (intltool|gettext)-native dependency and NLS disable')
bitbake('core-image-minimal') bitbake('core-image-minimal')
Wic.image_is_ready = True WicTestCase.image_is_ready = True
rmtree(self.resultdir, ignore_errors=True) rmtree(self.resultdir, ignore_errors=True)
@@ -94,6 +91,16 @@ class WicTestCase(OESelftestTestCase):
rmtree(self.resultdir, ignore_errors=True) rmtree(self.resultdir, ignore_errors=True)
super(WicTestCase, self).tearDownLocal() 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): class Wic(WicTestCase):
@OETestID(1552) @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")))
self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap"))) 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) @OETestID(1347)
def test_image_env(self): def test_image_env(self):
"""Test generation of <image>.env files.""" """Test generation of <image>.env files."""
@@ -683,9 +680,11 @@ class Wic2(WicTestCase):
wicimg = wicout[0] wicimg = wicout[0]
native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools")
# verify partition size with wic # verify partition size with wic
res = runCmd("parted -m %s unit mib p 2>/dev/null" % wicimg, 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: # parse parted output which looks like this:
# BYT;\n # BYT;\n