From 1a4b7ee28bf7413af6513fb45ad0d0736048f866 Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Sun, 16 Dec 2018 17:11:34 -0800 Subject: reset upstream subtrees to yocto 2.6 Reset the following subtrees on thud HEAD: poky: 87e3a9739d meta-openembedded: 6094ae18c8 meta-security: 31dc4e7532 meta-raspberrypi: a48743dc36 meta-xilinx: c42016e2e6 Also re-apply backports that didn't make it into thud: poky: 17726d0 systemd-systemctl-native: handle Install wildcards meta-openembedded: 4321a5d libtinyxml2: update to 7.0.1 042f0a3 libcereal: Add native and nativesdk classes e23284f libcereal: Allow empty package 030e8d4 rsyslog: curl-less build with fmhttp PACKAGECONFIG 179a1b9 gtest: update to 1.8.1 Squashed OpenBMC subtree compatibility updates: meta-aspeed: Brad Bishop (1): aspeed: add yocto 2.6 compatibility meta-ibm: Brad Bishop (1): ibm: prepare for yocto 2.6 meta-ingrasys: Brad Bishop (1): ingrasys: set layer compatibility to yocto 2.6 meta-openpower: Brad Bishop (1): openpower: set layer compatibility to yocto 2.6 meta-phosphor: Brad Bishop (3): phosphor: set layer compatibility to thud phosphor: libgpg-error: drop patches phosphor: react to fitimage artifact rename Ed Tanous (4): Dropbear: upgrade options for latest upgrade yocto2.6: update openssl options busybox: remove upstream watchdog patch systemd: Rebase CONFIG_CGROUP_BPF patch Change-Id: I7b1fe71cca880d0372a82d94b5fd785323e3a9e7 Signed-off-by: Brad Bishop --- poky/meta/lib/oeqa/selftest/cases/bblayers.py | 27 ++- poky/meta/lib/oeqa/selftest/cases/bbtests.py | 12 +- poky/meta/lib/oeqa/selftest/cases/buildoptions.py | 23 ++ poky/meta/lib/oeqa/selftest/cases/devtool.py | 180 +++++++++++----- poky/meta/lib/oeqa/selftest/cases/distrodata.py | 4 +- .../lib/oeqa/selftest/cases/efibootpartition.py | 1 - poky/meta/lib/oeqa/selftest/cases/fetch.py | 49 +++++ poky/meta/lib/oeqa/selftest/cases/image_typedep.py | 3 + poky/meta/lib/oeqa/selftest/cases/imagefeatures.py | 6 +- poky/meta/lib/oeqa/selftest/cases/lic_checksum.py | 3 +- poky/meta/lib/oeqa/selftest/cases/oelib/elf.py | 1 + poky/meta/lib/oeqa/selftest/cases/oelib/utils.py | 50 ++++- poky/meta/lib/oeqa/selftest/cases/oescripts.py | 17 +- poky/meta/lib/oeqa/selftest/cases/package.py | 67 +++++- poky/meta/lib/oeqa/selftest/cases/recipetool.py | 4 +- poky/meta/lib/oeqa/selftest/cases/runqemu.py | 21 +- poky/meta/lib/oeqa/selftest/cases/runtime_test.py | 9 +- poky/meta/lib/oeqa/selftest/cases/signing.py | 2 +- poky/meta/lib/oeqa/selftest/cases/sstatetests.py | 23 +- poky/meta/lib/oeqa/selftest/cases/wic.py | 239 +++++++++------------ 20 files changed, 516 insertions(+), 225 deletions(-) create mode 100644 poky/meta/lib/oeqa/selftest/cases/fetch.py (limited to 'poky/meta/lib/oeqa/selftest/cases') diff --git a/poky/meta/lib/oeqa/selftest/cases/bblayers.py b/poky/meta/lib/oeqa/selftest/cases/bblayers.py index 90a2249b08..447c54b7e6 100644 --- a/poky/meta/lib/oeqa/selftest/cases/bblayers.py +++ b/poky/meta/lib/oeqa/selftest/cases/bblayers.py @@ -2,7 +2,7 @@ import os import re import oeqa.utils.ftools as ftools -from oeqa.utils.commands import runCmd, get_bb_var +from oeqa.utils.commands import runCmd, get_bb_var, get_bb_vars from oeqa.selftest.case import OESelftestTestCase from oeqa.core.decorator.oeid import OETestID @@ -85,6 +85,31 @@ class BitbakeLayers(OESelftestTestCase): self.assertNotEqual(result.status, 0, 'bitbake-layers show-recipes -i nonexistentclass should have failed') self.assertIn('ERROR:', result.output) + def test_bitbakelayers_createlayer(self): + priority = 10 + layername = 'test-bitbakelayer-layercreate' + layerpath = os.path.join(self.builddir, layername) + self.assertFalse(os.path.exists(layerpath), '%s should not exist at this point in time' % layerpath) + result = runCmd('bitbake-layers create-layer --priority=%d %s' % (priority, layerpath)) + self.track_for_cleanup(layerpath) + result = runCmd('bitbake-layers add-layer %s' % layerpath) + self.add_command_to_tearDown('bitbake-layers remove-layer %s' % layerpath) + result = runCmd('bitbake-layers show-layers') + find_in_contents = re.search(re.escape(layername) + r'\s+' + re.escape(layerpath) + r'\s+' + re.escape(str(priority)), result.output) + self.assertTrue(find_in_contents, "%s not found in layers\n%s" % (layername, result.output)) + + layervars = ['BBFILE_PRIORITY', 'BBFILE_PATTERN', 'LAYERDEPENDS', 'LAYERSERIES_COMPAT'] + bb_vars = get_bb_vars(['BBFILE_COLLECTIONS'] + ['%s_%s' % (v, layername) for v in layervars]) + + for v in layervars: + varname = '%s_%s' % (v, layername) + self.assertIsNotNone(bb_vars[varname], "%s not found" % varname) + + find_in_contents = re.search(r'(^|\s)' + re.escape(layername) + r'($|\s)', bb_vars['BBFILE_COLLECTIONS']) + self.assertTrue(find_in_contents, "%s not in BBFILE_COLLECTIONS" % layername) + + self.assertEqual(bb_vars['BBFILE_PRIORITY_%s' % layername], str(priority), 'BBFILE_PRIORITY_%s != %d' % (layername, priority)) + def get_recipe_basename(self, recipe): recipe_file = "" result = runCmd("bitbake-layers show-recipes -f %s" % recipe) diff --git a/poky/meta/lib/oeqa/selftest/cases/bbtests.py b/poky/meta/lib/oeqa/selftest/cases/bbtests.py index 350614967c..005fdd0964 100644 --- a/poky/meta/lib/oeqa/selftest/cases/bbtests.py +++ b/poky/meta/lib/oeqa/selftest/cases/bbtests.py @@ -15,16 +15,26 @@ class BitbakeTests(OESelftestTestCase): return l @OETestID(789) + # Test bitbake can run from the /conf directory def test_run_bitbake_from_dir_1(self): os.chdir(os.path.join(self.builddir, 'conf')) self.assertEqual(bitbake('-e').status, 0, msg = "bitbake couldn't run from \"conf\" dir") @OETestID(790) + # Test bitbake can run from the 's parent directory def test_run_bitbake_from_dir_2(self): my_env = os.environ.copy() my_env['BBPATH'] = my_env['BUILDDIR'] os.chdir(os.path.dirname(os.environ['BUILDDIR'])) - self.assertEqual(bitbake('-e', env=my_env).status, 0, msg = "bitbake couldn't run from builddir") + self.assertEqual(bitbake('-e', env=my_env).status, 0, msg = "bitbake couldn't run from builddir's parent directory") + + # Test bitbake can run from some other random system location (we use /tmp/) + def test_run_bitbake_from_dir_3(self): + my_env = os.environ.copy() + my_env['BBPATH'] = my_env['BUILDDIR'] + os.chdir("/tmp/") + self.assertEqual(bitbake('-e', env=my_env).status, 0, msg = "bitbake couldn't run from /tmp/") + @OETestID(806) def test_event_handler(self): diff --git a/poky/meta/lib/oeqa/selftest/cases/buildoptions.py b/poky/meta/lib/oeqa/selftest/cases/buildoptions.py index 24597ac192..f234bac051 100644 --- a/poky/meta/lib/oeqa/selftest/cases/buildoptions.py +++ b/poky/meta/lib/oeqa/selftest/cases/buildoptions.py @@ -180,3 +180,26 @@ class ToolchainOptions(OESelftestTestCase): bitbake('gcc-runtime libgfortran') +class SourceMirroring(OESelftestTestCase): + # Can we download everything from the Yocto Sources Mirror over http only + def test_yocto_source_mirror(self): + self.write_config(""" +BB_ALLOWED_NETWORKS = "downloads.yoctoproject.org" +MIRRORS = "" +DL_DIR = "${TMPDIR}/test_downloads" +PREMIRRORS = "\\ + bzr://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + cvs://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + git://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + gitsm://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + hg://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + osc://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + p4://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + svn://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + ftp://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + http://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\ + https://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n" +""") + + bitbake("world --runall fetch") + diff --git a/poky/meta/lib/oeqa/selftest/cases/devtool.py b/poky/meta/lib/oeqa/selftest/cases/devtool.py index d5b6a46d49..9eb9badf84 100644 --- a/poky/meta/lib/oeqa/selftest/cases/devtool.py +++ b/poky/meta/lib/oeqa/selftest/cases/devtool.py @@ -11,9 +11,124 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer from oeqa.utils.commands import get_bb_vars, runqemu, get_test_layer from oeqa.core.decorator.oeid import OETestID +oldmetapath = None + +def setUpModule(): + import bb.utils + + global templayerdir + templayerdir = tempfile.mkdtemp(prefix='devtoolqa') + corecopydir = os.path.join(templayerdir, 'core-copy') + bblayers_conf = os.path.join(os.environ['BUILDDIR'], 'conf', 'bblayers.conf') + edited_layers = [] + + # We need to take a copy of the meta layer so we can modify it and not + # have any races against other tests that might be running in parallel + # however things like COREBASE mean that you can't just copy meta, you + # need the whole repository. + def bblayers_edit_cb(layerpath, canonical_layerpath): + global oldmetapath + if not canonical_layerpath.endswith('/'): + # This helps us match exactly when we're using this path later + canonical_layerpath += '/' + if not edited_layers and canonical_layerpath.endswith('/meta/'): + canonical_layerpath = os.path.realpath(canonical_layerpath) + '/' + edited_layers.append(layerpath) + oldmetapath = os.path.realpath(layerpath) + result = runCmd('git rev-parse --show-toplevel', cwd=canonical_layerpath) + oldreporoot = result.output.rstrip() + newmetapath = os.path.join(corecopydir, os.path.relpath(oldmetapath, oldreporoot)) + runCmd('git clone %s %s' % (oldreporoot, corecopydir), cwd=templayerdir) + # Now we need to copy any modified files + # You might ask "why not just copy the entire tree instead of + # cloning and doing this?" - well, the problem with that is + # TMPDIR or an equally large subdirectory might exist + # under COREBASE and we don't want to copy that, so we have + # to be selective. + result = runCmd('git status --porcelain', cwd=oldreporoot) + for line in result.output.splitlines(): + if line.startswith(' M ') or line.startswith('?? '): + relpth = line.split()[1] + pth = os.path.join(oldreporoot, relpth) + if pth.startswith(canonical_layerpath): + if relpth.endswith('/'): + destdir = os.path.join(corecopydir, relpth) + shutil.copytree(pth, destdir) + else: + destdir = os.path.join(corecopydir, os.path.dirname(relpth)) + bb.utils.mkdirhier(destdir) + shutil.copy2(pth, destdir) + return newmetapath + else: + return layerpath + bb.utils.edit_bblayers_conf(bblayers_conf, None, None, bblayers_edit_cb) + +def tearDownModule(): + if oldmetapath: + edited_layers = [] + def bblayers_edit_cb(layerpath, canonical_layerpath): + if not edited_layers and canonical_layerpath.endswith('/meta'): + edited_layers.append(layerpath) + return oldmetapath + else: + return layerpath + bblayers_conf = os.path.join(os.environ['BUILDDIR'], 'conf', 'bblayers.conf') + bb.utils.edit_bblayers_conf(bblayers_conf, None, None, bblayers_edit_cb) + shutil.rmtree(templayerdir) + class DevtoolBase(OESelftestTestCase): - buffer = True + @classmethod + def setUpClass(cls): + super(DevtoolBase, cls).setUpClass() + bb_vars = get_bb_vars(['TOPDIR', 'SSTATE_DIR']) + cls.original_sstate = bb_vars['SSTATE_DIR'] + cls.devtool_sstate = os.path.join(bb_vars['TOPDIR'], 'sstate_devtool') + cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate + cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n' + % cls.original_sstate) + + @classmethod + def tearDownClass(cls): + cls.logger.debug('Deleting devtool sstate cache on %s' % cls.devtool_sstate) + runCmd('rm -rf %s' % cls.devtool_sstate) + super(DevtoolBase, cls).tearDownClass() + + def setUp(self): + """Test case setup function""" + super(DevtoolBase, self).setUp() + self.workspacedir = os.path.join(self.builddir, 'workspace') + self.assertTrue(not os.path.exists(self.workspacedir), + 'This test cannot be run with a workspace directory ' + 'under the build directory') + self.append_config(self.sstate_conf) + + def _check_src_repo(self, repo_dir): + """Check srctree git repository""" + self.assertTrue(os.path.isdir(os.path.join(repo_dir, '.git')), + 'git repository for external source tree not found') + result = runCmd('git status --porcelain', cwd=repo_dir) + self.assertEqual(result.output.strip(), "", + 'Created git repo is not clean') + result = runCmd('git symbolic-ref HEAD', cwd=repo_dir) + self.assertEqual(result.output.strip(), "refs/heads/devtool", + 'Wrong branch in git repo') + + def _check_repo_status(self, repo_dir, expected_status): + """Check the worktree status of a repository""" + result = runCmd('git status . --porcelain', + cwd=repo_dir) + for line in result.output.splitlines(): + for ind, (f_status, fn_re) in enumerate(expected_status): + if re.match(fn_re, line[3:]): + if f_status != line[:2]: + self.fail('Unexpected status in line: %s' % line) + expected_status.pop(ind) + break + else: + self.fail('Unexpected modified file in line: %s' % line) + if expected_status: + self.fail('Missing file changes: %s' % expected_status) def _test_recipe_contents(self, recipefile, checkvars, checkinherits): with open(recipefile, 'r') as f: @@ -118,58 +233,6 @@ class DevtoolBase(OESelftestTestCase): class DevtoolTests(DevtoolBase): - @classmethod - def setUpClass(cls): - super(DevtoolTests, cls).setUpClass() - bb_vars = get_bb_vars(['TOPDIR', 'SSTATE_DIR']) - cls.original_sstate = bb_vars['SSTATE_DIR'] - cls.devtool_sstate = os.path.join(bb_vars['TOPDIR'], 'sstate_devtool') - cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate - cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n' - % cls.original_sstate) - - @classmethod - def tearDownClass(cls): - cls.logger.debug('Deleting devtool sstate cache on %s' % cls.devtool_sstate) - runCmd('rm -rf %s' % cls.devtool_sstate) - super(DevtoolTests, cls).tearDownClass() - - def setUp(self): - """Test case setup function""" - super(DevtoolTests, self).setUp() - self.workspacedir = os.path.join(self.builddir, 'workspace') - self.assertTrue(not os.path.exists(self.workspacedir), - 'This test cannot be run with a workspace directory ' - 'under the build directory') - self.append_config(self.sstate_conf) - - def _check_src_repo(self, repo_dir): - """Check srctree git repository""" - self.assertTrue(os.path.isdir(os.path.join(repo_dir, '.git')), - 'git repository for external source tree not found') - result = runCmd('git status --porcelain', cwd=repo_dir) - self.assertEqual(result.output.strip(), "", - 'Created git repo is not clean') - result = runCmd('git symbolic-ref HEAD', cwd=repo_dir) - self.assertEqual(result.output.strip(), "refs/heads/devtool", - 'Wrong branch in git repo') - - def _check_repo_status(self, repo_dir, expected_status): - """Check the worktree status of a repository""" - result = runCmd('git status . --porcelain', - cwd=repo_dir) - for line in result.output.splitlines(): - for ind, (f_status, fn_re) in enumerate(expected_status): - if re.match(fn_re, line[3:]): - if f_status != line[:2]: - self.fail('Unexpected status in line: %s' % line) - expected_status.pop(ind) - break - else: - self.fail('Unexpected modified file in line: %s' % line) - if expected_status: - self.fail('Missing file changes: %s' % expected_status) - @OETestID(1158) def test_create_workspace(self): # Check preconditions @@ -191,6 +254,8 @@ class DevtoolTests(DevtoolBase): self.assertNotIn(tempdir, result.output) self.assertIn(self.workspacedir, result.output) +class DevtoolAddTests(DevtoolBase): + @OETestID(1159) def test_devtool_add(self): # Fetch source @@ -235,6 +300,8 @@ class DevtoolTests(DevtoolBase): @OETestID(1423) def test_devtool_add_git_local(self): + # We need dbus built so that DEPENDS recognition works + bitbake('dbus') # Fetch source from a remote URL, but do it outside of devtool tempdir = tempfile.mkdtemp(prefix='devtoolqa') self.track_for_cleanup(tempdir) @@ -444,6 +511,8 @@ class DevtoolTests(DevtoolBase): checkvars['SRC_URI'] = url.replace(testver, '${PV}') self._test_recipe_contents(recipefile, checkvars, []) +class DevtoolModifyTests(DevtoolBase): + @OETestID(1164) def test_devtool_modify(self): import oe.path @@ -689,6 +758,7 @@ class DevtoolTests(DevtoolBase): self._check_src_repo(tempdir) # This is probably sufficient +class DevtoolUpdateTests(DevtoolBase): @OETestID(1169) def test_devtool_update_recipe(self): @@ -1105,6 +1175,8 @@ class DevtoolTests(DevtoolBase): expected_status = [] self._check_repo_status(os.path.dirname(recipefile), expected_status) +class DevtoolExtractTests(DevtoolBase): + @OETestID(1163) def test_devtool_extract(self): tempdir = tempfile.mkdtemp(prefix='devtoolqa') @@ -1274,6 +1346,8 @@ class DevtoolTests(DevtoolBase): if reqpkgs: self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs)) +class DevtoolUpgradeTests(DevtoolBase): + @OETestID(1367) def test_devtool_upgrade(self): # Check preconditions diff --git a/poky/meta/lib/oeqa/selftest/cases/distrodata.py b/poky/meta/lib/oeqa/selftest/cases/distrodata.py index 7b2800464c..e7b5e34956 100644 --- a/poky/meta/lib/oeqa/selftest/cases/distrodata.py +++ b/poky/meta/lib/oeqa/selftest/cases/distrodata.py @@ -21,7 +21,7 @@ class Distrodata(OESelftestTestCase): Summary: Test that upstream version checks do not regress Expected: Upstream version checks should succeed except for the recipes listed in the exception list. Product: oe-core - Author: Alexander Kanavin + Author: Alexander Kanavin """ checkpkg_result = open(os.path.join(get_bb_var("LOG_DIR"), "checkpkg.csv")).readlines()[1:] regressed_failures = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] if pkg_data[11] == 'UNKNOWN_BROKEN'] @@ -46,7 +46,7 @@ but their recipes claim otherwise by setting UPSTREAM_VERSION_UNKNOWN. Please re Summary: Test that oe-core recipes have a maintainer Expected: All oe-core recipes (except a few special static/testing ones) should have a maintainer listed in maintainers.inc file. Product: oe-core - Author: Alexander Kanavin + Author: Alexander Kanavin """ def is_exception(pkg): exceptions = ["packagegroup-", "initramfs-", "systemd-machine-units", "target-sdk-provides-dummy"] diff --git a/poky/meta/lib/oeqa/selftest/cases/efibootpartition.py b/poky/meta/lib/oeqa/selftest/cases/efibootpartition.py index 0c83256696..c6f39d5b16 100644 --- a/poky/meta/lib/oeqa/selftest/cases/efibootpartition.py +++ b/poky/meta/lib/oeqa/selftest/cases/efibootpartition.py @@ -11,7 +11,6 @@ from oeqa.utils.commands import bitbake, runqemu, get_bb_var class GenericEFITest(OESelftestTestCase): """EFI booting test class""" - buffer = True cmd_common = "runqemu nographic serial wic ovmf" efi_provider = "systemd-boot" image = "core-image-minimal" diff --git a/poky/meta/lib/oeqa/selftest/cases/fetch.py b/poky/meta/lib/oeqa/selftest/cases/fetch.py new file mode 100644 index 0000000000..4acc8cdcc8 --- /dev/null +++ b/poky/meta/lib/oeqa/selftest/cases/fetch.py @@ -0,0 +1,49 @@ +import oe.path +from oeqa.selftest.case import OESelftestTestCase +from oeqa.utils.commands import bitbake +from oeqa.core.decorator.oeid import OETestID + +class Fetch(OESelftestTestCase): + @OETestID(1058) + def test_git_mirrors(self): + """ + Verify that the git fetcher will fall back to the HTTP mirrors. The + recipe needs to be one that we have on the Yocto Project source mirror + and is hosted in git. + """ + + # TODO: mktempd instead of hardcoding + dldir = os.path.join(self.builddir, "download-git-mirrors") + self.track_for_cleanup(dldir) + + # No mirrors, should use git to fetch successfully + features = """ +DL_DIR = "%s" +MIRRORS_forcevariable = "" +PREMIRRORS_forcevariable = "" +""" % dldir + self.write_config(features) + oe.path.remove(dldir, recurse=True) + bitbake("dbus-wait -c fetch -f") + + # No mirrors and broken git, should fail + features = """ +DL_DIR = "%s" +GIT_PROXY_COMMAND = "false" +MIRRORS_forcevariable = "" +PREMIRRORS_forcevariable = "" +""" % dldir + self.write_config(features) + oe.path.remove(dldir, recurse=True) + with self.assertRaises(AssertionError): + bitbake("dbus-wait -c fetch -f") + + # Broken git but a specific mirror + features = """ +DL_DIR = "%s" +GIT_PROXY_COMMAND = "false" +MIRRORS_forcevariable = "git://.*/.* http://downloads.yoctoproject.org/mirror/sources/" +""" % dldir + self.write_config(features) + oe.path.remove(dldir, recurse=True) + bitbake("dbus-wait -c fetch -f") diff --git a/poky/meta/lib/oeqa/selftest/cases/image_typedep.py b/poky/meta/lib/oeqa/selftest/cases/image_typedep.py index e6788853a3..932c7f883d 100644 --- a/poky/meta/lib/oeqa/selftest/cases/image_typedep.py +++ b/poky/meta/lib/oeqa/selftest/cases/image_typedep.py @@ -29,11 +29,14 @@ inherit image # like CONVERSION_DEPENDS_bz2="somedep" result = bitbake('-e emptytest') + dep = None for line in result.output.split('\n'): if line.startswith('CONVERSION_DEPENDS_bz2'): dep = line.split('=')[1].strip('"') break + self.assertIsNotNone(dep, "CONVERSION_DEPENDS_bz2 dependency not found in bitbake -e output") + # Now get the dependency task list and check for the expected task # dependency bitbake('-g emptytest') diff --git a/poky/meta/lib/oeqa/selftest/cases/imagefeatures.py b/poky/meta/lib/oeqa/selftest/cases/imagefeatures.py index 09e0b20625..8c95432e00 100644 --- a/poky/meta/lib/oeqa/selftest/cases/imagefeatures.py +++ b/poky/meta/lib/oeqa/selftest/cases/imagefeatures.py @@ -10,8 +10,6 @@ class ImageFeatures(OESelftestTestCase): test_user = 'tester' root_user = 'root' - buffer = True - @OETestID(1107) def test_non_root_user_can_connect_via_ssh_without_password(self): """ @@ -23,7 +21,7 @@ class ImageFeatures(OESelftestTestCase): AutomatedBy: Daniel Istrate """ - features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' + features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password allow-root-login"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -49,7 +47,7 @@ class ImageFeatures(OESelftestTestCase): AutomatedBy: Daniel Istrate """ - features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' + features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password allow-root-login"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) diff --git a/poky/meta/lib/oeqa/selftest/cases/lic_checksum.py b/poky/meta/lib/oeqa/selftest/cases/lic_checksum.py index 37407157c1..f992b3736e 100644 --- a/poky/meta/lib/oeqa/selftest/cases/lic_checksum.py +++ b/poky/meta/lib/oeqa/selftest/cases/lic_checksum.py @@ -19,6 +19,8 @@ class LicenseTests(OESelftestTestCase): os.close(lic_file) self.track_for_cleanup(lic_path) + self.write_config("INHERIT_remove = \"report-error\"") + self.write_recipeinc('emptytest', """ INHIBIT_DEFAULT_DEPS = "1" LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" @@ -29,7 +31,6 @@ SRC_URI = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" with open(lic_path, "w") as f: f.write("data") - self.write_config("INHERIT_remove = \"report-error\"") result = bitbake(bitbake_cmd, ignore_status=True) if error_msg not in result.output: raise AssertionError(result.output) diff --git a/poky/meta/lib/oeqa/selftest/cases/oelib/elf.py b/poky/meta/lib/oeqa/selftest/cases/oelib/elf.py index 74ee6a11cc..15c03f4609 100644 --- a/poky/meta/lib/oeqa/selftest/cases/oelib/elf.py +++ b/poky/meta/lib/oeqa/selftest/cases/oelib/elf.py @@ -15,6 +15,7 @@ class TestElf(TestCase): self.assertEqual(oe.qa.elf_machine_to_string(0x32), "IA-64") self.assertEqual(oe.qa.elf_machine_to_string(0x3E), "x86-64") self.assertEqual(oe.qa.elf_machine_to_string(0xB7), "AArch64") + self.assertEqual(oe.qa.elf_machine_to_string(0xF7), "BPF") self.assertEqual(oe.qa.elf_machine_to_string(0x00), "Unknown (0)") self.assertEqual(oe.qa.elf_machine_to_string(0xDEADBEEF), "Unknown (3735928559)") diff --git a/poky/meta/lib/oeqa/selftest/cases/oelib/utils.py b/poky/meta/lib/oeqa/selftest/cases/oelib/utils.py index 9fb6c1576e..789c6f78d2 100644 --- a/poky/meta/lib/oeqa/selftest/cases/oelib/utils.py +++ b/poky/meta/lib/oeqa/selftest/cases/oelib/utils.py @@ -1,5 +1,8 @@ +import sys from unittest.case import TestCase -from oe.utils import packages_filter_out_system, trim_version +from contextlib import contextmanager +from io import StringIO +from oe.utils import packages_filter_out_system, trim_version, multiprocess_launch class TestPackagesFilterOutSystem(TestCase): def test_filter(self): @@ -49,3 +52,48 @@ class TestTrimVersion(TestCase): self.assertEqual(trim_version("1.2.3", 2), "1.2") self.assertEqual(trim_version("1.2.3", 3), "1.2.3") self.assertEqual(trim_version("1.2.3", 4), "1.2.3") + + +class TestMultiprocessLaunch(TestCase): + + def test_multiprocesslaunch(self): + import bb + + def testfunction(item, d): + if item == "2" or item == "1": + raise KeyError("Invalid number %s" % item) + return "Found %s" % item + + def dummyerror(msg): + print("ERROR: %s" % msg) + def dummyfatal(msg): + print("ERROR: %s" % msg) + raise bb.BBHandledException() + + @contextmanager + def captured_output(): + new_out, new_err = StringIO(), StringIO() + old_out, old_err = sys.stdout, sys.stderr + try: + sys.stdout, sys.stderr = new_out, new_err + yield sys.stdout, sys.stderr + finally: + sys.stdout, sys.stderr = old_out, old_err + + d = bb.data_smart.DataSmart() + bb.error = dummyerror + bb.fatal = dummyfatal + + # Assert the function returns the right results + result = multiprocess_launch(testfunction, ["3", "4", "5", "6"], d, extraargs=(d,)) + self.assertIn("Found 3", result) + self.assertIn("Found 4", result) + self.assertIn("Found 5", result) + self.assertIn("Found 6", result) + self.assertEqual(len(result), 4) + + # Assert the function prints exceptions + with captured_output() as (out, err): + self.assertRaises(bb.BBHandledException, multiprocess_launch, testfunction, ["1", "2", "3", "4", "5", "6"], d, extraargs=(d,)) + self.assertIn("KeyError: 'Invalid number 1'", out.getvalue()) + self.assertIn("KeyError: 'Invalid number 2'", out.getvalue()) diff --git a/poky/meta/lib/oeqa/selftest/cases/oescripts.py b/poky/meta/lib/oeqa/selftest/cases/oescripts.py index 1ee753763e..bcdc2d5ac0 100644 --- a/poky/meta/lib/oeqa/selftest/cases/oescripts.py +++ b/poky/meta/lib/oeqa/selftest/cases/oescripts.py @@ -10,6 +10,19 @@ class BuildhistoryDiffTests(BuildhistoryBase): target = 'xcursor-transparent-theme' self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True) + result = runCmd("oe-pkgdata-util read-value PKGV %s" % target) + pkgv = result.output.rstrip() result = runCmd("buildhistory-diff -p %s" % get_bb_var('BUILDHISTORY_DIR')) - expected_output = 'PR changed from "r1" to "r0"' - self.assertTrue(expected_output in result.output, msg="Did not find expected output: %s" % result.output) + expected_endlines = [ + "xcursor-transparent-theme-dev: RDEPENDS: removed \"xcursor-transparent-theme (['= %s-r1'])\", added \"xcursor-transparent-theme (['= %s-r0'])\"" % (pkgv, pkgv), + "xcursor-transparent-theme-staticdev: RDEPENDS: removed \"xcursor-transparent-theme-dev (['= %s-r1'])\", added \"xcursor-transparent-theme-dev (['= %s-r0'])\"" % (pkgv, pkgv) + ] + for line in result.output.splitlines(): + for el in expected_endlines: + if line.endswith(el): + expected_endlines.remove(el) + break + else: + self.fail('Unexpected line:\n%s\nExpected line endings:\n %s' % (line, '\n '.join(expected_endlines))) + if expected_endlines: + self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines)) diff --git a/poky/meta/lib/oeqa/selftest/cases/package.py b/poky/meta/lib/oeqa/selftest/cases/package.py index 169698f780..0a88dc25b3 100644 --- a/poky/meta/lib/oeqa/selftest/cases/package.py +++ b/poky/meta/lib/oeqa/selftest/cases/package.py @@ -1,6 +1,7 @@ from oeqa.selftest.case import OESelftestTestCase from oeqa.core.decorator.oeid import OETestID -from oeqa.utils.commands import bitbake, get_bb_vars +from oeqa.utils.commands import bitbake, get_bb_vars, get_bb_var, runqemu +import stat import subprocess, os import oe.path @@ -29,7 +30,7 @@ class VersionOrdering(OESelftestTestCase): cls.bindir = oe.path.join(cls.staging, vars["bindir_native"]) cls.libdir = oe.path.join(cls.staging, vars["libdir_native"]) - def setUp(self): + def setUpLocal(self): # Just for convenience self.staging = type(self).staging self.bindir = type(self).bindir @@ -84,3 +85,65 @@ class VersionOrdering(OESelftestTestCase): status = subprocess.call(command, env=env) self.assertIn(status, (99, 100, 101)) self.assertEqual(status - 100, sort, "%s %s (%d) failed" % (ver1, ver2, sort)) + +class PackageTests(OESelftestTestCase): + # Verify that a recipe which sets up hardlink files has those preserved into split packages + # Also test file sparseness is preserved + def test_preserve_sparse_hardlinks(self): + bitbake("selftest-hardlink -c package") + + dest = get_bb_var('PKGDEST', 'selftest-hardlink') + bindir = get_bb_var('bindir', 'selftest-hardlink') + + def checkfiles(): + # Recipe creates 4 hardlinked files, there is a copy in package/ and a copy in packages-split/ + # so expect 8 in total. + self.assertEqual(os.stat(dest + "/selftest-hardlink" + bindir + "/hello1").st_nlink, 8) + + # Test a sparse file remains sparse + sparsestat = os.stat(dest + "/selftest-hardlink" + bindir + "/sparsetest") + self.assertEqual(sparsestat.st_blocks, 0) + self.assertEqual(sparsestat.st_size, 1048576) + + checkfiles() + + # Clean and reinstall so its now definitely from sstate, then retest. + bitbake("selftest-hardlink -c clean") + bitbake("selftest-hardlink -c package") + + checkfiles() + + # Verify gdb to read symbols from separated debug hardlink file correctly + def test_gdb_hardlink_debug(self): + features = 'IMAGE_INSTALL_append = " selftest-hardlink"\n' + features += 'IMAGE_INSTALL_append = " selftest-hardlink-dbg"\n' + features += 'IMAGE_INSTALL_append = " selftest-hardlink-gdb"\n' + self.write_config(features) + bitbake("core-image-minimal") + + def gdbtest(qemu, binary): + """ + Check that gdb ``binary`` to read symbols from separated debug file + """ + self.logger.info("gdbtest %s" % binary) + status, output = qemu.run_serial('/usr/bin/gdb.sh %s' % binary, timeout=60) + for l in output.split('\n'): + # Check debugging symbols exists + if '(no debugging symbols found)' in l: + self.logger.error("No debugging symbols found. GDB result:\n%s" % output) + return False + + # Check debugging symbols works correctly + elif "Breakpoint 1, main () at hello.c:4" in l: + return True + + self.logger.error("GDB result:\n%s: %s" % output) + return False + + with runqemu('core-image-minimal') as qemu: + for binary in ['/usr/bin/hello1', + '/usr/bin/hello2', + '/usr/libexec/hello3', + '/usr/libexec/hello4']: + if not gdbtest(qemu, binary): + self.fail('GDB %s failed' % binary) diff --git a/poky/meta/lib/oeqa/selftest/cases/recipetool.py b/poky/meta/lib/oeqa/selftest/cases/recipetool.py index 437eb2a733..06f980e1b0 100644 --- a/poky/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/poky/meta/lib/oeqa/selftest/cases/recipetool.py @@ -427,6 +427,8 @@ class RecipetoolTests(RecipetoolBase): @OETestID(1418) def test_recipetool_create_cmake(self): + bitbake('-c packagedata gtk+') + # Try adding a recipe temprecipe = os.path.join(self.tempdir, 'recipe') os.makedirs(temprecipe) @@ -439,7 +441,7 @@ class RecipetoolTests(RecipetoolBase): checkvars['SRC_URI'] = 'http://downloads.yoctoproject.org/mirror/sources/navit-${PV}.tar.gz' checkvars['SRC_URI[md5sum]'] = '242f398e979a6b8c0f3c802b63435b68' checkvars['SRC_URI[sha256sum]'] = '13353481d7fc01a4f64e385dda460b51496366bba0fd2cc85a89a0747910e94d' - checkvars['DEPENDS'] = set(['freetype', 'zlib', 'openssl', 'glib-2.0', 'virtual/libgl', 'virtual/egl', 'gtk+', 'libpng', 'libsdl', 'freeglut', 'dbus-glib']) + checkvars['DEPENDS'] = set(['freetype', 'zlib', 'openssl', 'glib-2.0', 'virtual/libgl', 'virtual/egl', 'gtk+', 'libpng', 'libsdl', 'freeglut', 'dbus-glib', 'fribidi']) inherits = ['cmake', 'python-dir', 'gettext', 'pkgconfig'] self._test_recipe_contents(recipefile, checkvars, inherits) diff --git a/poky/meta/lib/oeqa/selftest/cases/runqemu.py b/poky/meta/lib/oeqa/selftest/cases/runqemu.py index a758aafbdd..4e35bb97e3 100644 --- a/poky/meta/lib/oeqa/selftest/cases/runqemu.py +++ b/poky/meta/lib/oeqa/selftest/cases/runqemu.py @@ -14,8 +14,6 @@ class RunqemuTests(OESelftestTestCase): image_is_ready = False deploy_dir_image = '' - # We only want to print runqemu stdout/stderr if there is a test case failure - buffer = True def setUpLocal(self): super(RunqemuTests, self).setUpLocal() @@ -176,14 +174,17 @@ class QemuTest(OESelftestTestCase): # when qemu was shutdown by the above shutdown command qemu.runner.stop_thread() time_track = 0 - while True: - is_alive = qemu.check() - if not is_alive: - return True - if time_track > timeout: - return False - time.sleep(1) - time_track += 1 + try: + while True: + is_alive = qemu.check() + if not is_alive: + return True + if time_track > timeout: + return False + time.sleep(1) + time_track += 1 + except SystemExit: + return True def test_qemu_can_shutdown(self): self.assertExists(self.qemuboot_conf) diff --git a/poky/meta/lib/oeqa/selftest/cases/runtime_test.py b/poky/meta/lib/oeqa/selftest/cases/runtime_test.py index 146daf80b3..906e460d4f 100644 --- a/poky/meta/lib/oeqa/selftest/cases/runtime_test.py +++ b/poky/meta/lib/oeqa/selftest/cases/runtime_test.py @@ -122,6 +122,7 @@ class TestImage(OESelftestTestCase): self.skipTest('core-image-full-cmdline not buildable for poky-tiny') features = 'INHERIT += "testimage"\n' + features += 'IMAGE_INSTALL_append = " libssl"\n' features += 'TEST_SUITES = "ping ssh selftest"\n' self.write_config(features) @@ -135,7 +136,7 @@ class TestImage(OESelftestTestCase): Summary: Check package feeds functionality for dnf Expected: 1. Check that remote package feeds can be accessed Product: oe-core - Author: Alexander Kanavin + Author: Alexander Kanavin """ if get_bb_var('DISTRO') == 'poky-tiny': self.skipTest('core-image-full-cmdline not buildable for poky-tiny') @@ -233,7 +234,7 @@ class Postinst(OESelftestTestCase): Expected: The scriptlet failure is properly reported. The file that is created after the error in the scriptlet is not present. Product: oe-core - Author: Alexander Kanavin + Author: Alexander Kanavin """ import oe.path @@ -251,8 +252,8 @@ class Postinst(OESelftestTestCase): features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-rootfs-failing"\n' features += 'PACKAGE_CLASSES = "%s"\n' % classes self.write_config(features) - bb_result = bitbake('core-image-minimal') - self.assertGreaterEqual(bb_result.output.find("Intentionally failing postinstall scriptlets of ['postinst-rootfs-failing'] to defer them to first boot is deprecated."), 0, + bb_result = bitbake('core-image-minimal', ignore_status=True) + self.assertGreaterEqual(bb_result.output.find("Postinstall scriptlets of ['postinst-rootfs-failing'] have failed."), 0, "Warning about a failed scriptlet not found in bitbake output: %s" %(bb_result.output)) self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs-before-failure")), diff --git a/poky/meta/lib/oeqa/selftest/cases/signing.py b/poky/meta/lib/oeqa/selftest/cases/signing.py index 0edaf400bb..4fa99acbc9 100644 --- a/poky/meta/lib/oeqa/selftest/cases/signing.py +++ b/poky/meta/lib/oeqa/selftest/cases/signing.py @@ -59,7 +59,7 @@ class Signing(OESelftestTestCase): Expected: Images can be created from signed packages Product: oe-core Author: Daniel Istrate - Author: Alexander Kanavin + Author: Alexander Kanavin AutomatedBy: Daniel Istrate """ import oe.packagedata diff --git a/poky/meta/lib/oeqa/selftest/cases/sstatetests.py b/poky/meta/lib/oeqa/selftest/cases/sstatetests.py index 7b008e409f..077d6e5374 100644 --- a/poky/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/poky/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -262,6 +262,7 @@ class SStateTests(SStateBase): self.write_config(""" MACHINE = "qemux86" TMPDIR = "${TOPDIR}/tmp-sstatesamehash" +TCLIBCAPPEND = "" BUILD_ARCH = "x86_64" BUILD_OS = "linux" SDKMACHINE = "x86_64" @@ -272,6 +273,7 @@ PACKAGE_CLASSES = "package_rpm package_ipk package_deb" self.write_config(""" MACHINE = "qemux86" TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" +TCLIBCAPPEND = "" BUILD_ARCH = "i686" BUILD_OS = "linux" SDKMACHINE = "i686" @@ -307,12 +309,14 @@ PACKAGE_CLASSES = "package_rpm package_ipk package_deb" self.write_config(""" TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" +TCLIBCAPPEND = \"\" NATIVELSBSTRING = \"DistroA\" """) self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") bitbake("core-image-sato -S none") self.write_config(""" TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" +TCLIBCAPPEND = \"\" NATIVELSBSTRING = \"DistroB\" """) self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") @@ -340,25 +344,25 @@ NATIVELSBSTRING = \"DistroB\" configA = """ TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" +TCLIBCAPPEND = \"\" MACHINE = \"qemux86-64\" """ configB = """ TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" +TCLIBCAPPEND = \"\" MACHINE = \"qemuarm\" """ self.sstate_allarch_samesigs(configA, configB) @OETestID(1645) - def test_sstate_allarch_samesigs_multilib(self): + def test_sstate_nativesdk_samesigs_multilib(self): """ - The sstate checksums of allarch multilib packages should be independent of whichever - MACHINE is set. Check this using bitbake -S. - Also, rather than duplicate the test, check nativesdk stamps are the same between - the two MACHINE values. + check nativesdk stamps are the same between the two MACHINE values. """ configA = """ TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" +TCLIBCAPPEND = \"\" MACHINE = \"qemux86-64\" require conf/multilib.conf MULTILIBS = \"multilib:lib32\" @@ -366,6 +370,7 @@ DEFAULTTUNE_virtclass-multilib-lib32 = \"x86\" """ configB = """ TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" +TCLIBCAPPEND = \"\" MACHINE = \"qemuarm\" require conf/multilib.conf MULTILIBS = \"\" @@ -392,10 +397,6 @@ MULTILIBS = \"\" (_, task, _, shash) = name.rsplit(".", 3) f[os.path.join(os.path.basename(root), task)] = shash return f - files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/all" + self.target_vendor + "-" + self.target_os) - files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/all" + self.target_vendor + "-" + self.target_os) - self.maxDiff = None - self.assertEqual(files1, files2) nativesdkdir = os.path.basename(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/*-nativesdk*-linux")[0]) @@ -414,6 +415,7 @@ MULTILIBS = \"\" self.write_config(""" TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" +TCLIBCAPPEND = \"\" MACHINE = \"qemux86\" require conf/multilib.conf MULTILIBS = "multilib:lib32" @@ -423,6 +425,7 @@ DEFAULTTUNE_virtclass-multilib-lib32 = "x86" bitbake("world meta-toolchain -S none") self.write_config(""" TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" +TCLIBCAPPEND = \"\" MACHINE = \"qemux86copy\" require conf/multilib.conf MULTILIBS = "multilib:lib32" @@ -458,6 +461,7 @@ DEFAULTTUNE_virtclass-multilib-lib32 = "x86" self.write_config(""" TMPDIR = "${TOPDIR}/tmp-sstatesamehash" +TCLIBCAPPEND = "" BB_NUMBER_THREADS = "${@oe.utils.cpu_count()}" PARALLEL_MAKE = "-j 1" DL_DIR = "${TOPDIR}/download1" @@ -471,6 +475,7 @@ http_proxy = "" bitbake("world meta-toolchain -S none") self.write_config(""" TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" +TCLIBCAPPEND = "" BB_NUMBER_THREADS = "${@oe.utils.cpu_count()+1}" PARALLEL_MAKE = "-j 2" DL_DIR = "${TOPDIR}/download2" diff --git a/poky/meta/lib/oeqa/selftest/cases/wic.py b/poky/meta/lib/oeqa/selftest/cases/wic.py index baf3af6ebf..36ee5e5a14 100644 --- a/poky/meta/lib/oeqa/selftest/cases/wic.py +++ b/poky/meta/lib/oeqa/selftest/cases/wic.py @@ -61,94 +61,103 @@ def only_for_arch(archs, image='core-image-minimal'): return wrapper -class Wic(OESelftestTestCase): +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(Wic, self).setUpLocal() - if not self.native_sysroot: - Wic.native_sysroot = get_bb_var('STAGING_DIR_NATIVE', 'wic-tools') + super(WicTestCase, self).setUpLocal() # 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) def tearDownLocal(self): """Remove resultdir as it may contain images.""" rmtree(self.resultdir, ignore_errors=True) - super(Wic, self).tearDownLocal() + super(WicTestCase, self).tearDownLocal() + + def _get_image_env_path(self, image): + """Generate and obtain the path to .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) def test_version(self): """Test wic --version""" - self.assertEqual(0, runCmd('wic --version').status) + runCmd('wic --version') @OETestID(1208) def test_help(self): """Test wic --help and wic -h""" - self.assertEqual(0, runCmd('wic --help').status) - self.assertEqual(0, runCmd('wic -h').status) + runCmd('wic --help') + runCmd('wic -h') @OETestID(1209) def test_createhelp(self): """Test wic create --help""" - self.assertEqual(0, runCmd('wic create --help').status) + runCmd('wic create --help') @OETestID(1210) def test_listhelp(self): """Test wic list --help""" - self.assertEqual(0, runCmd('wic list --help').status) + runCmd('wic list --help') @OETestID(1553) def test_help_create(self): """Test wic help create""" - self.assertEqual(0, runCmd('wic help create').status) + runCmd('wic help create') @OETestID(1554) def test_help_list(self): """Test wic help list""" - self.assertEqual(0, runCmd('wic help list').status) + runCmd('wic help list') @OETestID(1215) def test_help_overview(self): """Test wic help overview""" - self.assertEqual(0, runCmd('wic help overview').status) + runCmd('wic help overview') @OETestID(1216) def test_help_plugins(self): """Test wic help plugins""" - self.assertEqual(0, runCmd('wic help plugins').status) + runCmd('wic help plugins') @OETestID(1217) def test_help_kickstart(self): """Test wic help kickstart""" - self.assertEqual(0, runCmd('wic help kickstart').status) + runCmd('wic help kickstart') @OETestID(1555) def test_list_images(self): """Test wic list images""" - self.assertEqual(0, runCmd('wic list images').status) + runCmd('wic list images') @OETestID(1556) def test_list_source_plugins(self): """Test wic list source-plugins""" - self.assertEqual(0, runCmd('wic list source-plugins').status) + runCmd('wic list source-plugins') @OETestID(1557) def test_listed_images_help(self): @@ -156,7 +165,7 @@ class Wic(OESelftestTestCase): output = runCmd('wic list images').output imagelist = [line.split()[0] for line in output.splitlines()] for image in imagelist: - self.assertEqual(0, runCmd('wic list %s help' % image).status) + runCmd('wic list %s help' % image) @OETestID(1213) def test_unsupported_subcommand(self): @@ -172,7 +181,7 @@ class Wic(OESelftestTestCase): def test_build_image_name(self): """Test wic create wictestdisk --image-name=core-image-minimal""" cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) @OETestID(1157) @@ -180,7 +189,7 @@ class Wic(OESelftestTestCase): def test_gpt_image(self): """Test creation of core-image-minimal with gpt table and UUID boot""" cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) @OETestID(1346) @@ -194,7 +203,7 @@ class Wic(OESelftestTestCase): bitbake('core-image-minimal core-image-minimal-initramfs') self.remove_config(config) cmd = "wic create mkhybridiso --image-name core-image-minimal -o %s" % self.resultdir - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.direct"))) self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso"))) @@ -203,7 +212,7 @@ class Wic(OESelftestTestCase): def test_qemux86_directdisk(self): """Test creation of qemux-86-directdisk image""" cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct"))) @OETestID(1350) @@ -211,7 +220,7 @@ class Wic(OESelftestTestCase): def test_mkefidisk(self): """Test creation of mkefidisk image""" cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct"))) @OETestID(1385) @@ -223,7 +232,7 @@ class Wic(OESelftestTestCase): bitbake('core-image-minimal') self.remove_config(config) cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct"))) @OETestID(1560) @@ -235,7 +244,7 @@ class Wic(OESelftestTestCase): bitbake('core-image-minimal') self.remove_config(config) cmd = "wic create systemd-bootdisk -e core-image-minimal -o %s" % self.resultdir - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "systemd-bootdisk-*direct"))) @OETestID(1561) @@ -244,7 +253,7 @@ class Wic(OESelftestTestCase): cmd = "wic create sdimage-bootpart -e core-image-minimal -o %s" % self.resultdir kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal') self.write_config('IMAGE_BOOT_FILES = "%s"\n' % kimgtype) - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) @OETestID(1562) @@ -258,7 +267,7 @@ class Wic(OESelftestTestCase): bitbake('core-image-minimal') self.remove_config(config) cmd = "wic create directdisk -e core-image-minimal" - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.assertEqual(1, len(glob("directdisk-*.direct"))) @OETestID(1212) @@ -271,37 +280,36 @@ class Wic(OESelftestTestCase): 'core-image-minimal')) bbvars = {key.lower(): value for key, value in bb_vars.items()} bbvars['resultdir'] = self.resultdir - status = runCmd("wic create directdisk " + runCmd("wic create directdisk " "-b %(staging_datadir)s " "-k %(deploy_dir_image)s " "-n %(recipe_sysroot_native)s " "-r %(image_rootfs)s " - "-o %(resultdir)s" % bbvars).status - self.assertEqual(0, status) + "-o %(resultdir)s" % bbvars) self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) @OETestID(1264) def test_compress_gzip(self): """Test compressing an image with gzip""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name core-image-minimal " - "-c gzip -o %s" % self.resultdir).status) + "-c gzip -o %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.gz"))) @OETestID(1265) def test_compress_bzip2(self): """Test compressing an image with bzip2""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "-c bzip2 -o %s" % self.resultdir).status) + "-c bzip2 -o %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.bz2"))) @OETestID(1266) def test_compress_xz(self): """Test compressing an image with xz""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "--compress-with=xz -o %s" % self.resultdir).status) + "--compress-with=xz -o %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.xz"))) @OETestID(1267) @@ -315,63 +323,62 @@ class Wic(OESelftestTestCase): @OETestID(1558) def test_debug_short(self): """Test -D option""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "-D -o %s" % self.resultdir).status) + "-D -o %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) @OETestID(1658) def test_debug_long(self): """Test --debug option""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "--debug -o %s" % self.resultdir).status) + "--debug -o %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) @OETestID(1563) def test_skip_build_check_short(self): """Test -s option""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "-s -o %s" % self.resultdir).status) + "-s -o %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) @OETestID(1671) def test_skip_build_check_long(self): """Test --skip-build-check option""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "--skip-build-check " - "--outdir %s" % self.resultdir).status) + "--outdir %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) @OETestID(1564) def test_build_rootfs_short(self): """Test -f option""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "-f -o %s" % self.resultdir).status) + "-f -o %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) @OETestID(1656) def test_build_rootfs_long(self): """Test --build-rootfs option""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "--build-rootfs " - "--outdir %s" % self.resultdir).status) + "--outdir %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) @OETestID(1268) @only_for_arch(['i586', 'i686', 'x86_64']) def test_rootfs_indirect_recipes(self): """Test usage of rootfs plugin with rootfs recipes""" - status = runCmd("wic create directdisk-multi-rootfs " + runCmd("wic create directdisk-multi-rootfs " "--image-name=core-image-minimal " "--rootfs rootfs1=core-image-minimal " "--rootfs rootfs2=core-image-minimal " - "--outdir %s" % self.resultdir).status - self.assertEqual(0, status) + "--outdir %s" % self.resultdir) self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct"))) @OETestID(1269) @@ -385,14 +392,13 @@ class Wic(OESelftestTestCase): bbvars = {key.lower(): value for key, value in bb_vars.items()} bbvars['wks'] = "directdisk-multi-rootfs" bbvars['resultdir'] = self.resultdir - status = runCmd("wic create %(wks)s " + runCmd("wic create %(wks)s " "--bootimg-dir=%(staging_datadir)s " "--kernel-dir=%(deploy_dir_image)s " "--native-sysroot=%(recipe_sysroot_native)s " "--rootfs-dir rootfs1=%(image_rootfs)s " "--rootfs-dir rootfs2=%(image_rootfs)s " - "--outdir %(resultdir)s" % bbvars).status - self.assertEqual(0, status) + "--outdir %(resultdir)s" % bbvars) self.assertEqual(1, len(glob(self.resultdir + "%(wks)s-*.direct" % bbvars))) @OETestID(1661) @@ -411,8 +417,8 @@ part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path usr part /usr --source rootfs --ondisk mmcblk0 --fstype=ext4 --rootfs-dir %s/usr part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --rootfs-dir %s/usr""" % (rootfs_dir, rootfs_dir)) - self.assertEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \ - % (wks_file, self.resultdir)).status) + runCmd("wic create %s -e core-image-minimal -o %s" \ + % (wks_file, self.resultdir)) os.remove(wks_file) wicout = glob(self.resultdir + "%s-*direct" % 'temp') @@ -422,7 +428,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # verify partition size with wic res = runCmd("parted -m %s unit b p 2>/dev/null" % wicimg) - self.assertEqual(0, res.status) # parse parted output which looks like this: # BYT;\n @@ -438,8 +443,8 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r self.assertEqual(7, len(partln)) start = int(partln[1].rstrip("B")) / 512 length = int(partln[3].rstrip("B")) / 512 - self.assertEqual(0, runCmd("dd if=%s of=%s skip=%d count=%d" % - (wicimg, part_file, start, length)).status) + runCmd("dd if=%s of=%s skip=%d count=%d" % + (wicimg, part_file, start, length)) def extract_files(debugfs_output): """ @@ -463,7 +468,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # /usr. res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ os.path.join(self.resultdir, "selftest_img.part1")) - self.assertEqual(0, res.status) files = extract_files(res.output) self.assertIn("etc", files) self.assertNotIn("usr", files) @@ -472,7 +476,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # directories. res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ os.path.join(self.resultdir, "selftest_img.part2")) - self.assertEqual(0, res.status) files = extract_files(res.output) self.assertNotIn("etc", files) self.assertNotIn("usr", files) @@ -482,7 +485,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # directory, but not the files inside it. res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ os.path.join(self.resultdir, "selftest_img.part3")) - self.assertEqual(0, res.status) files = extract_files(res.output) self.assertNotIn("etc", files) self.assertNotIn("usr", files) @@ -490,7 +492,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r self.assertIn("bin", files) res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % \ os.path.join(self.resultdir, "selftest_img.part3")) - self.assertEqual(0, res.status) files = extract_files(res.output) self.assertIn(".", files) self.assertIn("..", files) @@ -522,12 +523,13 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r % (wks_file, self.resultdir), ignore_status=True).status) os.remove(wks_file) +class Wic2(WicTestCase): + @OETestID(1496) def test_bmap_short(self): """Test generation of .bmap file -m option""" cmd = "wic create wictestdisk -e core-image-minimal -m -o %s" % self.resultdir - status = runCmd(cmd).status - self.assertEqual(0, status) + runCmd(cmd) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap"))) @@ -535,21 +537,10 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r def test_bmap_long(self): """Test generation of .bmap file --bmap option""" cmd = "wic create wictestdisk -e core-image-minimal --bmap -o %s" % self.resultdir - status = runCmd(cmd).status - self.assertEqual(0, status) + runCmd(cmd) 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 .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 .env files.""" @@ -580,10 +571,10 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r imgenvdir = self._get_image_env_path(image) native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=%s -v %s -n %s -o %s" % (image, imgenvdir, native_sysroot, - self.resultdir)).status) + self.resultdir)) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) @OETestID(1665) @@ -593,13 +584,13 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r imgenvdir = self._get_image_env_path(image) native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=%s " "--vars %s " "--native-sysroot %s " "--outdir %s" % (image, imgenvdir, native_sysroot, - self.resultdir)).status) + self.resultdir)) self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) @OETestID(1351) @@ -679,19 +670,21 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r Test creation of a simple image with partition size controlled through --fixed-size flag """ - wkspath, wksname = Wic._make_fixed_size_wks(200) + wkspath, wksname = Wic2._make_fixed_size_wks(200) - self.assertEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \ - % (wkspath, self.resultdir)).status) + runCmd("wic create %s -e core-image-minimal -o %s" \ + % (wkspath, self.resultdir)) os.remove(wkspath) wicout = glob(self.resultdir + "%s-*direct" % wksname) self.assertEqual(1, len(wicout)) 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 @@ -709,7 +702,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r --fixed-size flag. The size of partition is intentionally set to 1MiB in order to trigger an error in wic. """ - wkspath, wksname = Wic._make_fixed_size_wks(1) + wkspath, wksname = Wic2._make_fixed_size_wks(1) self.assertEqual(1, runCmd("wic create %s -e core-image-minimal -o %s" \ % (wkspath, self.resultdir), ignore_status=True).status) @@ -746,7 +739,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n']) wks.flush() cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] out = glob(self.resultdir + "%s-*direct" % wksname) self.assertEqual(1, len(out)) @@ -763,10 +756,10 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r 'part emptyvfat --fstype vfat --size 1M\n', 'part emptymsdos --fstype msdos --size 1M\n', 'part emptyext2 --fstype ext2 --size 1M\n', - 'part emptybtrfs --fstype btrfs --size 100M\n']) + 'part emptybtrfs --fstype btrfs --size 150M\n']) wks.flush() cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] out = glob(self.resultdir + "%s-*direct" % wksname) self.assertEqual(1, len(out)) @@ -779,7 +772,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r '--overhead-factor 1.2 --size 100k\n']) wks.flush() cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir) - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] out = glob(self.resultdir + "%s-*direct" % wksname) self.assertEqual(1, len(out)) @@ -791,7 +784,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r cmd = "wic create sdimage-bootpart -e %s -o %s" % (img, self.resultdir) config = 'IMAGE_BOOT_FILES = "%s*"' % get_bb_var('KERNEL_IMAGETYPE', img) self.append_config(config) - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) self.remove_config(config) self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) @@ -827,9 +820,9 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r @OETestID(1857) def test_wic_ls(self): """Test listing image content using 'wic ls'""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "-D -o %s" % self.resultdir).status) + "-D -o %s" % self.resultdir) images = glob(self.resultdir + "wictestdisk-*.direct") self.assertEqual(1, len(images)) @@ -837,20 +830,18 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # list partitions result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertEqual(3, len(result.output.split('\n'))) # list directory content of the first partition result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertEqual(6, len(result.output.split('\n'))) @OETestID(1856) def test_wic_cp(self): """Test copy files and directories to the the wic image.""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "-D -o %s" % self.resultdir).status) + "-D -o %s" % self.resultdir) images = glob(self.resultdir + "wictestdisk-*.direct") self.assertEqual(1, len(images)) @@ -858,19 +849,16 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # list directory content of the first partition result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertEqual(6, len(result.output.split('\n'))) with NamedTemporaryFile("w", suffix=".wic-cp") as testfile: testfile.write("test") # copy file to the partition - result = runCmd("wic cp %s %s:1/ -n %s" % (testfile.name, images[0], sysroot)) - self.assertEqual(0, result.status) + runCmd("wic cp %s %s:1/ -n %s" % (testfile.name, images[0], sysroot)) # check if file is there result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertEqual(7, len(result.output.split('\n'))) self.assertTrue(os.path.basename(testfile.name) in result.output) @@ -881,21 +869,19 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r copy(testfile.name, testdir) # copy directory to the partition - result = runCmd("wic cp %s %s:1/ -n %s" % (testdir, images[0], sysroot)) - self.assertEqual(0, result.status) + runCmd("wic cp %s %s:1/ -n %s" % (testdir, images[0], sysroot)) # check if directory is there result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertEqual(8, len(result.output.split('\n'))) self.assertTrue(os.path.basename(testdir) in result.output) @OETestID(1858) def test_wic_rm(self): """Test removing files and directories from the the wic image.""" - self.assertEqual(0, runCmd("wic create mkefidisk " + runCmd("wic create mkefidisk " "--image-name=core-image-minimal " - "-D -o %s" % self.resultdir).status) + "-D -o %s" % self.resultdir) images = glob(self.resultdir + "mkefidisk-*.direct") self.assertEqual(1, len(images)) @@ -903,21 +889,17 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # list directory content of the first partition result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertIn('\nBZIMAGE ', result.output) self.assertIn('\nEFI ', result.output) # remove file - result = runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) + runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot)) # remove directory - result = runCmd("wic rm %s:1/efi -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) + runCmd("wic rm %s:1/efi -n %s" % (images[0], sysroot)) # check if they're removed result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertNotIn('\nBZIMAGE ', result.output) self.assertNotIn('\nEFI ', result.output) @@ -936,7 +918,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r 'part emptybtrfs --fstype btrfs --size 100M --mkfs-extraopts "--mixed -K"\n']) wks.flush() cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] out = glob(self.resultdir + "%s-*direct" % wksname) self.assertEqual(1, len(out)) @@ -966,7 +948,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') cmd = "wic write -n %s --expand 1:0 %s %s" % (sysroot, image_path, new_image_path) - self.assertEqual(0, runCmd(cmd).status) + runCmd(cmd) # check if partitions are expanded orig = runCmd("wic ls %s -n %s" % (image_path, sysroot)) @@ -996,9 +978,9 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r def test_wic_ls_ext(self): """Test listing content of the ext partition using 'wic ls'""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "-D -o %s" % self.resultdir).status) + "-D -o %s" % self.resultdir) images = glob(self.resultdir + "wictestdisk-*.direct") self.assertEqual(1, len(images)) @@ -1006,15 +988,14 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # list directory content of the second ext4 partition result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset( set(line.split()[-1] for line in result.output.split('\n') if line))) def test_wic_cp_ext(self): """Test copy files and directories to the ext partition.""" - self.assertEqual(0, runCmd("wic create wictestdisk " + runCmd("wic create wictestdisk " "--image-name=core-image-minimal " - "-D -o %s" % self.resultdir).status) + "-D -o %s" % self.resultdir) images = glob(self.resultdir + "wictestdisk-*.direct") self.assertEqual(1, len(images)) @@ -1022,7 +1003,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # list directory content of the ext4 partition result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) dirs = set(line.split()[-1] for line in result.output.split('\n') if line) self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset(dirs)) @@ -1030,20 +1010,18 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r testfile.write("test") # copy file to the partition - result = runCmd("wic cp %s %s:2/ -n %s" % (testfile.name, images[0], sysroot)) - self.assertEqual(0, result.status) + runCmd("wic cp %s %s:2/ -n %s" % (testfile.name, images[0], sysroot)) # check if file is there result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) newdirs = set(line.split()[-1] for line in result.output.split('\n') if line) self.assertEqual(newdirs.difference(dirs), set([os.path.basename(testfile.name)])) def test_wic_rm_ext(self): """Test removing files from the ext partition.""" - self.assertEqual(0, runCmd("wic create mkefidisk " + runCmd("wic create mkefidisk " "--image-name=core-image-minimal " - "-D -o %s" % self.resultdir).status) + "-D -o %s" % self.resultdir) images = glob(self.resultdir + "mkefidisk-*.direct") self.assertEqual(1, len(images)) @@ -1051,14 +1029,11 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r # list directory content of the /etc directory on ext4 partition result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertTrue('fstab' in [line.split()[-1] for line in result.output.split('\n') if line]) # remove file - result = runCmd("wic rm %s:2/etc/fstab -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) + runCmd("wic rm %s:2/etc/fstab -n %s" % (images[0], sysroot)) # check if it's removed result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot)) - self.assertEqual(0, result.status) self.assertTrue('fstab' not in [line.split()[-1] for line in result.output.split('\n') if line]) -- cgit v1.2.3