diff options
Diffstat (limited to 'poky/meta/lib/oeqa/selftest/cases')
26 files changed, 248 insertions, 241 deletions
diff --git a/poky/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py b/poky/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py index 7ac03f0cec..bff6e7740c 100644 --- a/poky/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py +++ b/poky/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py @@ -6,7 +6,7 @@ import os import shutil import oeqa.utils.ftools as ftools -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer +from oeqa.utils.commands import runCmd, bitbake, get_bb_var from oeqa.selftest.cases.sstate import SStateBase diff --git a/poky/meta/lib/oeqa/selftest/cases/binutils.py b/poky/meta/lib/oeqa/selftest/cases/binutils.py index 821f52f5a8..3b0b44b390 100644 --- a/poky/meta/lib/oeqa/selftest/cases/binutils.py +++ b/poky/meta/lib/oeqa/selftest/cases/binutils.py @@ -1,12 +1,9 @@ # SPDX-License-Identifier: MIT import os -import sys -import re -import logging from oeqa.core.decorator import OETestTag from oeqa.core.case import OEPTestResultTestCase from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars +from oeqa.utils.commands import bitbake, get_bb_vars def parse_values(content): for i in content: diff --git a/poky/meta/lib/oeqa/selftest/cases/buildoptions.py b/poky/meta/lib/oeqa/selftest/cases/buildoptions.py index bfe613b847..ad604d6ae2 100644 --- a/poky/meta/lib/oeqa/selftest/cases/buildoptions.py +++ b/poky/meta/lib/oeqa/selftest/cases/buildoptions.py @@ -9,7 +9,7 @@ import shutil import tempfile from oeqa.selftest.case import OESelftestTestCase from oeqa.selftest.cases.buildhistory import BuildhistoryBase -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars +from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars import oeqa.utils.ftools as ftools class ImageOptionsTests(OESelftestTestCase): @@ -177,7 +177,12 @@ class ArchiverTest(OESelftestTestCase): """ Test for archiving the work directory and exporting the source files. """ - self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") + self.write_config(""" +INHERIT += "archiver" +PACKAGE_CLASSES = "package_rpm" +ARCHIVER_MODE[src] = "original" +ARCHIVER_MODE[srpm] = "1" +""") res = bitbake("xcursor-transparent-theme", ignore_status=True) self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output) deploy_dir_src = get_bb_var('DEPLOY_DIR_SRC') diff --git a/poky/meta/lib/oeqa/selftest/cases/devtool.py b/poky/meta/lib/oeqa/selftest/cases/devtool.py index e910672c31..3eea2b1a0e 100644 --- a/poky/meta/lib/oeqa/selftest/cases/devtool.py +++ b/poky/meta/lib/oeqa/selftest/cases/devtool.py @@ -9,10 +9,10 @@ import tempfile import glob import fnmatch -import oeqa.utils.ftools as ftools from oeqa.selftest.case import OESelftestTestCase 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 import OETestTag oldmetapath = None @@ -1351,6 +1351,7 @@ class DevtoolExtractTests(DevtoolBase): matches2 = glob.glob(stampprefix2 + '*') self.assertFalse(matches2, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe2) + @OETestTag("runqemu") def test_devtool_deploy_target(self): # NOTE: Whilst this test would seemingly be better placed as a runtime test, # unfortunately the runtime tests run under bitbake and you can't run @@ -1471,6 +1472,14 @@ class DevtoolExtractTests(DevtoolBase): class DevtoolUpgradeTests(DevtoolBase): + def setUp(self): + super().setUp() + try: + runCmd("git config --global user.name") + runCmd("git config --global user.email") + except: + self.skip("Git user.name and user.email must be set") + def test_devtool_upgrade(self): # Check preconditions self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') @@ -1866,8 +1875,9 @@ class DevtoolUpgradeTests(DevtoolBase): Expected: devtool modify is able to checkout the source of the kernel and modification to the source and configurations are reflected when building the kernel. - """ - kernel_provider = get_bb_var('PREFERRED_PROVIDER_virtual/kernel') + """ + kernel_provider = self.td['PREFERRED_PROVIDER_virtual/kernel'] + # Clean up the environment bitbake('%s -c clean' % kernel_provider) tempdir = tempfile.mkdtemp(prefix='devtoolqa') @@ -1894,33 +1904,28 @@ class DevtoolUpgradeTests(DevtoolBase): self.assertExists(os.path.join(tempdir, 'Makefile'), 'Extracted source could not be found') #Step 4.2 configfile = os.path.join(tempdir,'.config') - diff = runCmd('diff %s %s' % (tmpconfig, configfile)) - self.assertEqual(0,diff.status,'Kernel .config file is not the same using bitbake and devtool') + runCmd('diff %s %s' % (tmpconfig, configfile)) + #Step 4.3 #NOTE: virtual/kernel is mapped to kernel_provider - result = runCmd('devtool build %s' % kernel_provider) - self.assertEqual(0,result.status,'Cannot build kernel using `devtool build`') + runCmd('devtool build %s' % kernel_provider) kernelfile = os.path.join(get_bb_var('KBUILD_OUTPUT', kernel_provider), 'vmlinux') self.assertExists(kernelfile, 'Kernel was not build correctly') #Modify the kernel source - modfile = os.path.join(tempdir,'arch/x86/boot/header.S') - modstring = "Use a boot loader. Devtool testing." - modapplied = runCmd("sed -i 's/Use a boot loader./%s/' %s" % (modstring, modfile)) - self.assertEqual(0,modapplied.status,'Modification to %s on kernel source failed' % modfile) + modfile = os.path.join(tempdir, 'init/version.c') + runCmd("sed -i 's/Linux/LiNuX/g' %s" % (modfile)) + #Modify the configuration - codeconfigfile = os.path.join(tempdir,'.config.new') + codeconfigfile = os.path.join(tempdir, '.config.new') modconfopt = "CONFIG_SG_POOL=n" - modconf = runCmd("sed -i 's/CONFIG_SG_POOL=y/%s/' %s" % (modconfopt, codeconfigfile)) - self.assertEqual(0,modconf.status,'Modification to %s failed' % codeconfigfile) + runCmd("sed -i 's/CONFIG_SG_POOL=y/%s/' %s" % (modconfopt, codeconfigfile)) + #Build again kernel with devtool - rebuild = runCmd('devtool build %s' % kernel_provider) - self.assertEqual(0,rebuild.status,'Fail to build kernel after modification of source and config') + runCmd('devtool build %s' % kernel_provider) + #Step 4.4 - bzimagename = 'bzImage-' + get_bb_var('KERNEL_VERSION_NAME', kernel_provider) - bzimagefile = os.path.join(get_bb_var('D', kernel_provider),'boot', bzimagename) - checkmodcode = runCmd("grep '%s' %s" % (modstring, bzimagefile)) - self.assertEqual(0,checkmodcode.status,'Modification on kernel source failed') + runCmd("grep '%s' %s" % ('LiNuX', kernelfile)) + #Step 4.5 - checkmodconfg = runCmd("grep %s %s" % (modconfopt, codeconfigfile)) - self.assertEqual(0,checkmodconfg.status,'Modification to configuration file failed') + runCmd("grep %s %s" % (modconfopt, codeconfigfile)) diff --git a/poky/meta/lib/oeqa/selftest/cases/distrodata.py b/poky/meta/lib/oeqa/selftest/cases/distrodata.py index 03f31e9fcb..b80d091c1c 100644 --- a/poky/meta/lib/oeqa/selftest/cases/distrodata.py +++ b/poky/meta/lib/oeqa/selftest/cases/distrodata.py @@ -3,9 +3,6 @@ # from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars -from oeqa.utils.decorators import testcase -from oeqa.utils.ftools import write_file import oe.recipeutils diff --git a/poky/meta/lib/oeqa/selftest/cases/eSDK.py b/poky/meta/lib/oeqa/selftest/cases/eSDK.py index f7279b3230..3ea0f66357 100644 --- a/poky/meta/lib/oeqa/selftest/cases/eSDK.py +++ b/poky/meta/lib/oeqa/selftest/cases/eSDK.py @@ -8,7 +8,7 @@ import os import glob import time from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars +from oeqa.utils.commands import runCmd, bitbake, get_bb_vars class oeSDKExtSelfTest(OESelftestTestCase): """ diff --git a/poky/meta/lib/oeqa/selftest/cases/fitimage.py b/poky/meta/lib/oeqa/selftest/cases/fitimage.py index f6f6a8e795..e6bfd1257e 100644 --- a/poky/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/poky/meta/lib/oeqa/selftest/cases/fitimage.py @@ -3,9 +3,8 @@ # from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu +from oeqa.utils.commands import runCmd, bitbake, get_bb_var import os -import json import re class FitImageTests(OESelftestTestCase): diff --git a/poky/meta/lib/oeqa/selftest/cases/gcc.py b/poky/meta/lib/oeqa/selftest/cases/gcc.py index 3efe15228f..b9ea03ae62 100644 --- a/poky/meta/lib/oeqa/selftest/cases/gcc.py +++ b/poky/meta/lib/oeqa/selftest/cases/gcc.py @@ -3,7 +3,7 @@ import os from oeqa.core.decorator import OETestTag from oeqa.core.case import OEPTestResultTestCase from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu, Command +from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu def parse_values(content): for i in content: @@ -114,37 +114,44 @@ class GccLibItmSelfTest(GccSelfTestBase): self.run_check("libitm") @OETestTag("toolchain-system") +@OETestTag("runqemu") class GccCrossSelfTestSystemEmulated(GccSelfTestBase): def test_cross_gcc(self): self.run_check_emulated("gcc") @OETestTag("toolchain-system") +@OETestTag("runqemu") class GxxCrossSelfTestSystemEmulated(GccSelfTestBase): def test_cross_gxx(self): self.run_check_emulated("g++") @OETestTag("toolchain-system") +@OETestTag("runqemu") class GccLibAtomicSelfTestSystemEmulated(GccSelfTestBase): def test_libatomic(self): self.run_check_emulated("libatomic") @OETestTag("toolchain-system") +@OETestTag("runqemu") class GccLibGompSelfTestSystemEmulated(GccSelfTestBase): def test_libgomp(self): self.run_check_emulated("libgomp") @OETestTag("toolchain-system") +@OETestTag("runqemu") class GccLibStdCxxSelfTestSystemEmulated(GccSelfTestBase): def test_libstdcxx(self): self.run_check_emulated("libstdc++-v3") @OETestTag("toolchain-system") +@OETestTag("runqemu") class GccLibSspSelfTestSystemEmulated(GccSelfTestBase): def test_libssp(self): self.check_skip("libssp") self.run_check_emulated("libssp") @OETestTag("toolchain-system") +@OETestTag("runqemu") class GccLibItmSelfTestSystemEmulated(GccSelfTestBase): def test_libitm(self): self.check_skip("libitm") diff --git a/poky/meta/lib/oeqa/selftest/cases/glibc.py b/poky/meta/lib/oeqa/selftest/cases/glibc.py index 6f96281ea5..6fc98e9cb4 100644 --- a/poky/meta/lib/oeqa/selftest/cases/glibc.py +++ b/poky/meta/lib/oeqa/selftest/cases/glibc.py @@ -4,7 +4,7 @@ import contextlib from oeqa.core.decorator import OETestTag from oeqa.core.case import OEPTestResultTestCase from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu, Command +from oeqa.utils.commands import bitbake, get_bb_var, runqemu from oeqa.utils.nfs import unfs_server def parse_values(content): @@ -83,6 +83,7 @@ class GlibcSelfTest(GlibcSelfTestBase): self.run_check() @OETestTag("toolchain-system") +@OETestTag("runqemu") class GlibcSelfTestSystemEmulated(GlibcSelfTestBase): def test_glibc(self): self.run_check_emulated() diff --git a/poky/meta/lib/oeqa/selftest/cases/imagefeatures.py b/poky/meta/lib/oeqa/selftest/cases/imagefeatures.py index d36d45c551..6b94ace4eb 100644 --- a/poky/meta/lib/oeqa/selftest/cases/imagefeatures.py +++ b/poky/meta/lib/oeqa/selftest/cases/imagefeatures.py @@ -3,6 +3,7 @@ # from oeqa.selftest.case import OESelftestTestCase +from oeqa.core.decorator import OETestTag from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu from oeqa.utils.sshcontrol import SSHControl import glob @@ -14,6 +15,7 @@ class ImageFeatures(OESelftestTestCase): test_user = 'tester' root_user = 'root' + @OETestTag("runqemu") def test_non_root_user_can_connect_via_ssh_without_password(self): """ Summary: Check if non root user can connect via ssh without password @@ -39,6 +41,7 @@ class ImageFeatures(OESelftestTestCase): status, output = ssh.run("true") self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output)) + @OETestTag("runqemu") def test_all_users_can_connect_via_ssh_without_password(self): """ Summary: Check if all users can connect via ssh without password diff --git a/poky/meta/lib/oeqa/selftest/cases/layerappend.py b/poky/meta/lib/oeqa/selftest/cases/layerappend.py index dadc7c5d28..8fb1e6c530 100644 --- a/poky/meta/lib/oeqa/selftest/cases/layerappend.py +++ b/poky/meta/lib/oeqa/selftest/cases/layerappend.py @@ -5,7 +5,7 @@ import os from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd, bitbake, get_bb_var +from oeqa.utils.commands import bitbake, get_bb_var import oeqa.utils.ftools as ftools class LayerAppendTests(OESelftestTestCase): diff --git a/poky/meta/lib/oeqa/selftest/cases/lic_checksum.py b/poky/meta/lib/oeqa/selftest/cases/lic_checksum.py index 91021ac335..f8681ed755 100644 --- a/poky/meta/lib/oeqa/selftest/cases/lic_checksum.py +++ b/poky/meta/lib/oeqa/selftest/cases/lic_checksum.py @@ -7,7 +7,6 @@ import tempfile from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import bitbake -from oeqa.utils import CommandError class LicenseTests(OESelftestTestCase): diff --git a/poky/meta/lib/oeqa/selftest/cases/manifest.py b/poky/meta/lib/oeqa/selftest/cases/manifest.py index 5d13f35468..0a04c13a85 100644 --- a/poky/meta/lib/oeqa/selftest/cases/manifest.py +++ b/poky/meta/lib/oeqa/selftest/cases/manifest.py @@ -5,7 +5,7 @@ import os from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import get_bb_var, get_bb_vars, bitbake +from oeqa.utils.commands import get_bb_var, bitbake class ManifestEntry: '''A manifest item of a collection able to list missing packages''' diff --git a/poky/meta/lib/oeqa/selftest/cases/oescripts.py b/poky/meta/lib/oeqa/selftest/cases/oescripts.py index 91abf9654a..cd687816c8 100644 --- a/poky/meta/lib/oeqa/selftest/cases/oescripts.py +++ b/poky/meta/lib/oeqa/selftest/cases/oescripts.py @@ -8,7 +8,7 @@ import importlib import unittest from oeqa.selftest.case import OESelftestTestCase from oeqa.selftest.cases.buildhistory import BuildhistoryBase -from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer +from oeqa.utils.commands import runCmd, bitbake, get_bb_var from oeqa.utils import CommandError class BuildhistoryDiffTests(BuildhistoryBase): @@ -34,21 +34,19 @@ class BuildhistoryDiffTests(BuildhistoryBase): if expected_endlines: self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines)) -@unittest.skipUnless(importlib.util.find_spec("cairo"), "Python cairo module is not present") class OEScriptTests(OESelftestTestCase): + scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts') + +@unittest.skipUnless(importlib.util.find_spec("cairo"), "Python cairo module is not present") +class OEPybootchartguyTests(OEScriptTests): @classmethod def setUpClass(cls): super(OEScriptTests, cls).setUpClass() - import cairo bitbake("core-image-minimal -c rootfs -f") cls.tmpdir = get_bb_var('TMPDIR') cls.buildstats = cls.tmpdir + "/buildstats/" + sorted(os.listdir(cls.tmpdir + "/buildstats"))[-1] - scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts') - -class OEPybootchartguyTests(OEScriptTests): - def test_pybootchartguy_help(self): runCmd('%s/pybootchartgui/pybootchartgui.py --help' % self.scripts_dir) @@ -65,9 +63,7 @@ class OEPybootchartguyTests(OEScriptTests): self.assertTrue(os.path.exists(self.tmpdir + "/charts.pdf")) -class OEGitproxyTests(OESelftestTestCase): - - scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts') +class OEGitproxyTests(OEScriptTests): def test_oegitproxy_help(self): try: diff --git a/poky/meta/lib/oeqa/selftest/cases/overlayfs.py b/poky/meta/lib/oeqa/selftest/cases/overlayfs.py index 56ae48ce64..472746a64f 100644 --- a/poky/meta/lib/oeqa/selftest/cases/overlayfs.py +++ b/poky/meta/lib/oeqa/selftest/cases/overlayfs.py @@ -3,7 +3,8 @@ # from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu +from oeqa.utils.commands import bitbake, runqemu +from oeqa.core.decorator import OETestTag def getline_qemu(out, line): for l in out.split('\n'): @@ -185,6 +186,7 @@ EOT line = getline_qemu(output, "upperdir=/mnt/overlay/upper/usr/share/another-overlay-mount") self.assertTrue(line and line.startswith("overlay"), msg=output) + @OETestTag("runqemu") def test_correct_image_fstab(self): """ Summary: Check that we can create an image when all parameters are @@ -203,6 +205,7 @@ EOT self._test_correct_image('base-files', base_files_append) + @OETestTag("runqemu") def test_correct_image_unit(self): """ Summary: Check that we can create an image when all parameters are @@ -238,6 +241,7 @@ EOT self._test_correct_image('systemd-machine-units', systemd_machine_unit_append) +@OETestTag("runqemu") class OverlayFSEtcRunTimeTests(OESelftestTestCase): """overlayfs-etc class tests""" diff --git a/poky/meta/lib/oeqa/selftest/cases/package.py b/poky/meta/lib/oeqa/selftest/cases/package.py index cebbb4f3f4..51d835259e 100644 --- a/poky/meta/lib/oeqa/selftest/cases/package.py +++ b/poky/meta/lib/oeqa/selftest/cases/package.py @@ -4,7 +4,6 @@ from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import bitbake, get_bb_vars, get_bb_var, runqemu -import stat import subprocess, os import oe.path import re diff --git a/poky/meta/lib/oeqa/selftest/cases/recipeutils.py b/poky/meta/lib/oeqa/selftest/cases/recipeutils.py index f1dd63f65b..74b2098ae8 100644 --- a/poky/meta/lib/oeqa/selftest/cases/recipeutils.py +++ b/poky/meta/lib/oeqa/selftest/cases/recipeutils.py @@ -2,14 +2,10 @@ # SPDX-License-Identifier: MIT # -import os -import re -import time -import logging import bb.tinfoil from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd, get_test_layer +from oeqa.utils.commands import get_test_layer def setUpModule(): diff --git a/poky/meta/lib/oeqa/selftest/cases/reproducible.py b/poky/meta/lib/oeqa/selftest/cases/reproducible.py index 7caf8c3e7d..5042c11d8e 100644 --- a/poky/meta/lib/oeqa/selftest/cases/reproducible.py +++ b/poky/meta/lib/oeqa/selftest/cases/reproducible.py @@ -9,8 +9,6 @@ import bb.utils import functools import multiprocessing import textwrap -import json -import unittest import tempfile import shutil import stat diff --git a/poky/meta/lib/oeqa/selftest/cases/runqemu.py b/poky/meta/lib/oeqa/selftest/cases/runqemu.py index da22f77b27..c1d277a095 100644 --- a/poky/meta/lib/oeqa/selftest/cases/runqemu.py +++ b/poky/meta/lib/oeqa/selftest/cases/runqemu.py @@ -12,6 +12,7 @@ from oeqa.core.decorator import OETestTag from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd +@OETestTag("runqemu") class RunqemuTests(OESelftestTestCase): """Runqemu test class""" @@ -149,6 +150,7 @@ SYSLINUX_TIMEOUT = "10" # bootup various filesystem types, including live image(iso and hddimg) # where live image was not supported on all qemu architecture. @OETestTag("machine") +@OETestTag("runqemu") class QemuTest(OESelftestTestCase): @classmethod diff --git a/poky/meta/lib/oeqa/selftest/cases/runtime_test.py b/poky/meta/lib/oeqa/selftest/cases/runtime_test.py index 642f0eb637..2ad89490fc 100644 --- a/poky/meta/lib/oeqa/selftest/cases/runtime_test.py +++ b/poky/meta/lib/oeqa/selftest/cases/runtime_test.py @@ -4,16 +4,15 @@ from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu -from oeqa.utils.sshcontrol import SSHControl +from oeqa.core.decorator import OETestTag import os -import re import tempfile -import shutil import oe.lsb from oeqa.core.decorator.data import skipIfNotQemu class TestExport(OESelftestTestCase): + @OETestTag("runqemu") def test_testexport_basic(self): """ Summary: Check basic testexport functionality with only ping test enabled. @@ -106,6 +105,7 @@ class TestExport(OESelftestTestCase): self.assertEqual(0, result.status, "Couldn't run tar from SDK") +@OETestTag("runqemu") class TestImage(OESelftestTestCase): def test_testimage_install(self): @@ -240,6 +240,7 @@ class TestImage(OESelftestTestCase): bitbake('core-image-minimal') bitbake('-c testimage core-image-minimal') +@OETestTag("runqemu") class Postinst(OESelftestTestCase): def init_manager_loop(self, init_manager): @@ -280,7 +281,7 @@ class Postinst(OESelftestTestCase): - @skipIfNotQemu('qemuall', 'Test only runs in qemu') + @skipIfNotQemu() def test_postinst_rootfs_and_boot_sysvinit(self): """ Summary: The purpose of this test case is to verify Post-installation @@ -301,7 +302,7 @@ class Postinst(OESelftestTestCase): self.init_manager_loop("sysvinit") - @skipIfNotQemu('qemuall', 'Test only runs in qemu') + @skipIfNotQemu() def test_postinst_rootfs_and_boot_systemd(self): """ Summary: The purpose of this test case is to verify Post-installation @@ -357,6 +358,7 @@ class Postinst(OESelftestTestCase): self.assertFalse(os.path.isfile(os.path.join(hosttestdir, "rootfs-after-failure")), "rootfs-after-failure file was created") +@OETestTag("runqemu") class SystemTap(OESelftestTestCase): """ Summary: The purpose of this test case is to verify native crosstap @@ -433,4 +435,3 @@ IMAGE_INSTALL:append = " systemtap-runtime" cmd = "crosstap -r root@192.168.7.2 -s %s/process/ syscalls_by_pid.stp" % systemtap_examples result = runCmd(cmd) self.assertEqual(0, result.status, 'crosstap syscalls_by_pid returned a non 0 status:%s' % result.output) - diff --git a/poky/meta/lib/oeqa/selftest/cases/selftest.py b/poky/meta/lib/oeqa/selftest/cases/selftest.py index af080dcf03..7268e25939 100644 --- a/poky/meta/lib/oeqa/selftest/cases/selftest.py +++ b/poky/meta/lib/oeqa/selftest/cases/selftest.py @@ -3,7 +3,6 @@ # import importlib -from oeqa.utils.commands import runCmd import oeqa.selftest from oeqa.selftest.case import OESelftestTestCase diff --git a/poky/meta/lib/oeqa/selftest/cases/sstate.py b/poky/meta/lib/oeqa/selftest/cases/sstate.py index 80ce9e353c..176766331a 100644 --- a/poky/meta/lib/oeqa/selftest/cases/sstate.py +++ b/poky/meta/lib/oeqa/selftest/cases/sstate.py @@ -3,14 +3,11 @@ # import datetime -import unittest import os import re -import shutil -import oeqa.utils.ftools as ftools from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd, bitbake, get_bb_vars, get_test_layer +from oeqa.utils.commands import get_bb_vars class SStateBase(OESelftestTestCase): diff --git a/poky/meta/lib/oeqa/selftest/cases/sstatetests.py b/poky/meta/lib/oeqa/selftest/cases/sstatetests.py index 3038b40021..4a32af902f 100644 --- a/poky/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/poky/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -8,8 +8,7 @@ import glob import subprocess import tempfile -from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer, create_temp_layer +from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer from oeqa.selftest.cases.sstate import SStateBase import oe diff --git a/poky/meta/lib/oeqa/selftest/cases/sysroot.py b/poky/meta/lib/oeqa/selftest/cases/sysroot.py index 79ab45235d..315d1a61c2 100644 --- a/poky/meta/lib/oeqa/selftest/cases/sysroot.py +++ b/poky/meta/lib/oeqa/selftest/cases/sysroot.py @@ -5,7 +5,7 @@ import uuid from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import bitbake +from oeqa.utils.commands import bitbake class SysrootTests(OESelftestTestCase): def test_sysroot_cleanup(self): diff --git a/poky/meta/lib/oeqa/selftest/cases/tinfoil.py b/poky/meta/lib/oeqa/selftest/cases/tinfoil.py index 6f26af23d5..c81d56d82b 100644 --- a/poky/meta/lib/oeqa/selftest/cases/tinfoil.py +++ b/poky/meta/lib/oeqa/selftest/cases/tinfoil.py @@ -9,7 +9,6 @@ import logging import bb.tinfoil from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import runCmd class TinfoilTests(OESelftestTestCase): """ Basic tests for the tinfoil API """ diff --git a/poky/meta/lib/oeqa/selftest/cases/wic.py b/poky/meta/lib/oeqa/selftest/cases/wic.py index 6f3dc27743..de74c07a03 100644 --- a/poky/meta/lib/oeqa/selftest/cases/wic.py +++ b/poky/meta/lib/oeqa/selftest/cases/wic.py @@ -19,29 +19,26 @@ from functools import wraps, lru_cache from tempfile import NamedTemporaryFile from oeqa.selftest.case import OESelftestTestCase +from oeqa.core.decorator import OETestTag from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu -@lru_cache(maxsize=32) -def get_host_arch(recipe): - """A cached call to get_bb_var('HOST_ARCH', <recipe>)""" - return get_bb_var('HOST_ARCH', recipe) +@lru_cache() +def get_host_arch(): + return get_bb_var('HOST_ARCH') -def only_for_arch(archs, image='core-image-minimal'): +def only_for_arch(archs): """Decorator for wrapping test cases that can be run only for specific target architectures. A list of compatible architectures is passed in `archs`. - Current architecture will be determined by parsing bitbake output for - `image` recipe. """ def wrapper(func): @wraps(func) def wrapped_f(*args, **kwargs): - arch = get_host_arch(image) + arch = get_host_arch() if archs and arch not in archs: raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch) return func(*args, **kwargs) - wrapped_f.__name__ = func.__name__ return wrapped_f return wrapper @@ -78,22 +75,18 @@ class WicTestCase(OESelftestTestCase): def setUpLocal(self): """This code is executed before each test method.""" - self.resultdir = self.builddir + "/wic-tmp/" + self.resultdir = os.path.join(self.builddir, "wic-tmp") 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 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') + if self.td['USE_NLS'] != 'yes': + self.skipTest('wic-tools needs USE_NLS=yes') - bitbake('core-image-minimal') - bitbake('core-image-minimal-mtdutils') + bitbake('wic-tools core-image-minimal core-image-minimal-mtdutils') WicTestCase.image_is_ready = True - rmtree(self.resultdir, ignore_errors=True) def tearDownLocal(self): @@ -104,15 +97,13 @@ class WicTestCase(OESelftestTestCase): 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'] + bitbake('%s -c do_rootfs_wicenv' % image) + stdir = get_bb_var('STAGING_DIR', image) + machine = self.td["MACHINE"] WicTestCase.wicenv_cache[image] = os.path.join(stdir, machine, 'imgdata') return WicTestCase.wicenv_cache[image] -class Wic(WicTestCase): - +class CLITests(OESelftestTestCase): def test_version(self): """Test wic --version""" runCmd('wic --version') @@ -173,18 +164,19 @@ class Wic(WicTestCase): """Test wic without command""" self.assertEqual(1, runCmd('wic', ignore_status=True).status) +class Wic(WicTestCase): 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 runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) + self.assertEqual(1, len(glob(os.path.join (self.resultdir, "wictestdisk-*.direct")))) @only_for_arch(['i586', 'i686', 'x86_64']) 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 runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-*.direct")))) @only_for_arch(['i586', 'i686', 'x86_64']) def test_iso_image(self): @@ -197,22 +189,22 @@ class Wic(WicTestCase): self.remove_config(config) cmd = "wic create mkhybridiso --image-name core-image-minimal -o %s" % self.resultdir runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.direct"))) - self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "HYBRID_ISO_IMG-*.direct")))) + self.assertEqual(1, len(glob(os.path.join (self.resultdir, "HYBRID_ISO_IMG-*.iso")))) @only_for_arch(['i586', 'i686', 'x86_64']) 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 runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "qemux86-directdisk-*direct")))) - @only_for_arch(['i586', 'i686', 'x86_64']) + @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64']) def test_mkefidisk(self): """Test creation of mkefidisk image""" cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "mkefidisk-*direct")))) @only_for_arch(['i586', 'i686', 'x86_64']) def test_bootloader_config(self): @@ -223,9 +215,9 @@ class Wic(WicTestCase): self.remove_config(config) cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-bootloader-config-*direct")))) - @only_for_arch(['i586', 'i686', 'x86_64']) + @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64']) def test_systemd_bootdisk(self): """Test creation of systemd-bootdisk image""" config = 'MACHINE_FEATURES:append = " efi"\n' @@ -234,7 +226,7 @@ class Wic(WicTestCase): self.remove_config(config) cmd = "wic create systemd-bootdisk -e core-image-minimal -o %s" % self.resultdir runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "systemd-bootdisk-*direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "systemd-bootdisk-*direct")))) def test_efi_bootpart(self): """Test creation of efi-bootpart image""" @@ -243,7 +235,7 @@ class Wic(WicTestCase): self.append_config('IMAGE_EFI_BOOT_FILES = "%s;kernel"\n' % kimgtype) runCmd(cmd) sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') - images = glob(self.resultdir + "mkefidisk-*.direct") + images = glob(os.path.join(self.resultdir, "mkefidisk-*.direct")) result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) self.assertIn("kernel",result.output) @@ -253,8 +245,9 @@ class Wic(WicTestCase): kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal') self.write_config('IMAGE_BOOT_FILES = "%s"\n' % kimgtype) runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "sdimage-bootpart-*direct")))) + # TODO this doesn't have to be x86-specific @only_for_arch(['i586', 'i686', 'x86_64']) def test_default_output_dir(self): """Test default output location""" @@ -283,28 +276,28 @@ class Wic(WicTestCase): "-n %(recipe_sysroot_native)s " "-r %(image_rootfs)s " "-o %(resultdir)s" % bbvars) - self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-*.direct")))) def test_compress_gzip(self): """Test compressing an image with gzip""" runCmd("wic create wictestdisk " "--image-name core-image-minimal " "-c gzip -o %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.gz"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct.gz")))) def test_compress_bzip2(self): """Test compressing an image with bzip2""" runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "-c bzip2 -o %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.bz2"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct.bz2")))) def test_compress_xz(self): """Test compressing an image with xz""" runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "--compress-with=xz -o %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.xz"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct.xz")))) def test_wrong_compressor(self): """Test how wic breaks if wrong compressor is provided""" @@ -318,23 +311,23 @@ class Wic(WicTestCase): runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "-D -o %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) - self.assertEqual(1, len(glob(self.resultdir + "tmp.wic*"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct")))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "tmp.wic*")))) def test_debug_long(self): """Test --debug option""" runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "--debug -o %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) - self.assertEqual(1, len(glob(self.resultdir + "tmp.wic*"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct")))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "tmp.wic*")))) def test_skip_build_check_short(self): """Test -s option""" runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "-s -o %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct")))) def test_skip_build_check_long(self): """Test --skip-build-check option""" @@ -342,14 +335,14 @@ class Wic(WicTestCase): "--image-name=core-image-minimal " "--skip-build-check " "--outdir %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct")))) def test_build_rootfs_short(self): """Test -f option""" runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "-f -o %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct")))) def test_build_rootfs_long(self): """Test --build-rootfs option""" @@ -357,8 +350,9 @@ class Wic(WicTestCase): "--image-name=core-image-minimal " "--build-rootfs " "--outdir %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct")))) + # TODO this doesn't have to be x86-specific @only_for_arch(['i586', 'i686', 'x86_64']) def test_rootfs_indirect_recipes(self): """Test usage of rootfs plugin with rootfs recipes""" @@ -367,8 +361,9 @@ class Wic(WicTestCase): "--rootfs rootfs1=core-image-minimal " "--rootfs rootfs2=core-image-minimal " "--outdir %s" % self.resultdir) - self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-multi-rootfs*.direct")))) + # TODO this doesn't have to be x86-specific @only_for_arch(['i586', 'i686', 'x86_64']) def test_rootfs_artifacts(self): """Test usage of rootfs plugin with rootfs paths""" @@ -386,7 +381,7 @@ class Wic(WicTestCase): "--rootfs-dir rootfs1=%(image_rootfs)s " "--rootfs-dir rootfs2=%(image_rootfs)s " "--outdir %(resultdir)s" % bbvars) - self.assertEqual(1, len(glob(self.resultdir + "%(wks)s-*.direct" % bbvars))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "%(wks)s-*.direct" % bbvars)))) def test_exclude_path(self): """Test --exclude-path wks option.""" @@ -407,7 +402,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r % (wks_file, self.resultdir)) os.remove(wks_file) - wicout = glob(self.resultdir + "%s-*direct" % 'temp') + wicout = glob(os.path.join(self.resultdir, "%s-*direct" % 'temp')) self.assertEqual(1, len(wicout)) wicimg = wicout[0] @@ -694,8 +689,8 @@ part /etc --source rootfs --fstype=ext4 --change-directory=etc os.environ['PATH'] = get_bb_var("PATH", "wic-tools") # Get stock fstab from base-files recipe - self.assertEqual(0, bitbake('base-files -c do_install').status) - bf_fstab = os.path.join(get_bb_var('D', 'base-files'), 'etc/fstab') + bitbake('base-files -c do_install') + bf_fstab = os.path.join(get_bb_var('D', 'base-files'), 'etc', 'fstab') self.assertEqual(True, os.path.exists(bf_fstab)) bf_fstab_md5sum = runCmd('md5sum %s 2>/dev/null' % bf_fstab).output.split(" ")[0] @@ -750,7 +745,7 @@ part /etc --source rootfs --fstype=ext4 --change-directory=etc runCmd("wic create wictestdisk " "--image-name core-image-minimal " "--extra-space %i -o %s" % (extraspace ,self.resultdir)) - wicout = glob(self.resultdir + "wictestdisk-*.direct") + wicout = glob(os.path.join(self.resultdir, "wictestdisk-*.direct")) self.assertEqual(1, len(wicout)) size = os.path.getsize(wicout[0]) self.assertTrue(size > extraspace) @@ -761,15 +756,15 @@ class Wic2(WicTestCase): """Test generation of .bmap file -m option""" cmd = "wic create wictestdisk -e core-image-minimal -m -o %s" % self.resultdir runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct")))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct.bmap")))) 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 runCmd(cmd) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct")))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct.bmap")))) def test_image_env(self): """Test generation of <image>.env files.""" @@ -805,7 +800,7 @@ class Wic2(WicTestCase): "--image-name=%s -v %s -n %s -o %s" % (image, imgenvdir, native_sysroot, self.resultdir)) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct")))) def test_image_vars_dir_long(self): """Test image vars directory selection --vars option""" @@ -820,20 +815,19 @@ class Wic2(WicTestCase): "--outdir %s" % (image, imgenvdir, native_sysroot, self.resultdir)) - self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct")))) - @only_for_arch(['i586', 'i686', 'x86_64']) + @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64']) def test_wic_image_type(self): """Test building wic images by bitbake""" config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\ 'MACHINE_FEATURES:append = " efi"\n' self.append_config(config) - self.assertEqual(0, bitbake('wic-image-minimal').status) + bitbake('wic-image-minimal') self.remove_config(config) - bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE']) - deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] - machine = bb_vars['MACHINE'] + deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE') + machine = self.td['MACHINE'] prefix = os.path.join(deploy_dir, 'wic-image-minimal-%s.' % machine) # check if we have result image and manifests symlinks # pointing to existing files @@ -842,13 +836,15 @@ class Wic2(WicTestCase): self.assertTrue(os.path.islink(path)) self.assertTrue(os.path.isfile(os.path.realpath(path))) + # TODO this should work on aarch64 @only_for_arch(['i586', 'i686', 'x86_64']) + @OETestTag("runqemu") def test_qemu(self): """Test wic-image-minimal under qemu""" config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\ 'MACHINE_FEATURES:append = " efi"\n' self.append_config(config) - self.assertEqual(0, bitbake('wic-image-minimal').status) + bitbake('wic-image-minimal') self.remove_config(config) with runqemu('wic-image-minimal', ssh=False, runqemuparams='nographic') as qemu: @@ -863,11 +859,12 @@ class Wic2(WicTestCase): self.assertEqual(output, 'UUID=2c71ef06-a81d-4735-9d3a-379b69c6bdba\t/media\text4\tdefaults\t0\t0') @only_for_arch(['i586', 'i686', 'x86_64']) + @OETestTag("runqemu") def test_qemu_efi(self): """Test core-image-minimal efi image under qemu""" config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "mkefidisk.wks"\n' self.append_config(config) - self.assertEqual(0, bitbake('core-image-minimal ovmf').status) + bitbake('core-image-minimal ovmf') self.remove_config(config) with runqemu('core-image-minimal', ssh=False, @@ -900,7 +897,7 @@ class Wic2(WicTestCase): wksname = os.path.splitext(os.path.basename(wkspath))[0] - wicout = glob(self.resultdir + "%s-*direct" % wksname) + wicout = glob(os.path.join(self.resultdir, "%s-*direct" % wksname)) if not wicout: return (p, None) @@ -1045,18 +1042,19 @@ class Wic2(WicTestCase): size = int(size[:-3]) self.assertGreaterEqual(size, 204800) - @only_for_arch(['i586', 'i686', 'x86_64']) + @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64']) + @OETestTag("runqemu") def test_rawcopy_plugin_qemu(self): """Test rawcopy plugin in qemu""" # build ext4 and then use it for a wic image config = 'IMAGE_FSTYPES = "ext4"\n' self.append_config(config) - self.assertEqual(0, bitbake('core-image-minimal').status) + bitbake('core-image-minimal') self.remove_config(config) config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_rawcopy_plugin.wks.in"\n' self.append_config(config) - self.assertEqual(0, bitbake('core-image-minimal-mtdutils').status) + bitbake('core-image-minimal-mtdutils') self.remove_config(config) with runqemu('core-image-minimal-mtdutils', ssh=False, @@ -1069,7 +1067,7 @@ class Wic2(WicTestCase): def _rawcopy_plugin(self, fstype): """Test rawcopy plugin""" img = 'core-image-minimal' - machine = get_bb_var('MACHINE', img) + machine = self.td["MACHINE"] params = ',unpack' if fstype.endswith('.gz') else '' with NamedTemporaryFile("w", suffix=".wks") as wks: wks.write('part / --source rawcopy --sourceparams="file=%s-%s.%s%s"\n'\ @@ -1078,7 +1076,7 @@ class Wic2(WicTestCase): cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] - out = glob(self.resultdir + "%s-*direct" % wksname) + out = glob(os.path.join(self.resultdir, "%s-*direct" % wksname)) self.assertEqual(1, len(out)) def test_rawcopy_plugin(self): @@ -1096,14 +1094,13 @@ class Wic2(WicTestCase): """Test empty plugin""" config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_empty_plugin.wks"\n' self.append_config(config) - self.assertEqual(0, bitbake('core-image-minimal').status) + bitbake('core-image-minimal') self.remove_config(config) + deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE') + machine = self.td['MACHINE'] - bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE']) - deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] - machine = bb_vars['MACHINE'] image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine) - self.assertEqual(True, os.path.exists(image_path)) + self.assertTrue(os.path.exists(image_path)) sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') @@ -1113,11 +1110,12 @@ class Wic2(WicTestCase): self.assertEqual('1', result.output) @only_for_arch(['i586', 'i686', 'x86_64']) + @OETestTag("runqemu") def test_biosplusefi_plugin_qemu(self): """Test biosplusefi plugin in qemu""" config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_biosplusefi_plugin.wks"\nMACHINE_FEATURES:append = " efi"\n' self.append_config(config) - self.assertEqual(0, bitbake('core-image-minimal').status) + bitbake('core-image-minimal') self.remove_config(config) with runqemu('core-image-minimal', ssh=False, @@ -1155,7 +1153,7 @@ class Wic2(WicTestCase): # The easiest way to work-around this issue is to make sure we already built an image here, hence the bitbake call config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_biosplusefi_plugin.wks"\nMACHINE_FEATURES:append = " efi"\n' self.append_config(config) - self.assertEqual(0, bitbake('core-image-minimal').status) + bitbake('core-image-minimal') self.remove_config(config) img = 'core-image-minimal' @@ -1167,10 +1165,12 @@ class Wic2(WicTestCase): cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] - out = glob(self.resultdir + "%s-*.direct" % wksname) + out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname)) self.assertEqual(1, len(out)) + # TODO this test could also work on aarch64 @only_for_arch(['i586', 'i686', 'x86_64']) + @OETestTag("runqemu") def test_efi_plugin_unified_kernel_image_qemu(self): """Test efi plugin's Unified Kernel Image feature in qemu""" config = 'IMAGE_FSTYPES = "wic"\n'\ @@ -1178,7 +1178,7 @@ class Wic2(WicTestCase): 'WKS_FILE = "test_efi_plugin.wks"\n'\ 'MACHINE_FEATURES:append = " efi"\n' self.append_config(config) - self.assertEqual(0, bitbake('core-image-minimal core-image-minimal-initramfs ovmf').status) + bitbake('core-image-minimal core-image-minimal-initramfs ovmf') self.remove_config(config) with runqemu('core-image-minimal', ssh=False, @@ -1215,7 +1215,7 @@ class Wic2(WicTestCase): cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] - out = glob(self.resultdir + "%s-*direct" % wksname) + out = glob(os.path.join(self.resultdir, "%s-*direct" % wksname)) self.assertEqual(1, len(out)) def test_kickstart_parser(self): @@ -1227,7 +1227,7 @@ class Wic2(WicTestCase): cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir) runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] - out = glob(self.resultdir + "%s-*direct" % wksname) + out = glob(os.path.join(self.resultdir, "%s-*direct" % wksname)) self.assertEqual(1, len(out)) def test_image_bootpart_globbed(self): @@ -1238,11 +1238,11 @@ class Wic2(WicTestCase): self.append_config(config) runCmd(cmd) self.remove_config(config) - self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) + self.assertEqual(1, len(glob(os.path.join(self.resultdir, "sdimage-bootpart-*direct")))) def test_sparse_copy(self): """Test sparse_copy with FIEMAP and SEEK_HOLE filemap APIs""" - libpath = os.path.join(get_bb_var('COREBASE'), 'scripts', 'lib', 'wic') + libpath = os.path.join(self.td['COREBASE'], 'scripts', 'lib', 'wic') sys.path.insert(0, libpath) from filemap import FilemapFiemap, FilemapSeek, sparse_copy, ErrorNotSupp with NamedTemporaryFile("w", suffix=".wic-sparse") as sparse: @@ -1268,12 +1268,86 @@ class Wic2(WicTestCase): self.assertEqual(dest_stat.st_blocks, 8) os.unlink(dest) + def test_mkfs_extraopts(self): + """Test wks option --mkfs-extraopts for empty and not empty partitions""" + img = 'core-image-minimal' + with NamedTemporaryFile("w", suffix=".wks") as wks: + wks.writelines( + ['part ext2 --fstype ext2 --source rootfs --mkfs-extraopts "-D -F -i 8192"\n', + "part btrfs --fstype btrfs --source rootfs --size 40M --mkfs-extraopts='--quiet'\n", + 'part squash --fstype squashfs --source rootfs --mkfs-extraopts "-no-sparse -b 4096"\n', + 'part emptyvfat --fstype vfat --size 1M --mkfs-extraopts "-S 1024 -s 64"\n', + 'part emptymsdos --fstype msdos --size 1M --mkfs-extraopts "-S 1024 -s 64"\n', + 'part emptyext2 --fstype ext2 --size 1M --mkfs-extraopts "-D -F -i 8192"\n', + '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) + runCmd(cmd) + wksname = os.path.splitext(os.path.basename(wks.name))[0] + out = glob(os.path.join(self.resultdir, "%s-*direct" % wksname)) + self.assertEqual(1, len(out)) + + @only_for_arch(['i586', 'i686', 'x86_64']) + @OETestTag("runqemu") + def test_expand_mbr_image(self): + """Test wic write --expand command for mbr image""" + # build an image + config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "directdisk.wks"\n' + self.append_config(config) + bitbake('core-image-minimal') + + # get path to the image + deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE') + machine = self.td['MACHINE'] + image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine) + + self.remove_config(config) + + try: + # expand image to 1G + new_image_path = None + with NamedTemporaryFile(mode='wb', suffix='.wic.exp', + dir=deploy_dir, delete=False) as sparse: + sparse.truncate(1024 ** 3) + new_image_path = sparse.name + + 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) + runCmd(cmd) + + # check if partitions are expanded + orig = runCmd("wic ls %s -n %s" % (image_path, sysroot)) + exp = runCmd("wic ls %s -n %s" % (new_image_path, sysroot)) + orig_sizes = [int(line.split()[3]) for line in orig.output.split('\n')[1:]] + exp_sizes = [int(line.split()[3]) for line in exp.output.split('\n')[1:]] + self.assertEqual(orig_sizes[0], exp_sizes[0]) # first partition is not resized + self.assertTrue(orig_sizes[1] < exp_sizes[1]) + + # Check if all free space is partitioned + result = runCmd("%s/usr/sbin/sfdisk -F %s" % (sysroot, new_image_path)) + self.assertTrue("0 B, 0 bytes, 0 sectors" in result.output) + + os.rename(image_path, image_path + '.bak') + os.rename(new_image_path, image_path) + + # Check if it boots in qemu + with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic') as qemu: + cmd = "ls /etc/" + status, output = qemu.run_serial('true') + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + finally: + if os.path.exists(new_image_path): + os.unlink(new_image_path) + if os.path.exists(image_path + '.bak'): + os.rename(image_path + '.bak', image_path) + +class ModifyTests(WicTestCase): def test_wic_ls(self): """Test listing image content using 'wic ls'""" runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "-D -o %s" % self.resultdir) - images = glob(self.resultdir + "wictestdisk-*.direct") + images = glob(os.path.join(self.resultdir, "wictestdisk-*.direct")) self.assertEqual(1, len(images)) sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') @@ -1291,7 +1365,7 @@ class Wic2(WicTestCase): runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "-D -o %s" % self.resultdir) - images = glob(self.resultdir + "wictestdisk-*.direct") + images = glob(os.path.join(self.resultdir, "wictestdisk-*.direct")) self.assertEqual(1, len(images)) sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') @@ -1337,105 +1411,35 @@ class Wic2(WicTestCase): runCmd("wic create mkefidisk " "--image-name=core-image-minimal " "-D -o %s" % self.resultdir) - images = glob(self.resultdir + "mkefidisk-*.direct") + images = glob(os.path.join(self.resultdir, "mkefidisk-*.direct")) self.assertEqual(1, len(images)) sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') + # Not bulletproof but hopefully sufficient + kerneltype = get_bb_var('KERNEL_IMAGETYPE', 'virtual/kernel') # list directory content of the first partition result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) - self.assertIn('\nBZIMAGE ', result.output) + self.assertIn('\n%s ' % kerneltype.upper(), result.output) self.assertIn('\nEFI <DIR> ', result.output) - # remove file - runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot)) + # remove file. EFI partitions are case-insensitive so exercise that too + runCmd("wic rm %s:1/%s -n %s" % (images[0], kerneltype.lower(), sysroot)) # remove directory 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.assertNotIn('\nBZIMAGE ', result.output) + self.assertNotIn('\n%s ' % kerneltype.upper(), result.output) self.assertNotIn('\nEFI <DIR> ', result.output) - def test_mkfs_extraopts(self): - """Test wks option --mkfs-extraopts for empty and not empty partitions""" - img = 'core-image-minimal' - with NamedTemporaryFile("w", suffix=".wks") as wks: - wks.writelines( - ['part ext2 --fstype ext2 --source rootfs --mkfs-extraopts "-D -F -i 8192"\n', - "part btrfs --fstype btrfs --source rootfs --size 40M --mkfs-extraopts='--quiet'\n", - 'part squash --fstype squashfs --source rootfs --mkfs-extraopts "-no-sparse -b 4096"\n', - 'part emptyvfat --fstype vfat --size 1M --mkfs-extraopts "-S 1024 -s 64"\n', - 'part emptymsdos --fstype msdos --size 1M --mkfs-extraopts "-S 1024 -s 64"\n', - 'part emptyext2 --fstype ext2 --size 1M --mkfs-extraopts "-D -F -i 8192"\n', - '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) - runCmd(cmd) - wksname = os.path.splitext(os.path.basename(wks.name))[0] - out = glob(self.resultdir + "%s-*direct" % wksname) - self.assertEqual(1, len(out)) - - def test_expand_mbr_image(self): - """Test wic write --expand command for mbr image""" - # build an image - config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "directdisk.wks"\n' - self.append_config(config) - self.assertEqual(0, bitbake('core-image-minimal').status) - - # get path to the image - bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE']) - deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] - machine = bb_vars['MACHINE'] - image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine) - - self.remove_config(config) - - try: - # expand image to 1G - new_image_path = None - with NamedTemporaryFile(mode='wb', suffix='.wic.exp', - dir=deploy_dir, delete=False) as sparse: - sparse.truncate(1024 ** 3) - new_image_path = sparse.name - - 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) - runCmd(cmd) - - # check if partitions are expanded - orig = runCmd("wic ls %s -n %s" % (image_path, sysroot)) - exp = runCmd("wic ls %s -n %s" % (new_image_path, sysroot)) - orig_sizes = [int(line.split()[3]) for line in orig.output.split('\n')[1:]] - exp_sizes = [int(line.split()[3]) for line in exp.output.split('\n')[1:]] - self.assertEqual(orig_sizes[0], exp_sizes[0]) # first partition is not resized - self.assertTrue(orig_sizes[1] < exp_sizes[1]) - - # Check if all free space is partitioned - result = runCmd("%s/usr/sbin/sfdisk -F %s" % (sysroot, new_image_path)) - self.assertTrue("0 B, 0 bytes, 0 sectors" in result.output) - - bb.utils.rename(image_path, image_path + '.bak') - bb.utils.rename(new_image_path, image_path) - - # Check if it boots in qemu - with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic') as qemu: - cmd = "ls /etc/" - status, output = qemu.run_serial('true') - self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) - finally: - if os.path.exists(new_image_path): - os.unlink(new_image_path) - if os.path.exists(image_path + '.bak'): - bb.utils.rename(image_path + '.bak', image_path) - def test_wic_ls_ext(self): """Test listing content of the ext partition using 'wic ls'""" runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "-D -o %s" % self.resultdir) - images = glob(self.resultdir + "wictestdisk-*.direct") + images = glob(os.path.join(self.resultdir, "wictestdisk-*.direct")) self.assertEqual(1, len(images)) sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') @@ -1450,7 +1454,7 @@ class Wic2(WicTestCase): runCmd("wic create wictestdisk " "--image-name=core-image-minimal " "-D -o %s" % self.resultdir) - images = glob(self.resultdir + "wictestdisk-*.direct") + images = glob(os.path.join(self.resultdir, "wictestdisk-*.direct")) self.assertEqual(1, len(images)) sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') @@ -1486,7 +1490,7 @@ class Wic2(WicTestCase): runCmd("wic create mkefidisk " "--image-name=core-image-minimal " "-D -o %s" % self.resultdir) - images = glob(self.resultdir + "mkefidisk-*.direct") + images = glob(os.path.join(self.resultdir, "mkefidisk-*.direct")) self.assertEqual(1, len(images)) sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') |