diff options
Diffstat (limited to 'poky/meta/lib/oeqa')
27 files changed, 340 insertions, 77 deletions
diff --git a/poky/meta/lib/oeqa/core/target/qemu.py b/poky/meta/lib/oeqa/core/target/qemu.py index bf3b633f04..538bf12b6a 100644 --- a/poky/meta/lib/oeqa/core/target/qemu.py +++ b/poky/meta/lib/oeqa/core/target/qemu.py @@ -12,15 +12,14 @@ from oeqa.utils.qemurunner import QemuRunner supported_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic'] class OEQemuTarget(OESSHTarget): - def __init__(self, logger, ip, server_ip, timeout=300, user='root', + def __init__(self, logger, server_ip, timeout=300, user='root', port=None, machine='', rootfs='', kernel='', kvm=False, dump_dir='', dump_host_cmds='', display='', bootlog='', tmpdir='', dir_image='', boottime=60, **kwargs): - super(OEQemuTarget, self).__init__(logger, ip, server_ip, timeout, + super(OEQemuTarget, self).__init__(logger, None, server_ip, timeout, user, port) - self.ip = ip self.server_ip = server_ip self.machine = machine self.rootfs = rootfs diff --git a/poky/meta/lib/oeqa/manual/bsp-qemu.json b/poky/meta/lib/oeqa/manual/bsp-qemu.json index 1260af4b4c..cf51b6ab1c 100644 --- a/poky/meta/lib/oeqa/manual/bsp-qemu.json +++ b/poky/meta/lib/oeqa/manual/bsp-qemu.json @@ -10,7 +10,7 @@ ], "execution": { "1": { - "action": "Build a kernel with KVM enabled \n\nIn Local.conf add \n\nQEMU_USE_KVM = \"${@ 'intel-corei7-64 intel-core2-32 qemux86 qemux86-64' if os.access('/dev/kvm', os.R_OK|os.W_OK) else '' }\" \n\n ", + "action": "Build a kernel with KVM enabled \n\nIn Local.conf add \n\nQEMU_USE_KVM = \"${@ '1' if os.access('/dev/kvm', os.R_OK|os.W_OK) else '0' }\" \n\n ", "expected_results": "" }, "2": { @@ -219,4 +219,4 @@ "summary": "check_bash_in_image" } } -]
\ No newline at end of file +] diff --git a/poky/meta/lib/oeqa/runtime/cases/buildcpio.py b/poky/meta/lib/oeqa/runtime/cases/buildcpio.py index 79b22d04dd..a61d1e0304 100644 --- a/poky/meta/lib/oeqa/runtime/cases/buildcpio.py +++ b/poky/meta/lib/oeqa/runtime/cases/buildcpio.py @@ -1,7 +1,7 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID -from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage from oeqa.runtime.utils.targetbuildproject import TargetBuildProject @@ -13,17 +13,18 @@ class BuildCpioTest(OERuntimeTestCase): cls.project = TargetBuildProject(cls.tc.target, uri, dl_dir = cls.tc.td['DL_DIR']) - cls.project.download_archive() @classmethod def tearDownClass(cls): cls.project.clean() @OETestID(205) - @skipIfNotFeature('tools-sdk', - 'Test requires tools-sdk to be in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['gcc']) + @OEHasPackage(['make']) + @OEHasPackage(['autoconf']) def test_cpio(self): + self.project.download_archive() self.project.run_configure() self.project.run_make() self.project.run_install() diff --git a/poky/meta/lib/oeqa/runtime/cases/buildgalculator.py b/poky/meta/lib/oeqa/runtime/cases/buildgalculator.py index 7c9d4a392b..a0a0032083 100644 --- a/poky/meta/lib/oeqa/runtime/cases/buildgalculator.py +++ b/poky/meta/lib/oeqa/runtime/cases/buildgalculator.py @@ -1,7 +1,7 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID -from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage from oeqa.runtime.utils.targetbuildproject import TargetBuildProject @@ -13,16 +13,17 @@ class GalculatorTest(OERuntimeTestCase): cls.project = TargetBuildProject(cls.tc.target, uri, dl_dir = cls.tc.td['DL_DIR']) - cls.project.download_archive() @classmethod def tearDownClass(cls): cls.project.clean() @OETestID(1526) - @skipIfNotFeature('tools-sdk', - 'Test requires tools-sdk to be in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['gcc']) + @OEHasPackage(['make']) + @OEHasPackage(['autoconf']) def test_galculator(self): + self.project.download_archive() self.project.run_configure() self.project.run_make() diff --git a/poky/meta/lib/oeqa/runtime/cases/buildlzip.py b/poky/meta/lib/oeqa/runtime/cases/buildlzip.py index ca3fead2e4..5b455a0790 100644 --- a/poky/meta/lib/oeqa/runtime/cases/buildlzip.py +++ b/poky/meta/lib/oeqa/runtime/cases/buildlzip.py @@ -1,7 +1,7 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID -from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage from oeqa.runtime.utils.targetbuildproject import TargetBuildProject @@ -14,21 +14,19 @@ class BuildLzipTest(OERuntimeTestCase): cls.project = TargetBuildProject(cls.tc.target, uri, dl_dir = cls.tc.td['DL_DIR']) - cls.project.download_archive() @classmethod def tearDownClass(cls): cls.project.clean() @OETestID(206) - @skipIfNotFeature('tools-sdk', - 'Test requires tools-sdk to be in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['gcc']) + @OEHasPackage(['make']) + @OEHasPackage(['autoconf']) def test_lzip(self): + self.project.download_archive() self.project.run_configure() self.project.run_make() self.project.run_install() - @classmethod - def tearDownClass(self): - self.project.clean() diff --git a/poky/meta/lib/oeqa/runtime/cases/date.py b/poky/meta/lib/oeqa/runtime/cases/date.py index ece7338de7..0887b831f4 100644 --- a/poky/meta/lib/oeqa/runtime/cases/date.py +++ b/poky/meta/lib/oeqa/runtime/cases/date.py @@ -3,6 +3,7 @@ import re from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID +from oeqa.runtime.decorator.package import OEHasPackage class DateTest(OERuntimeTestCase): @@ -18,6 +19,7 @@ class DateTest(OERuntimeTestCase): @OETestID(211) @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['coreutils', 'busybox']) def test_date(self): (status, output) = self.target.run('date +"%Y-%m-%d %T"') msg = 'Failed to get initial date, output: %s' % output diff --git a/poky/meta/lib/oeqa/runtime/cases/df.py b/poky/meta/lib/oeqa/runtime/cases/df.py index aecc32d7ce..e0b6bb839d 100644 --- a/poky/meta/lib/oeqa/runtime/cases/df.py +++ b/poky/meta/lib/oeqa/runtime/cases/df.py @@ -1,11 +1,13 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID +from oeqa.runtime.decorator.package import OEHasPackage class DfTest(OERuntimeTestCase): @OETestID(234) @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['coreutils', 'busybox']) def test_df(self): cmd = "df / | sed -n '2p' | awk '{print $4}'" (status,output) = self.target.run(cmd) diff --git a/poky/meta/lib/oeqa/runtime/cases/gcc.py b/poky/meta/lib/oeqa/runtime/cases/gcc.py index 911083156f..8265c59f23 100644 --- a/poky/meta/lib/oeqa/runtime/cases/gcc.py +++ b/poky/meta/lib/oeqa/runtime/cases/gcc.py @@ -3,12 +3,12 @@ import os from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID -from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage class GccCompileTest(OERuntimeTestCase): @classmethod - def setUpClass(cls): + def setUp(cls): dst = '/tmp/' src = os.path.join(cls.tc.files_dir, 'test.c') cls.tc.target.copyTo(src, dst) @@ -20,14 +20,13 @@ class GccCompileTest(OERuntimeTestCase): cls.tc.target.copyTo(src, dst) @classmethod - def tearDownClass(cls): + def tearDown(cls): files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile' cls.tc.target.run('rm %s' % files) @OETestID(203) - @skipIfNotFeature('tools-sdk', - 'Test requires tools-sdk to be in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['gcc']) def test_gcc_compile(self): status, output = self.target.run('gcc /tmp/test.c -o /tmp/test -lm') msg = 'gcc compile failed, output: %s' % output @@ -38,9 +37,8 @@ class GccCompileTest(OERuntimeTestCase): self.assertEqual(status, 0, msg=msg) @OETestID(200) - @skipIfNotFeature('tools-sdk', - 'Test requires tools-sdk to be in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['g++']) def test_gpp_compile(self): status, output = self.target.run('g++ /tmp/test.c -o /tmp/test -lm') msg = 'g++ compile failed, output: %s' % output @@ -51,9 +49,8 @@ class GccCompileTest(OERuntimeTestCase): self.assertEqual(status, 0, msg=msg) @OETestID(1142) - @skipIfNotFeature('tools-sdk', - 'Test requires tools-sdk to be in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['g++']) def test_gpp2_compile(self): status, output = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm') msg = 'g++ compile failed, output: %s' % output @@ -64,9 +61,9 @@ class GccCompileTest(OERuntimeTestCase): self.assertEqual(status, 0, msg=msg) @OETestID(204) - @skipIfNotFeature('tools-sdk', - 'Test requires tools-sdk to be in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['gcc']) + @OEHasPackage(['make']) def test_make(self): status, output = self.target.run('cd /tmp; make -f testmakefile') msg = 'running make failed, output %s' % output diff --git a/poky/meta/lib/oeqa/runtime/cases/kernelmodule.py b/poky/meta/lib/oeqa/runtime/cases/kernelmodule.py index de1a5aa445..27a2c35b71 100644 --- a/poky/meta/lib/oeqa/runtime/cases/kernelmodule.py +++ b/poky/meta/lib/oeqa/runtime/cases/kernelmodule.py @@ -4,11 +4,12 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage class KernelModuleTest(OERuntimeTestCase): @classmethod - def setUpClass(cls): + def setUp(cls): src = os.path.join(cls.tc.runtime_files_dir, 'hellomod.c') dst = '/tmp/hellomod.c' cls.tc.target.copyTo(src, dst) @@ -18,7 +19,7 @@ class KernelModuleTest(OERuntimeTestCase): cls.tc.target.copyTo(src, dst) @classmethod - def tearDownClass(cls): + def tearDown(cls): files = '/tmp/Makefile /tmp/hellomod.c' cls.tc.target.run('rm %s' % files) @@ -26,6 +27,9 @@ class KernelModuleTest(OERuntimeTestCase): @skipIfNotFeature('tools-sdk', 'Test requires tools-sdk to be in IMAGE_FEATURES') @OETestDepends(['gcc.GccCompileTest.test_gcc_compile']) + @OEHasPackage(['kernel-devsrc']) + @OEHasPackage(['make']) + @OEHasPackage(['gcc']) def test_kernel_module(self): cmds = [ 'cd /usr/src/kernel && make scripts prepare', diff --git a/poky/meta/lib/oeqa/runtime/cases/opkg.py b/poky/meta/lib/oeqa/runtime/cases/opkg.py index 29e990269b..693f5d68c9 100644 --- a/poky/meta/lib/oeqa/runtime/cases/opkg.py +++ b/poky/meta/lib/oeqa/runtime/cases/opkg.py @@ -16,7 +16,7 @@ class OpkgTest(OERuntimeTestCase): class OpkgRepoTest(OpkgTest): @classmethod - def setUpClass(cls): + def setUp(cls): allarchfeed = 'all' if cls.tc.td["MULTILIB_VARIANTS"]: allarchfeed = cls.tc.td["TUNE_PKGARCH"] @@ -25,7 +25,7 @@ class OpkgRepoTest(OpkgTest): cls.repo_server.start() @classmethod - def tearDownClass(cls): + def tearDown(cls): cls.repo_server.stop() def setup_source_config_for_package_install(self): diff --git a/poky/meta/lib/oeqa/runtime/cases/ptest.py b/poky/meta/lib/oeqa/runtime/cases/ptest.py index 77ae7b6b86..0972a583ee 100644 --- a/poky/meta/lib/oeqa/runtime/cases/ptest.py +++ b/poky/meta/lib/oeqa/runtime/cases/ptest.py @@ -5,6 +5,7 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage from oeqa.utils.logparser import Lparser, Result class PtestRunnerTest(OERuntimeTestCase): @@ -52,6 +53,7 @@ class PtestRunnerTest(OERuntimeTestCase): @OETestID(1600) @skipIfNotFeature('ptest', 'Test requires ptest to be in DISTRO_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['ptest-runner']) @unittest.expectedFailure def test_ptestrunner(self): status, output = self.target.run('which ptest-runner', 0) diff --git a/poky/meta/lib/oeqa/runtime/cases/python.py b/poky/meta/lib/oeqa/runtime/cases/python.py index 4419a9f639..66ab4d25f3 100644 --- a/poky/meta/lib/oeqa/runtime/cases/python.py +++ b/poky/meta/lib/oeqa/runtime/cases/python.py @@ -1,16 +1,12 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID +from oeqa.runtime.decorator.package import OEHasPackage class PythonTest(OERuntimeTestCase): - @classmethod - def setUpClass(cls): - import unittest - if "python3-core" not in cls.tc.image_packages: - raise unittest.SkipTest("Python3 not on target") - @OETestID(965) @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['python3-core']) def test_python3(self): cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" status, output = self.target.run(cmd) diff --git a/poky/meta/lib/oeqa/runtime/cases/rpm.py b/poky/meta/lib/oeqa/runtime/cases/rpm.py index 1e5e4631d3..de92157c52 100644 --- a/poky/meta/lib/oeqa/runtime/cases/rpm.py +++ b/poky/meta/lib/oeqa/runtime/cases/rpm.py @@ -10,11 +10,6 @@ from oeqa.core.utils.path import findFile class RpmBasicTest(OERuntimeTestCase): - @classmethod - def setUpClass(cls): - if cls.tc.td['PACKAGE_CLASSES'].split()[0] != 'package_rpm': - cls.skipTest('Tests require image to be build from rpm') - @OETestID(960) @OEHasPackage(['rpm']) @OETestDepends(['ssh.SSHTest.test_ssh']) @@ -26,6 +21,9 @@ class RpmBasicTest(OERuntimeTestCase): @OETestID(191) @OETestDepends(['rpm.RpmBasicTest.test_rpm_help']) def test_rpm_query(self): + status, output = self.target.run('ls /var/lib/rpm/') + if status != 0: + self.skipTest('No /var/lib/rpm on target') status, output = self.target.run('rpm -q rpm') msg = 'status and output: %s and %s' % (status, output) self.assertEqual(status, 0, msg=msg) @@ -34,30 +32,25 @@ class RpmInstallRemoveTest(OERuntimeTestCase): @classmethod def setUpClass(cls): - if cls.tc.td['PACKAGE_CLASSES'].split()[0] != 'package_rpm': - cls.skipTest('Tests require image to be build from rpm') - pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_') rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch) # Pick base-passwd-doc as a test file to get installed, because it's small # and it will always be built for standard targets rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch + if not os.path.exists(rpmdir): + return for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc): - test_file = os.path.join(rpmdir, f) - dst = '/tmp/base-passwd-doc.rpm' - cls.tc.target.copyTo(test_file, dst) - - @classmethod - def tearDownClass(cls): - dst = '/tmp/base-passwd-doc.rpm' - cls.tc.target.run('rm -f %s' % dst) + cls.test_file = os.path.join(rpmdir, f) + cls.dst = '/tmp/base-passwd-doc.rpm' @OETestID(192) - @OETestDepends(['rpm.RpmBasicTest.test_rpm_help']) + @OETestDepends(['rpm.RpmBasicTest.test_rpm_query']) def test_rpm_install(self): + self.tc.target.copyTo(self.test_file, self.dst) status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm') msg = 'Failed to install base-passwd-doc package: %s' % output self.assertEqual(status, 0, msg=msg) + self.tc.target.run('rm -f %s' % self.dst) @OETestID(194) @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install']) @@ -118,6 +111,8 @@ class RpmInstallRemoveTest(OERuntimeTestCase): msg = 'Failed to find database files under /var/lib/rpm/ as __db.xxx' self.assertEqual(0, status, msg=msg) + self.tc.target.copyTo(self.test_file, self.dst) + # Remove the package just in case self.target.run('rpm -e base-passwd-doc') @@ -131,6 +126,8 @@ class RpmInstallRemoveTest(OERuntimeTestCase): msg = 'Failed to remove base-passwd-doc package. Reason: {}'.format(output) self.assertEqual(0, status, msg=msg) + self.tc.target.run('rm -f %s' % self.dst) + # if using systemd this should ensure all entries are flushed to /var status, output = self.target.run("journalctl --sync") # Get the amount of entries in the log file diff --git a/poky/meta/lib/oeqa/runtime/cases/scp.py b/poky/meta/lib/oeqa/runtime/cases/scp.py index f488a6175b..8f895da95a 100644 --- a/poky/meta/lib/oeqa/runtime/cases/scp.py +++ b/poky/meta/lib/oeqa/runtime/cases/scp.py @@ -4,6 +4,7 @@ from tempfile import mkstemp from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID +from oeqa.runtime.decorator.package import OEHasPackage class ScpTest(OERuntimeTestCase): @@ -20,6 +21,7 @@ class ScpTest(OERuntimeTestCase): @OETestID(220) @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['openssh-scp', 'dropbear']) def test_scp_file(self): dst = '/tmp/test_scp_file' diff --git a/poky/meta/lib/oeqa/runtime/cases/ssh.py b/poky/meta/lib/oeqa/runtime/cases/ssh.py index eca167969a..0b1ea7bcc2 100644 --- a/poky/meta/lib/oeqa/runtime/cases/ssh.py +++ b/poky/meta/lib/oeqa/runtime/cases/ssh.py @@ -1,11 +1,13 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID +from oeqa.runtime.decorator.package import OEHasPackage class SSHTest(OERuntimeTestCase): @OETestID(224) @OETestDepends(['ping.PingTest.test_ping']) + @OEHasPackage(['dropbear', 'openssh-sshd']) def test_ssh(self): (status, output) = self.target.run('uname -a') self.assertEqual(status, 0, msg='SSH Test failed: %s' % output) diff --git a/poky/meta/lib/oeqa/runtime/cases/stap.py b/poky/meta/lib/oeqa/runtime/cases/stap.py index 96e197a2d6..c492caffd6 100644 --- a/poky/meta/lib/oeqa/runtime/cases/stap.py +++ b/poky/meta/lib/oeqa/runtime/cases/stap.py @@ -4,17 +4,18 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage class StapTest(OERuntimeTestCase): @classmethod - def setUpClass(cls): + def setUp(cls): src = os.path.join(cls.tc.runtime_files_dir, 'hello.stp') dst = '/tmp/hello.stp' cls.tc.target.copyTo(src, dst) @classmethod - def tearDownClass(cls): + def tearDown(cls): files = '/tmp/hello.stp' cls.tc.target.run('rm %s' % files) @@ -22,6 +23,7 @@ class StapTest(OERuntimeTestCase): @skipIfNotFeature('tools-profile', 'Test requires tools-profile to be in IMAGE_FEATURES') @OETestDepends(['kernelmodule.KernelModuleTest.test_kernel_module']) + @OEHasPackage(['systemtap']) def test_stap(self): cmds = [ 'cd /usr/src/kernel && make scripts prepare', diff --git a/poky/meta/lib/oeqa/runtime/cases/xorg.py b/poky/meta/lib/oeqa/runtime/cases/xorg.py index 2124813e3c..82521c69ac 100644 --- a/poky/meta/lib/oeqa/runtime/cases/xorg.py +++ b/poky/meta/lib/oeqa/runtime/cases/xorg.py @@ -2,6 +2,7 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage class XorgTest(OERuntimeTestCase): @@ -9,6 +10,7 @@ class XorgTest(OERuntimeTestCase): @skipIfNotFeature('x11-base', 'Test requires x11 to be in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['xserver-nodm-init']) def test_xorg_running(self): cmd ='%s | grep -v xinit | grep [X]org' % self.tc.target_cmds['ps'] status, output = self.target.run(cmd) diff --git a/poky/meta/lib/oeqa/runtime/context.py b/poky/meta/lib/oeqa/runtime/context.py index a7f3823996..db0482d68d 100644 --- a/poky/meta/lib/oeqa/runtime/context.py +++ b/poky/meta/lib/oeqa/runtime/context.py @@ -49,7 +49,6 @@ class OERuntimeTestContextExecutor(OETestContextExecutor): default_manifest = 'data/manifest' default_server_ip = '192.168.7.1' default_target_ip = '192.168.7.2' - default_host_dumper_dir = '/tmp/oe-saved-tests' default_extract_dir = 'packages/extracted' def register_commands(self, logger, subparsers): @@ -71,9 +70,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor): % self.default_server_ip) runtime_group.add_argument('--host-dumper-dir', action='store', - default=self.default_host_dumper_dir, - help="Directory where host status is dumped, if tests fails, default: %s" \ - % self.default_host_dumper_dir) + help="Directory where host status is dumped, if tests fails") runtime_group.add_argument('--packages-manifest', action='store', default=self.default_manifest, @@ -101,7 +98,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor): if target_type == 'simpleremote': target = OESSHTarget(logger, target_ip, server_ip, **kwargs) elif target_type == 'qemu': - target = OEQemuTarget(logger, target_ip, server_ip, **kwargs) + target = OEQemuTarget(logger, server_ip, **kwargs) else: # XXX: This code uses the old naming convention for controllers and # targets, the idea it is to leave just targets as the controller diff --git a/poky/meta/lib/oeqa/sdk/testsdk.py b/poky/meta/lib/oeqa/sdk/testsdk.py new file mode 100644 index 0000000000..632ac50d0c --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/testsdk.py @@ -0,0 +1,142 @@ +# Copyright 2018 by Garmin Ltd. or its subsidiaries +# Released under the MIT license (see COPYING.MIT) + +from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor + +class TestSDKBase(object): + @staticmethod + def get_sdk_configuration(d, test_type): + import platform + import oe.lsb + from oeqa.utils.metadata import get_layers + configuration = {'TEST_TYPE': test_type, + 'MACHINE': d.getVar("MACHINE"), + 'SDKMACHINE': d.getVar("SDKMACHINE"), + 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"), + 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"), + 'STARTTIME': d.getVar("DATETIME"), + 'HOST_DISTRO': oe.lsb.distro_identifier().replace(' ', '-'), + 'LAYERS': get_layers(d.getVar("BBLAYERS"))} + return configuration + + @staticmethod + def get_sdk_json_result_dir(d): + json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') + custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") + if custom_json_result_dir: + json_result_dir = custom_json_result_dir + return json_result_dir + + @staticmethod + def get_sdk_result_id(configuration): + return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) + +class TestSDK(TestSDKBase): + context_executor_class = OESDKTestContextExecutor + context_class = OESDKTestContext + test_type = 'sdk' + + def get_tcname(self, d): + """ + Get the name of the SDK file + """ + return d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") + + def extract_sdk(self, tcname, sdk_dir, d): + """ + Extract the SDK to the specified location + """ + import subprocess + + try: + subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True) + except subprocess.CalledProcessError as e: + bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8")) + + def setup_context(self, d): + """ + Return a dictionary of additional arguments that should be passed to + the context_class on construction + """ + return dict() + + def run(self, d): + + import os + import subprocess + import json + import logging + + from bb.utils import export_proxies + from oeqa.utils import make_logger_bitbake_compatible + + pn = d.getVar("PN") + logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) + + # sdk use network for download projects for build + export_proxies(d) + + tcname = self.get_tcname(d) + + if not os.path.exists(tcname): + bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname) + + tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json") + test_data = json.load(open(tdname, "r")) + + target_pkg_manifest = self.context_executor_class._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest")) + host_pkg_manifest = self.context_executor_class._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest")) + + processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS") + if processes: + try: + import testtools, subunit + except ImportError: + bb.warn("Failed to import testtools or subunit, the testcases will run serially") + processes = None + + sdk_dir = d.expand("${WORKDIR}/testimage-sdk/") + bb.utils.remove(sdk_dir, True) + bb.utils.mkdirhier(sdk_dir) + + context_args = self.setup_context(d) + + self.extract_sdk(tcname, sdk_dir, d) + + fail = False + sdk_envs = self.context_executor_class._get_sdk_environs(sdk_dir) + for s in sdk_envs: + sdk_env = sdk_envs[s] + bb.plain("SDK testing environment: %s" % s) + tc = self.context_class(td=test_data, logger=logger, sdk_dir=sdk_dir, + sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, + host_pkg_manifest=host_pkg_manifest, **context_args) + + try: + tc.loadTests(self.context_executor_class.default_cases) + except Exception as e: + import traceback + bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) + + if processes: + result = tc.runTests(processes=int(processes)) + else: + result = tc.runTests() + + component = "%s %s" % (pn, self.context_executor_class.name) + context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) + configuration = self.get_sdk_configuration(d, self.test_type) + result.logDetails(self.get_sdk_json_result_dir(d), + configuration, + self.get_sdk_result_id(configuration)) + result.logSummary(component, context_msg) + + if not result.wasSuccessful(): + fail = True + + if fail: + bb.fatal("%s - FAILED - check the task log and the commands log" % pn) + + diff --git a/poky/meta/lib/oeqa/sdkext/testsdk.py b/poky/meta/lib/oeqa/sdkext/testsdk.py new file mode 100644 index 0000000000..57b2e0e03f --- /dev/null +++ b/poky/meta/lib/oeqa/sdkext/testsdk.py @@ -0,0 +1,104 @@ +# Copyright 2018 by Garmin Ltd. or its subsidiaries +# Released under the MIT license (see COPYING.MIT) + +from oeqa.sdk.testsdk import TestSDKBase + +class TestSDKExt(TestSDKBase): + def run(self, d): + import os + import json + import subprocess + import logging + + from bb.utils import export_proxies + from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak + from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor + + pn = d.getVar("PN") + logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) + + # extensible sdk use network + export_proxies(d) + + subprocesstweak.errors_have_output() + + # extensible sdk can be contaminated if native programs are + # in PATH, i.e. use perl-native instead of eSDK one. + paths_to_avoid = [d.getVar('STAGING_DIR'), + d.getVar('BASE_WORKDIR')] + os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) + + tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh") + if not os.path.exists(tcname): + bb.fatal("The toolchain ext %s is not built. Build it before running the" \ + " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname) + + tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json") + test_data = json.load(open(tdname, "r")) + + target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest")) + host_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest")) + + sdk_dir = d.expand("${WORKDIR}/testsdkext/") + bb.utils.remove(sdk_dir, True) + bb.utils.mkdirhier(sdk_dir) + try: + subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True) + except subprocess.CalledProcessError as e: + msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8") + logfn = os.path.join(sdk_dir, 'preparing_build_system.log') + if os.path.exists(logfn): + msg += '\n\nContents of preparing_build_system.log:\n' + with open(logfn, 'r') as f: + for line in f: + msg += line + bb.fatal(msg) + + fail = False + sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir) + for s in sdk_envs: + bb.plain("Extensible SDK testing environment: %s" % s) + + sdk_env = sdk_envs[s] + + # Use our own SSTATE_DIR and DL_DIR so that updates to the eSDK come from our sstate cache + # and we don't spend hours downloading kernels for the kernel module test + # Abuse auto.conf since local.conf would be overwritten by the SDK + with open(os.path.join(sdk_dir, 'conf', 'auto.conf'), 'a+') as f: + f.write('SSTATE_MIRRORS += " \\n file://.* file://%s/PATH"\n' % test_data.get('SSTATE_DIR')) + f.write('SOURCE_MIRROR_URL = "file://%s"\n' % test_data.get('DL_DIR')) + f.write('INHERIT += "own-mirrors"\n') + f.write('PREMIRRORS_prepend = " git://git.yoctoproject.org/.* git://%s/git2/git.yoctoproject.org.BASENAME \\n "\n' % test_data.get('DL_DIR')) + + # We need to do this in case we have a minimal SDK + subprocess.check_output(". %s > /dev/null; devtool sdk-install meta-extsdk-toolchain" % \ + sdk_env, cwd=sdk_dir, shell=True, stderr=subprocess.STDOUT) + + tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir, + sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, + host_pkg_manifest=host_pkg_manifest) + + try: + tc.loadTests(OESDKExtTestContextExecutor.default_cases) + except Exception as e: + import traceback + bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) + + result = tc.runTests() + + component = "%s %s" % (pn, OESDKExtTestContextExecutor.name) + context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) + configuration = self.get_sdk_configuration(d, 'sdkext') + result.logDetails(self.get_sdk_json_result_dir(d), + configuration, + self.get_sdk_result_id(configuration)) + result.logSummary(component, context_msg) + + if not result.wasSuccessful(): + fail = True + + if fail: + bb.fatal("%s - FAILED - check the task log and the commands log" % pn) + diff --git a/poky/meta/lib/oeqa/selftest/cases/eSDK.py b/poky/meta/lib/oeqa/selftest/cases/eSDK.py index d7aef93991..8eb6ec660c 100644 --- a/poky/meta/lib/oeqa/selftest/cases/eSDK.py +++ b/poky/meta/lib/oeqa/selftest/cases/eSDK.py @@ -2,6 +2,7 @@ import tempfile import shutil import os import glob +import time from oeqa.core.decorator.oeid import OETestID from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars @@ -31,7 +32,7 @@ class oeSDKExtSelfTest(OESelftestTestCase): if not 'shell' in options: options['shell'] = True - runCmd("cd %s; . %s; %s" % (tmpdir_eSDKQA, env_eSDK, cmd), **options) + runCmd("cd %s; unset BBPATH; unset BUILDDIR; . %s; %s" % (tmpdir_eSDKQA, env_eSDK, cmd), **options) @staticmethod def generate_eSDK(image): @@ -95,6 +96,11 @@ SSTATE_MIRRORS = "file://.* file://%s/PATH" @classmethod def tearDownClass(cls): + for i in range(0, 10): + if os.path.exists(os.path.join(cls.tmpdir_eSDKQA, 'bitbake.lock')): + time.sleep(1) + else: + break cls.tmpdirobj.cleanup() super().tearDownClass() diff --git a/poky/meta/lib/oeqa/selftest/cases/runqemu.py b/poky/meta/lib/oeqa/selftest/cases/runqemu.py index 4e35bb97e3..f69d4706a5 100644 --- a/poky/meta/lib/oeqa/selftest/cases/runqemu.py +++ b/poky/meta/lib/oeqa/selftest/cases/runqemu.py @@ -5,6 +5,7 @@ import re import tempfile import time +import oe.types from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd from oeqa.core.decorator.oeid import OETestID @@ -22,6 +23,10 @@ class RunqemuTests(OESelftestTestCase): self.fstypes = "ext4 iso hddimg wic.vmdk wic.qcow2 wic.vdi" self.cmd_common = "runqemu nographic" + kvm = oe.types.qemu_use_kvm(get_bb_var('QEMU_USE_KVM'), 'x86_64') + if kvm: + self.cmd_common += " kvm" + self.write_config( """ MACHINE = "%s" diff --git a/poky/meta/lib/oeqa/targetcontrol.py b/poky/meta/lib/oeqa/targetcontrol.py index 59a9c35a09..1868ad3206 100644 --- a/poky/meta/lib/oeqa/targetcontrol.py +++ b/poky/meta/lib/oeqa/targetcontrol.py @@ -107,13 +107,9 @@ class QemuTarget(BaseTarget): dump_target_cmds = d.getVar("testimage_dump_target") dump_host_cmds = d.getVar("testimage_dump_host") dump_dir = d.getVar("TESTIMAGE_DUMP_DIR") - qemu_use_kvm = d.getVar("QEMU_USE_KVM") - if qemu_use_kvm and \ - (oe.types.boolean(qemu_use_kvm) and "x86" in d.getVar("MACHINE") or \ - d.getVar("MACHINE") in qemu_use_kvm.split()): - use_kvm = True - else: - use_kvm = False + if not dump_dir: + dump_dir = os.path.join(d.getVar('LOG_DIR'), 'runtime-hostdump') + use_kvm = oe.types.qemu_use_kvm(d.getVar('QEMU_USE_KVM'), d.getVar('TARGET_ARCH')) # Log QemuRunner log output to a file import oe.path @@ -196,7 +192,7 @@ class QemuTarget(BaseTarget): else: raise bb.build.FuncFailed("%s - FAILED to re-start qemu - check the task log and the boot log" % self.pn) - def run_serial(self, command, timeout=5): + def run_serial(self, command, timeout=60): return self.runner.run_serial(command, timeout=timeout) diff --git a/poky/meta/lib/oeqa/utils/buildproject.py b/poky/meta/lib/oeqa/utils/buildproject.py index 88e7b7fe27..01a803ab61 100644 --- a/poky/meta/lib/oeqa/utils/buildproject.py +++ b/poky/meta/lib/oeqa/utils/buildproject.py @@ -25,9 +25,12 @@ class BuildProject(metaclass=ABCMeta): self.fname = foldername else: self.fname = re.sub(r'\.tar\.bz2$|\.tar\.gz$|\.tar\.xz$', '', self.archive) + self.needclean = False # Download self.archive to self.localarchive def _download_archive(self): + + self.needclean = True if self.dl_dir and os.path.exists(os.path.join(self.dl_dir, self.archive)): shutil.copyfile(os.path.join(self.dl_dir, self.archive), self.localarchive) return @@ -52,5 +55,7 @@ class BuildProject(metaclass=ABCMeta): return self._run('cd %s; make install %s' % (self.targetdir, install_args)) def clean(self): + if not self.needclean: + return self._run('rm -rf %s' % self.targetdir) subprocess.check_call('rm -f %s' % self.localarchive, shell=True) diff --git a/poky/meta/lib/oeqa/utils/dump.py b/poky/meta/lib/oeqa/utils/dump.py index 5a7edc1a86..79c22b75c4 100644 --- a/poky/meta/lib/oeqa/utils/dump.py +++ b/poky/meta/lib/oeqa/utils/dump.py @@ -12,7 +12,7 @@ class BaseDumper(object): self.cmds = [] # Some testing doesn't inherit testimage, so it is needed # to set some defaults. - self.parent_dir = parent_dir or "/tmp/oe-saved-tests" + self.parent_dir = parent_dir dft_cmds = """ top -bn1 iostat -x -z -N -d -p ALL 20 2 ps -ef diff --git a/poky/meta/lib/oeqa/utils/qemurunner.py b/poky/meta/lib/oeqa/utils/qemurunner.py index c7442a2573..cc95dc2990 100644 --- a/poky/meta/lib/oeqa/utils/qemurunner.py +++ b/poky/meta/lib/oeqa/utils/qemurunner.py @@ -345,6 +345,7 @@ class QemuRunner: else: self.logger.debug("Couldn't login into serial console" " as root using blank password") + self.logger.debug("The output:\n%s" % output) except: self.logger.debug("Serial console failed while trying to login") return True @@ -420,7 +421,7 @@ class QemuRunner: return True return False - def run_serial(self, command, raw=False, timeout=5): + def run_serial(self, command, raw=False, timeout=60): # We assume target system have echo to get command status if not raw: command = "%s; echo $?\n" % command diff --git a/poky/meta/lib/oeqa/utils/qemutinyrunner.py b/poky/meta/lib/oeqa/utils/qemutinyrunner.py index 63b5d1648b..5aa99d0686 100644 --- a/poky/meta/lib/oeqa/utils/qemutinyrunner.py +++ b/poky/meta/lib/oeqa/utils/qemutinyrunner.py @@ -108,7 +108,7 @@ class QemuTinyRunner(QemuRunner): return self.is_alive() - def run_serial(self, command, timeout=5): + def run_serial(self, command, timeout=60): self.server_socket.sendall(command+'\n') data = '' status = 0 |