diff options
| author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2017-02-21 14:33:08 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-01 23:27:10 +0000 |
| commit | 19d23814e449101f57c8f149c77ee8697c636f43 (patch) | |
| tree | d6e79252c334f3f71caff686423cfa52ff2327a5 /meta/lib/oeqa/selftest/wic.py | |
| parent | ef010c1a1d823870aba80152fc13c32c62e95146 (diff) | |
| download | poky-19d23814e449101f57c8f149c77ee8697c636f43.tar.gz | |
selftest: Optimize get_bb_var use
get_bb_var calls bitbake every time it is used and every call
would take about 7 seconds. There are tests that calls get_bb_var
several times when they can use get_bb_vars. Also there are tests
that calls it to fetch the same variable over and over again.
This will optimize the use of get_bb_var and get_bb_vars for a
little speed up in the tests.
[YOCTO #11037]
(From OE-Core rev: e53f86ba8aeb6d2e9eb259329001d27d62401072)
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/wic.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/wic.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index 0144d77a6f..b7fe52f45e 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py | |||
| @@ -29,7 +29,7 @@ from glob import glob | |||
| 29 | from shutil import rmtree | 29 | from shutil import rmtree |
| 30 | 30 | ||
| 31 | from oeqa.selftest.base import oeSelfTest | 31 | from oeqa.selftest.base import oeSelfTest |
| 32 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu | 32 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu |
| 33 | from oeqa.utils.decorators import testcase | 33 | from oeqa.utils.decorators import testcase |
| 34 | 34 | ||
| 35 | 35 | ||
| @@ -212,12 +212,11 @@ class Wic(oeSelfTest): | |||
| 212 | @testcase(1212) | 212 | @testcase(1212) |
| 213 | def test_build_artifacts(self): | 213 | def test_build_artifacts(self): |
| 214 | """Test wic create directdisk providing all artifacts.""" | 214 | """Test wic create directdisk providing all artifacts.""" |
| 215 | variables = (('STAGING_DATADIR', 'wic-tools'), | 215 | bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'], |
| 216 | ('RECIPE_SYSROOT_NATIVE', 'wic-tools'), | 216 | 'wic-tools') |
| 217 | ('DEPLOY_DIR_IMAGE', 'core-image-minimal'), | 217 | bb_vars.update(get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_ROOTFS'], |
| 218 | ('IMAGE_ROOTFS', 'core-image-minimal')) | 218 | 'core-image-minimal')) |
| 219 | bbvars = {var.lower(): get_bb_var(var, recipe) \ | 219 | bbvars = {key.lower(): value for key, value in bb_vars.items()} |
| 220 | for var, recipe in variables} | ||
| 221 | bbvars['resultdir'] = self.resultdir | 220 | bbvars['resultdir'] = self.resultdir |
| 222 | status = runCmd("wic create directdisk " | 221 | status = runCmd("wic create directdisk " |
| 223 | "-b %(staging_datadir)s " | 222 | "-b %(staging_datadir)s " |
| @@ -321,12 +320,11 @@ class Wic(oeSelfTest): | |||
| 321 | @testcase(1269) | 320 | @testcase(1269) |
| 322 | def test_rootfs_artifacts(self): | 321 | def test_rootfs_artifacts(self): |
| 323 | """Test usage of rootfs plugin with rootfs paths""" | 322 | """Test usage of rootfs plugin with rootfs paths""" |
| 324 | variables = (('STAGING_DATADIR', 'wic-tools'), | 323 | bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'], |
| 325 | ('RECIPE_SYSROOT_NATIVE', 'wic-tools'), | 324 | 'wic-tools') |
| 326 | ('DEPLOY_DIR_IMAGE', 'core-image-minimal'), | 325 | bb_vars.update(get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_ROOTFS'], |
| 327 | ('IMAGE_ROOTFS', 'core-image-minimal')) | 326 | 'core-image-minimal')) |
| 328 | bbvars = {var.lower(): get_bb_var(var, recipe) \ | 327 | bbvars = {key.lower(): value for key, value in bb_vars.items()} |
| 329 | for var, recipe in variables} | ||
| 330 | bbvars['wks'] = "directdisk-multi-rootfs" | 328 | bbvars['wks'] = "directdisk-multi-rootfs" |
| 331 | bbvars['resultdir'] = self.resultdir | 329 | bbvars['resultdir'] = self.resultdir |
| 332 | status = runCmd("wic create %(wks)s " | 330 | status = runCmd("wic create %(wks)s " |
| @@ -464,8 +462,9 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r | |||
| 464 | """Generate and obtain the path to <image>.env""" | 462 | """Generate and obtain the path to <image>.env""" |
| 465 | if image not in self.wicenv_cache: | 463 | if image not in self.wicenv_cache: |
| 466 | self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status) | 464 | self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status) |
| 467 | stdir = get_bb_var('STAGING_DIR', image) | 465 | bb_vars = get_bb_vars(['STAGING_DIR', 'MACHINE'], image) |
| 468 | machine = get_bb_var('MACHINE', image) | 466 | stdir = bb_vars['STAGING_DIR'] |
| 467 | machine = bb_vars['MACHINE'] | ||
| 469 | self.wicenv_cache[image] = os.path.join(stdir, machine, 'imgdata') | 468 | self.wicenv_cache[image] = os.path.join(stdir, machine, 'imgdata') |
| 470 | return self.wicenv_cache[image] | 469 | return self.wicenv_cache[image] |
| 471 | 470 | ||
| @@ -475,12 +474,13 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r | |||
| 475 | image = 'core-image-minimal' | 474 | image = 'core-image-minimal' |
| 476 | imgdatadir = self._get_image_env_path(image) | 475 | imgdatadir = self._get_image_env_path(image) |
| 477 | 476 | ||
| 478 | basename = get_bb_var('IMAGE_BASENAME', image) | 477 | bb_vars = get_bb_vars(['IMAGE_BASENAME', 'WICVARS'], image) |
| 478 | basename = bb_vars['IMAGE_BASENAME'] | ||
| 479 | self.assertEqual(basename, image) | 479 | self.assertEqual(basename, image) |
| 480 | path = os.path.join(imgdatadir, basename) + '.env' | 480 | path = os.path.join(imgdatadir, basename) + '.env' |
| 481 | self.assertTrue(os.path.isfile(path)) | 481 | self.assertTrue(os.path.isfile(path)) |
| 482 | 482 | ||
| 483 | wicvars = set(get_bb_var('WICVARS', image).split()) | 483 | wicvars = set(bb_vars['WICVARS'].split()) |
| 484 | # filter out optional variables | 484 | # filter out optional variables |
| 485 | wicvars = wicvars.difference(('DEPLOY_DIR_IMAGE', 'IMAGE_BOOT_FILES', | 485 | wicvars = wicvars.difference(('DEPLOY_DIR_IMAGE', 'IMAGE_BOOT_FILES', |
| 486 | 'INITRD', 'INITRD_LIVE', 'ISODIR')) | 486 | 'INITRD', 'INITRD_LIVE', 'ISODIR')) |
| @@ -522,8 +522,9 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r | |||
| 522 | self.assertEqual(0, bitbake('wic-image-minimal').status) | 522 | self.assertEqual(0, bitbake('wic-image-minimal').status) |
| 523 | self.remove_config(config) | 523 | self.remove_config(config) |
| 524 | 524 | ||
| 525 | deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE') | 525 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE']) |
| 526 | machine = get_bb_var('MACHINE') | 526 | deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] |
| 527 | machine = bb_vars['MACHINE'] | ||
| 527 | prefix = os.path.join(deploy_dir, 'wic-image-minimal-%s.' % machine) | 528 | prefix = os.path.join(deploy_dir, 'wic-image-minimal-%s.' % machine) |
| 528 | # check if we have result image and manifests symlinks | 529 | # check if we have result image and manifests symlinks |
| 529 | # pointing to existing files | 530 | # pointing to existing files |
