summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/runtime')
-rw-r--r--meta/lib/oeqa/runtime/_ptest.py125
-rw-r--r--meta/lib/oeqa/runtime/_qemutiny.py9
-rw-r--r--meta/lib/oeqa/runtime/buildcvs.py31
-rw-r--r--meta/lib/oeqa/runtime/buildgalculator.py23
-rw-r--r--meta/lib/oeqa/runtime/buildiptables.py31
-rw-r--r--meta/lib/oeqa/runtime/case.py20
-rw-r--r--meta/lib/oeqa/runtime/cases/_qemutiny.py12
-rw-r--r--meta/lib/oeqa/runtime/cases/apt.py53
-rw-r--r--meta/lib/oeqa/runtime/cases/boot.py33
-rw-r--r--meta/lib/oeqa/runtime/cases/buildcpio.py32
-rw-r--r--meta/lib/oeqa/runtime/cases/buildgalculator.py32
-rw-r--r--meta/lib/oeqa/runtime/cases/buildlzip.py34
-rw-r--r--meta/lib/oeqa/runtime/cases/connman.py31
-rw-r--r--meta/lib/oeqa/runtime/cases/date.py42
-rw-r--r--meta/lib/oeqa/runtime/cases/df.py17
-rw-r--r--meta/lib/oeqa/runtime/cases/dnf.py191
-rw-r--r--meta/lib/oeqa/runtime/cases/gcc.py69
-rw-r--r--meta/lib/oeqa/runtime/cases/gi.py19
-rw-r--r--meta/lib/oeqa/runtime/cases/gstreamer.py18
-rw-r--r--meta/lib/oeqa/runtime/cases/kernelmodule.py46
-rw-r--r--meta/lib/oeqa/runtime/cases/ksample.py231
-rw-r--r--meta/lib/oeqa/runtime/cases/ldd.py26
-rw-r--r--meta/lib/oeqa/runtime/cases/logrotate.py49
-rw-r--r--meta/lib/oeqa/runtime/cases/ltp.py118
-rw-r--r--meta/lib/oeqa/runtime/cases/ltp_compliance.py97
-rw-r--r--meta/lib/oeqa/runtime/cases/ltp_stress.py98
-rw-r--r--meta/lib/oeqa/runtime/cases/multilib.py44
-rw-r--r--meta/lib/oeqa/runtime/cases/oe_syslog.py131
-rw-r--r--meta/lib/oeqa/runtime/cases/opkg.py58
-rw-r--r--meta/lib/oeqa/runtime/cases/pam.py35
-rw-r--r--meta/lib/oeqa/runtime/cases/parselogs.py (renamed from meta/lib/oeqa/runtime/parselogs.py)264
-rw-r--r--meta/lib/oeqa/runtime/cases/perl.py17
-rw-r--r--meta/lib/oeqa/runtime/cases/ping.py26
-rw-r--r--meta/lib/oeqa/runtime/cases/ptest.py84
-rw-r--r--meta/lib/oeqa/runtime/cases/python.py19
-rw-r--r--meta/lib/oeqa/runtime/cases/rpm.py153
-rw-r--r--meta/lib/oeqa/runtime/cases/scons.py37
-rw-r--r--meta/lib/oeqa/runtime/cases/scp.py37
-rw-r--r--meta/lib/oeqa/runtime/cases/skeletoninit.py35
-rw-r--r--meta/lib/oeqa/runtime/cases/ssh.py19
-rw-r--r--meta/lib/oeqa/runtime/cases/stap.py37
-rw-r--r--meta/lib/oeqa/runtime/cases/storage.py149
-rw-r--r--meta/lib/oeqa/runtime/cases/systemd.py194
-rw-r--r--meta/lib/oeqa/runtime/cases/x32lib.py21
-rw-r--r--meta/lib/oeqa/runtime/cases/xorg.py21
-rw-r--r--meta/lib/oeqa/runtime/connman.py31
-rw-r--r--meta/lib/oeqa/runtime/context.py226
-rw-r--r--meta/lib/oeqa/runtime/date.py31
-rw-r--r--meta/lib/oeqa/runtime/decorator/package.py56
-rw-r--r--meta/lib/oeqa/runtime/df.py12
-rw-r--r--meta/lib/oeqa/runtime/files/SConstruct1
-rw-r--r--meta/lib/oeqa/runtime/files/hello.c5
-rw-r--r--meta/lib/oeqa/runtime/files/hello.stp1
-rw-r--r--meta/lib/oeqa/runtime/files/test.c26
-rw-r--r--meta/lib/oeqa/runtime/files/test.cpp3
-rw-r--r--meta/lib/oeqa/runtime/files/test.pl2
-rw-r--r--meta/lib/oeqa/runtime/files/test.py6
-rw-r--r--meta/lib/oeqa/runtime/files/testsdkmakefile5
-rw-r--r--meta/lib/oeqa/runtime/gcc.py47
-rw-r--r--meta/lib/oeqa/runtime/kernelmodule.py34
-rw-r--r--meta/lib/oeqa/runtime/ldd.py21
-rw-r--r--meta/lib/oeqa/runtime/loader.py19
-rw-r--r--meta/lib/oeqa/runtime/logrotate.py28
-rw-r--r--meta/lib/oeqa/runtime/multilib.py42
-rw-r--r--meta/lib/oeqa/runtime/pam.py25
-rw-r--r--meta/lib/oeqa/runtime/perl.py30
-rw-r--r--meta/lib/oeqa/runtime/ping.py22
-rw-r--r--meta/lib/oeqa/runtime/python.py35
-rw-r--r--meta/lib/oeqa/runtime/rpm.py120
-rw-r--r--meta/lib/oeqa/runtime/scanelf.py28
-rw-r--r--meta/lib/oeqa/runtime/scp.py22
-rw-r--r--meta/lib/oeqa/runtime/skeletoninit.py29
-rw-r--r--meta/lib/oeqa/runtime/smart.py218
-rw-r--r--meta/lib/oeqa/runtime/ssh.py19
-rw-r--r--meta/lib/oeqa/runtime/syslog.py52
-rw-r--r--meta/lib/oeqa/runtime/systemd.py178
-rw-r--r--meta/lib/oeqa/runtime/utils/__init__.py0
-rw-r--r--meta/lib/oeqa/runtime/utils/targetbuildproject.py44
-rw-r--r--meta/lib/oeqa/runtime/x32lib.py18
-rw-r--r--meta/lib/oeqa/runtime/xorg.py16
80 files changed, 2902 insertions, 1418 deletions
diff --git a/meta/lib/oeqa/runtime/_ptest.py b/meta/lib/oeqa/runtime/_ptest.py
deleted file mode 100644
index 71324d3da2..0000000000
--- a/meta/lib/oeqa/runtime/_ptest.py
+++ /dev/null
@@ -1,125 +0,0 @@
-import unittest, os, shutil
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-from oeqa.utils.logparser import *
-from oeqa.utils.httpserver import HTTPService
-import bb
-import glob
-from oe.package_manager import RpmPkgsList
-import subprocess
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("package-management"):
- skipModule("Image doesn't have package management feature")
- if not oeRuntimeTest.hasPackage("smartpm"):
- skipModule("Image doesn't have smart installed")
- if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
- skipModule("Rpm is not the primary package manager")
-
-class PtestRunnerTest(oeRuntimeTest):
-
- # a ptest log parser
- def parse_ptest(self, logfile):
- parser = Lparser(test_0_pass_regex="^PASS:(.+)", test_0_fail_regex="^FAIL:(.+)", section_0_begin_regex="^BEGIN: .*/(.+)/ptest", section_0_end_regex="^END: .*/(.+)/ptest")
- parser.init()
- result = Result()
-
- with open(logfile) as f:
- for line in f:
- result_tuple = parser.parse_line(line)
- if not result_tuple:
- continue
- result_tuple = line_type, category, status, name = parser.parse_line(line)
-
- if line_type == 'section' and status == 'begin':
- current_section = name
- continue
-
- if line_type == 'section' and status == 'end':
- current_section = None
- continue
-
- if line_type == 'test' and status == 'pass':
- result.store(current_section, name, status)
- continue
-
- if line_type == 'test' and status == 'fail':
- result.store(current_section, name, status)
- continue
-
- result.sort_tests()
- return result
-
- @classmethod
- def setUpClass(self):
- #note the existing channels that are on the board before creating new ones
-# self.existingchannels = set()
-# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
-# for x in result.split("\n"):
-# self.existingchannels.add(x)
- self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True), oeRuntimeTest.tc.target.server_ip)
- self.repo_server.start()
-
- @classmethod
- def tearDownClass(self):
- self.repo_server.stop()
- #remove created channels to be able to repeat the tests on same image
-# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
-# for x in result.split("\n"):
-# if x not in self.existingchannels:
-# oeRuntimeTest.tc.target.run('smart channel --remove '+x[1:-1]+' -y', 0)
-
- def add_smart_channel(self):
- image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
- deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
- pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True).replace("-","_").split()
- for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
- if arch in pkgarchs:
- self.target.run('smart channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url), 0)
- self.target.run('smart update', 0)
-
- def install_complementary(self, globs=None):
- installed_pkgs_file = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR', True),
- "installed_pkgs.txt")
- self.pkgs_list = RpmPkgsList(oeRuntimeTest.tc.d, oeRuntimeTest.tc.d.getVar('IMAGE_ROOTFS', True), oeRuntimeTest.tc.d.getVar('arch_var', True), oeRuntimeTest.tc.d.getVar('os_var', True))
- with open(installed_pkgs_file, "w+") as installed_pkgs:
- installed_pkgs.write(self.pkgs_list.list("arch"))
-
- cmd = [bb.utils.which(os.getenv('PATH'), "oe-pkgdata-util"),
- "-p", oeRuntimeTest.tc.d.getVar('PKGDATA_DIR', True), "glob", installed_pkgs_file,
- globs]
- try:
- bb.note("Installing complementary packages ...")
- complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- except subprocess.CalledProcessError as e:
- bb.fatal("Could not compute complementary packages list. Command "
- "'%s' returned %d:\n%s" %
- (' '.join(cmd), e.returncode, e.output))
-
- return complementary_pkgs.split()
-
- def setUpLocal(self):
- self.ptest_log = os.path.join(oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR",True), "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME', True))
-
- @skipUnlessPassed('test_ssh')
- def test_ptestrunner(self):
- self.add_smart_channel()
- (runnerstatus, result) = self.target.run('which ptest-runner', 0)
- cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackageMatch("-ptest") and (runnerstatus != 0)
- if cond:
- self.install_packages(self.install_complementary("*-ptest"))
- self.install_packages(['ptest-runner'])
-
- (runnerstatus, result) = self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0)
- #exit code is !=0 even if ptest-runner executes because some ptest tests fail.
- self.assertTrue(runnerstatus != 127, msg="Cannot execute ptest-runner!")
- self.target.copy_from('/tmp/ptest.log', self.ptest_log)
- shutil.copyfile(self.ptest_log, "ptest.log")
-
- result = self.parse_ptest("ptest.log")
- log_results_to_location = "./results"
- if os.path.exists(log_results_to_location):
- shutil.rmtree(log_results_to_location)
- os.makedirs(log_results_to_location)
-
- result.log_as_files(log_results_to_location, test_status = ['pass','fail'])
diff --git a/meta/lib/oeqa/runtime/_qemutiny.py b/meta/lib/oeqa/runtime/_qemutiny.py
deleted file mode 100644
index a3c29f3572..0000000000
--- a/meta/lib/oeqa/runtime/_qemutiny.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest
-from oeqa.utils.qemutinyrunner import *
-
-class QemuTinyTest(oeRuntimeTest):
-
- def test_boot_tiny(self):
- (status, output) = self.target.run_serial('uname -a')
- self.assertTrue("yocto-tiny" in output, msg="Cannot detect poky tiny boot!") \ No newline at end of file
diff --git a/meta/lib/oeqa/runtime/buildcvs.py b/meta/lib/oeqa/runtime/buildcvs.py
deleted file mode 100644
index fe6cbfbcd5..0000000000
--- a/meta/lib/oeqa/runtime/buildcvs.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-from oeqa.utils.targetbuild import TargetBuildProject
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("tools-sdk"):
- skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
-
-class BuildCvsTest(oeRuntimeTest):
-
- @classmethod
- def setUpClass(self):
- self.project = TargetBuildProject(oeRuntimeTest.tc.target, oeRuntimeTest.tc.d,
- "http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2")
- self.project.download_archive()
-
- @testcase(205)
- @skipUnlessPassed("test_ssh")
- def test_cvs(self):
- self.assertEqual(self.project.run_configure(), 0,
- msg="Running configure failed")
-
- self.assertEqual(self.project.run_make(), 0,
- msg="Running make failed")
-
- self.assertEqual(self.project.run_install(), 0,
- msg="Running make install failed")
-
- @classmethod
- def tearDownClass(self):
- self.project.clean()
diff --git a/meta/lib/oeqa/runtime/buildgalculator.py b/meta/lib/oeqa/runtime/buildgalculator.py
deleted file mode 100644
index 28ba29e5c2..0000000000
--- a/meta/lib/oeqa/runtime/buildgalculator.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-from oeqa.utils.targetbuild import TargetBuildProject
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("tools-sdk"):
- skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
-
-class GalculatorTest(oeRuntimeTest):
- @skipUnlessPassed("test_ssh")
- def test_galculator(self):
- try:
- project = TargetBuildProject(oeRuntimeTest.tc.target, oeRuntimeTest.tc.d,
- "http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2")
- project.download_archive()
-
- self.assertEqual(project.run_configure(), 0,
- msg="Running configure failed")
-
- self.assertEqual(project.run_make(), 0,
- msg="Running make failed")
- finally:
- project.clean()
diff --git a/meta/lib/oeqa/runtime/buildiptables.py b/meta/lib/oeqa/runtime/buildiptables.py
deleted file mode 100644
index bc75d0a0c7..0000000000
--- a/meta/lib/oeqa/runtime/buildiptables.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-from oeqa.utils.targetbuild import TargetBuildProject
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("tools-sdk"):
- skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
-
-class BuildIptablesTest(oeRuntimeTest):
-
- @classmethod
- def setUpClass(self):
- self.project = TargetBuildProject(oeRuntimeTest.tc.target, oeRuntimeTest.tc.d,
- "http://downloads.yoctoproject.org/mirror/sources/iptables-1.4.13.tar.bz2")
- self.project.download_archive()
-
- @testcase(206)
- @skipUnlessPassed("test_ssh")
- def test_iptables(self):
- self.assertEqual(self.project.run_configure(), 0,
- msg="Running configure failed")
-
- self.assertEqual(self.project.run_make(), 0,
- msg="Running make failed")
-
- self.assertEqual(self.project.run_install(), 0,
- msg="Running make install failed")
-
- @classmethod
- def tearDownClass(self):
- self.project.clean()
diff --git a/meta/lib/oeqa/runtime/case.py b/meta/lib/oeqa/runtime/case.py
new file mode 100644
index 0000000000..f036982e1f
--- /dev/null
+++ b/meta/lib/oeqa/runtime/case.py
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2016 Intel Corporation
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.core.case import OETestCase
+from oeqa.utils.package_manager import install_package, uninstall_package
+
+class OERuntimeTestCase(OETestCase):
+ # target instance set by OERuntimeTestLoader.
+ target = None
+
+ def setUp(self):
+ super(OERuntimeTestCase, self).setUp()
+ install_package(self)
+
+ def tearDown(self):
+ super(OERuntimeTestCase, self).tearDown()
+ uninstall_package(self)
diff --git a/meta/lib/oeqa/runtime/cases/_qemutiny.py b/meta/lib/oeqa/runtime/cases/_qemutiny.py
new file mode 100644
index 0000000000..6886e36502
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/_qemutiny.py
@@ -0,0 +1,12 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+
+class QemuTinyTest(OERuntimeTestCase):
+
+ def test_boot_tiny(self):
+ status, output = self.target.run_serial('uname -a')
+ msg = "Cannot detect poky tiny boot!"
+ self.assertTrue("yocto-tiny" in output, msg)
diff --git a/meta/lib/oeqa/runtime/cases/apt.py b/meta/lib/oeqa/runtime/cases/apt.py
new file mode 100644
index 0000000000..c5378d90c3
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/apt.py
@@ -0,0 +1,53 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+from oeqa.utils.httpserver import HTTPService
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class AptTest(OERuntimeTestCase):
+
+ def pkg(self, command, expected = 0):
+ command = 'apt-get %s' % command
+ status, output = self.target.run(command, 1500)
+ message = os.linesep.join([command, output])
+ self.assertEqual(status, expected, message)
+ return output
+
+class AptRepoTest(AptTest):
+
+ @classmethod
+ def setUpClass(cls):
+ service_repo = os.path.join(cls.tc.td['DEPLOY_DIR_DEB'], 'all')
+ cls.repo_server = HTTPService(service_repo,
+ '0.0.0.0', port=cls.tc.target.server_port,
+ logger=cls.tc.logger)
+ cls.repo_server.start()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.repo_server.stop()
+
+ def setup_source_config_for_package_install(self):
+ apt_get_source_server = 'http://%s:%s/' % (self.tc.target.server_ip, self.repo_server.port)
+ apt_get_sourceslist_dir = '/etc/apt/'
+ self.target.run('cd %s; echo deb %s ./ > sources.list' % (apt_get_sourceslist_dir, apt_get_source_server))
+
+ def cleanup_source_config_for_package_install(self):
+ apt_get_sourceslist_dir = '/etc/apt/'
+ self.target.run('cd %s; rm sources.list' % (apt_get_sourceslist_dir))
+
+ @skipIfNotFeature('package-management',
+ 'Test requires package-management to be in IMAGE_FEATURES')
+ @skipIfNotDataVar('IMAGE_PKGTYPE', 'deb',
+ 'DEB is not the primary package manager')
+ @OEHasPackage(['apt'])
+ def test_apt_install_from_repo(self):
+ self.setup_source_config_for_package_install()
+ self.pkg('update')
+ self.pkg('remove --yes run-postinsts-dev')
+ self.pkg('install --yes --allow-unauthenticated run-postinsts-dev')
+ self.cleanup_source_config_for_package_install()
diff --git a/meta/lib/oeqa/runtime/cases/boot.py b/meta/lib/oeqa/runtime/cases/boot.py
new file mode 100644
index 0000000000..2142f400a0
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/boot.py
@@ -0,0 +1,33 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from subprocess import Popen, PIPE
+import time
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.oetimeout import OETimeout
+from oeqa.core.decorator.data import skipIfQemu
+
+class BootTest(OERuntimeTestCase):
+
+ @OETimeout(120)
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_reboot(self):
+ output = ''
+ count = 0
+ (status, output) = self.target.run('reboot -h')
+ while count < 5:
+ time.sleep(5)
+ cmd = 'ping -c 1 %s' % self.target.ip
+ proc = Popen(cmd, shell=True, stdout=PIPE)
+ output += proc.communicate()[0].decode('utf-8')
+ if proc.poll() == 0:
+ count += 1
+ else:
+ count = 0
+ msg = ('Expected 5 consecutive, got %d.\n'
+ 'ping output is:\n%s' % (count,output))
+ self.assertEqual(count, 5, msg = msg)
diff --git a/meta/lib/oeqa/runtime/cases/buildcpio.py b/meta/lib/oeqa/runtime/cases/buildcpio.py
new file mode 100644
index 0000000000..f4e871e421
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/buildcpio.py
@@ -0,0 +1,32 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
+
+class BuildCpioTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ uri = 'https://downloads.yoctoproject.org/mirror/sources/cpio-2.12.tar.gz'
+ cls.project = TargetBuildProject(cls.tc.target,
+ uri,
+ dl_dir = cls.tc.td['DL_DIR'])
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.project.clean()
+
+ @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/meta/lib/oeqa/runtime/cases/buildgalculator.py b/meta/lib/oeqa/runtime/cases/buildgalculator.py
new file mode 100644
index 0000000000..e5cc3e2888
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/buildgalculator.py
@@ -0,0 +1,32 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
+
+class GalculatorTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ uri = 'http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2'
+ cls.project = TargetBuildProject(cls.tc.target,
+ uri,
+ dl_dir = cls.tc.td['DL_DIR'])
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.project.clean()
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(['gcc'])
+ @OEHasPackage(['make'])
+ @OEHasPackage(['autoconf'])
+ @OEHasPackage(['gtk+3'])
+ def test_galculator(self):
+ self.project.download_archive()
+ self.project.run_configure()
+ self.project.run_make()
diff --git a/meta/lib/oeqa/runtime/cases/buildlzip.py b/meta/lib/oeqa/runtime/cases/buildlzip.py
new file mode 100644
index 0000000000..bc70b41461
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/buildlzip.py
@@ -0,0 +1,34 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
+
+class BuildLzipTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ uri = 'http://downloads.yoctoproject.org/mirror/sources'
+ uri = '%s/lzip-1.19.tar.gz' % uri
+ cls.project = TargetBuildProject(cls.tc.target,
+ uri,
+ dl_dir = cls.tc.td['DL_DIR'])
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.project.clean()
+
+ @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()
+
diff --git a/meta/lib/oeqa/runtime/cases/connman.py b/meta/lib/oeqa/runtime/cases/connman.py
new file mode 100644
index 0000000000..f0d15fac9b
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/connman.py
@@ -0,0 +1,31 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class ConnmanTest(OERuntimeTestCase):
+
+ def service_status(self, service):
+ if 'systemd' in self.tc.td['DISTRO_FEATURES']:
+ (_, output) = self.target.run('systemctl status -l %s' % service)
+ return output
+ else:
+ return "Unable to get status or logs for %s" % service
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(["connman"])
+ def test_connmand_help(self):
+ (status, output) = self.target.run('/usr/sbin/connmand --help')
+ msg = 'Failed to get connman help. Output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ @OETestDepends(['connman.ConnmanTest.test_connmand_help'])
+ def test_connmand_running(self):
+ cmd = '%s | grep [c]onnmand' % self.tc.target_cmds['ps']
+ (status, output) = self.target.run(cmd)
+ if status != 0:
+ self.logger.info(self.service_status("connman"))
+ self.fail("No connmand process running")
diff --git a/meta/lib/oeqa/runtime/cases/date.py b/meta/lib/oeqa/runtime/cases/date.py
new file mode 100644
index 0000000000..7750a7293f
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/date.py
@@ -0,0 +1,42 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import re
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class DateTest(OERuntimeTestCase):
+
+ def setUp(self):
+ if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
+ self.logger.debug('Stopping systemd-timesyncd daemon')
+ self.target.run('systemctl stop systemd-timesyncd')
+
+ def tearDown(self):
+ if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
+ self.logger.debug('Starting systemd-timesyncd daemon')
+ self.target.run('systemctl start systemd-timesyncd')
+
+ @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
+ self.assertEqual(status, 0, msg=msg)
+ oldDate = output
+
+ sampleDate = '"2016-08-09 10:00:00"'
+ (status, output) = self.target.run("date -s %s" % sampleDate)
+ self.assertEqual(status, 0, msg='Date set failed, output: %s' % output)
+
+ (status, output) = self.target.run("date -R")
+ p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output)
+ msg = 'The date was not set correctly, output: %s' % output
+ self.assertTrue(p, msg=msg)
+
+ (status, output) = self.target.run('date -s "%s"' % oldDate)
+ msg = 'Failed to reset date, output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/df.py b/meta/lib/oeqa/runtime/cases/df.py
new file mode 100644
index 0000000000..89fd0fb901
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/df.py
@@ -0,0 +1,17 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class DfTest(OERuntimeTestCase):
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(['coreutils', 'busybox'])
+ def test_df(self):
+ cmd = "df -P / | sed -n '2p' | awk '{print $4}'"
+ (status,output) = self.target.run(cmd)
+ msg = 'Not enough space on image. Current size is %s' % output
+ self.assertTrue(int(output)>5120, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/dnf.py b/meta/lib/oeqa/runtime/cases/dnf.py
new file mode 100644
index 0000000000..f40c63026e
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/dnf.py
@@ -0,0 +1,191 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+import re
+import subprocess
+from oeqa.utils.httpserver import HTTPService
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature, skipIfInDataVar, skipIfNotInDataVar
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class DnfTest(OERuntimeTestCase):
+
+ def dnf(self, command, expected = 0):
+ command = 'dnf %s' % command
+ status, output = self.target.run(command, 1500)
+ message = os.linesep.join([command, output])
+ self.assertEqual(status, expected, message)
+ return output
+
+class DnfBasicTest(DnfTest):
+
+ @skipIfNotFeature('package-management',
+ 'Test requires package-management to be in IMAGE_FEATURES')
+ @skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm',
+ 'RPM is not the primary package manager')
+ @OEHasPackage(['dnf'])
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_dnf_help(self):
+ self.dnf('--help')
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_version(self):
+ self.dnf('--version')
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_info(self):
+ self.dnf('info dnf')
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_search(self):
+ self.dnf('search dnf')
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_history(self):
+ self.dnf('history')
+
+class DnfRepoTest(DnfTest):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.repo_server = HTTPService(os.path.join(cls.tc.td['WORKDIR'], 'oe-testimage-repo'),
+ '0.0.0.0', port=cls.tc.target.server_port,
+ logger=cls.tc.logger)
+ cls.repo_server.start()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.repo_server.stop()
+
+ def dnf_with_repo(self, command):
+ pkgarchs = os.listdir(os.path.join(self.tc.td['WORKDIR'], 'oe-testimage-repo'))
+ deploy_url = 'http://%s:%s/' %(self.target.server_ip, self.repo_server.port)
+ cmdlinerepoopts = ["--repofrompath=oe-testimage-repo-%s,%s%s" %(arch, deploy_url, arch) for arch in pkgarchs]
+
+ output = self.dnf(" ".join(cmdlinerepoopts) + " --nogpgcheck " + command)
+ return output
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_makecache(self):
+ self.dnf_with_repo('makecache')
+
+
+# Does not work when repo is specified on the command line
+# @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+# def test_dnf_repolist(self):
+# self.dnf_with_repo('repolist')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+ def test_dnf_repoinfo(self):
+ self.dnf_with_repo('repoinfo')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+ def test_dnf_install(self):
+ output = self.dnf_with_repo('list run-postinsts-dev')
+ if 'Installed Packages' in output:
+ self.dnf_with_repo('remove -y run-postinsts-dev')
+ self.dnf_with_repo('install -y run-postinsts-dev')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_install'])
+ def test_dnf_install_dependency(self):
+ self.dnf_with_repo('remove -y run-postinsts')
+ self.dnf_with_repo('install -y run-postinsts-dev')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_install_dependency'])
+ def test_dnf_install_from_disk(self):
+ self.dnf_with_repo('remove -y run-postinsts-dev')
+ self.dnf_with_repo('install -y --downloadonly run-postinsts-dev')
+ status, output = self.target.run('find /var/cache/dnf -name run-postinsts-dev*rpm', 1500)
+ self.assertEqual(status, 0, output)
+ self.dnf_with_repo('install -y %s' % output)
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_install_from_disk'])
+ def test_dnf_install_from_http(self):
+ output = subprocess.check_output('%s %s -name run-postinsts-dev*' % (bb.utils.which(os.getenv('PATH'), "find"),
+ os.path.join(self.tc.td['WORKDIR'], 'oe-testimage-repo')), shell=True).decode("utf-8")
+ rpm_path = output.split("/")[-2] + "/" + output.split("/")[-1]
+ url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, rpm_path)
+ self.dnf_with_repo('remove -y run-postinsts-dev')
+ self.dnf_with_repo('install -y %s' % url)
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_install'])
+ def test_dnf_reinstall(self):
+ self.dnf_with_repo('reinstall -y run-postinsts-dev')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+ @skipIfInDataVar('DISTRO_FEATURES', 'usrmerge', 'Test run when not enable usrmerge')
+ @OEHasPackage('busybox')
+ def test_dnf_installroot(self):
+ rootpath = '/home/root/chroot/test'
+ #Copy necessary files to avoid errors with not yet installed tools on
+ #installroot directory.
+ self.target.run('mkdir -p %s/etc' % rootpath, 1500)
+ self.target.run('mkdir -p %s/bin %s/sbin %s/usr/bin %s/usr/sbin' % (rootpath, rootpath, rootpath, rootpath), 1500)
+ self.target.run('mkdir -p %s/dev' % rootpath, 1500)
+ #Handle different architectures lib dirs
+ self.target.run('mkdir -p %s/lib' % rootpath, 1500)
+ self.target.run('mkdir -p %s/libx32' % rootpath, 1500)
+ self.target.run('mkdir -p %s/lib64' % rootpath, 1500)
+ self.target.run('cp /lib/libtinfo.so.5 %s/lib' % rootpath, 1500)
+ self.target.run('cp /libx32/libtinfo.so.5 %s/libx32' % rootpath, 1500)
+ self.target.run('cp /lib64/libtinfo.so.5 %s/lib64' % rootpath, 1500)
+ self.target.run('cp -r /etc/rpm %s/etc' % rootpath, 1500)
+ self.target.run('cp -r /etc/dnf %s/etc' % rootpath, 1500)
+ self.target.run('cp /bin/sh %s/bin' % rootpath, 1500)
+ self.target.run('mount -o bind /dev %s/dev/' % rootpath, 1500)
+ self.dnf_with_repo('install --installroot=%s -v -y --rpmverbosity=debug busybox run-postinsts' % rootpath)
+ status, output = self.target.run('test -e %s/var/cache/dnf' % rootpath, 1500)
+ self.assertEqual(0, status, output)
+ status, output = self.target.run('test -e %s/bin/busybox' % rootpath, 1500)
+ self.assertEqual(0, status, output)
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+ @skipIfNotInDataVar('DISTRO_FEATURES', 'usrmerge', 'Test run when enable usrmege')
+ @OEHasPackage('busybox')
+ def test_dnf_installroot_usrmerge(self):
+ rootpath = '/home/root/chroot/test'
+ #Copy necessary files to avoid errors with not yet installed tools on
+ #installroot directory.
+ self.target.run('mkdir -p %s/etc' % rootpath, 1500)
+ self.target.run('mkdir -p %s/usr/bin %s/usr/sbin' % (rootpath, rootpath), 1500)
+ self.target.run('ln -sf -r %s/usr/bin %s/bin' % (rootpath, rootpath), 1500)
+ self.target.run('ln -sf -r %s/usr/sbin %s/sbin' % (rootpath, rootpath), 1500)
+ self.target.run('mkdir -p %s/dev' % rootpath, 1500)
+ #Handle different architectures lib dirs
+ self.target.run('mkdir -p %s/usr/lib' % rootpath, 1500)
+ self.target.run('mkdir -p %s/usr/libx32' % rootpath, 1500)
+ self.target.run('mkdir -p %s/usr/lib64' % rootpath, 1500)
+ self.target.run('cp /lib/libtinfo.so.5 %s/usr/lib' % rootpath, 1500)
+ self.target.run('cp /libx32/libtinfo.so.5 %s/usr/libx32' % rootpath, 1500)
+ self.target.run('cp /lib64/libtinfo.so.5 %s/usr/lib64' % rootpath, 1500)
+ self.target.run('ln -sf -r %s/lib %s/usr/lib' % (rootpath,rootpath), 1500)
+ self.target.run('ln -sf -r %s/libx32 %s/usr/libx32' % (rootpath,rootpath), 1500)
+ self.target.run('ln -sf -r %s/lib64 %s/usr/lib64' % (rootpath,rootpath), 1500)
+ self.target.run('cp -r /etc/rpm %s/etc' % rootpath, 1500)
+ self.target.run('cp -r /etc/dnf %s/etc' % rootpath, 1500)
+ self.target.run('cp /bin/sh %s/bin' % rootpath, 1500)
+ self.target.run('mount -o bind /dev %s/dev/' % rootpath, 1500)
+ self.dnf_with_repo('install --installroot=%s -v -y --rpmverbosity=debug busybox run-postinsts' % rootpath)
+ status, output = self.target.run('test -e %s/var/cache/dnf' % rootpath, 1500)
+ self.assertEqual(0, status, output)
+ status, output = self.target.run('test -e %s/bin/busybox' % rootpath, 1500)
+ self.assertEqual(0, status, output)
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+ def test_dnf_exclude(self):
+ excludepkg = 'curl-dev'
+ self.dnf_with_repo('install -y curl*')
+ self.dnf('list %s' % excludepkg, 0)
+ #Avoid remove dependencies to skip some errors on different archs and images
+ self.dnf_with_repo('remove --setopt=clean_requirements_on_remove=0 -y curl*')
+ #check curl-dev is not installed adter removing all curl occurrences
+ status, output = self.target.run('dnf list --installed | grep %s'% excludepkg, 1500)
+ self.assertEqual(1, status, "%s was not removed, is listed as installed"%excludepkg)
+ self.dnf_with_repo('install -y --exclude=%s --exclude=curl-staticdev curl*' % excludepkg)
+ #check curl-dev is not installed after being excluded
+ status, output = self.target.run('dnf list --installed | grep %s'% excludepkg , 1500)
+ self.assertEqual(1, status, "%s was not excluded, is listed as installed"%excludepkg)
diff --git a/meta/lib/oeqa/runtime/cases/gcc.py b/meta/lib/oeqa/runtime/cases/gcc.py
new file mode 100644
index 0000000000..1b6e431bf4
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/gcc.py
@@ -0,0 +1,69 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class GccCompileTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUp(cls):
+ dst = '/tmp/'
+ src = os.path.join(cls.tc.files_dir, 'test.c')
+ cls.tc.target.copyTo(src, dst)
+
+ src = os.path.join(cls.tc.runtime_files_dir, 'testmakefile')
+ cls.tc.target.copyTo(src, dst)
+
+ src = os.path.join(cls.tc.files_dir, 'test.cpp')
+ cls.tc.target.copyTo(src, dst)
+
+ @classmethod
+ def tearDown(cls):
+ files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile'
+ cls.tc.target.run('rm %s' % files)
+
+ @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
+ self.assertEqual(status, 0, msg=msg)
+
+ status, output = self.target.run('/tmp/test')
+ msg = 'running compiled file failed, output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ @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
+ self.assertEqual(status, 0, msg=msg)
+
+ status, output = self.target.run('/tmp/test')
+ msg = 'running compiled file failed, output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ @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
+ self.assertEqual(status, 0, msg=msg)
+
+ status, output = self.target.run('/tmp/test')
+ msg = 'running compiled file failed, output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ @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
+ self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/gi.py b/meta/lib/oeqa/runtime/cases/gi.py
new file mode 100644
index 0000000000..42bd100a31
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/gi.py
@@ -0,0 +1,19 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class GObjectIntrospectionTest(OERuntimeTestCase):
+
+ @OETestDepends(["ssh.SSHTest.test_ssh"])
+ @OEHasPackage(["python3-pygobject"])
+ def test_python(self):
+ script = """from gi.repository import GLib; print(GLib.markup_escape_text("<testing&testing>"))"""
+ status, output = self.target.run("python3 -c '%s'" % script)
+ self.assertEqual(status, 0, msg="Python failed (%s)" % (output))
+ self.assertEqual(output, "&lt;testing&amp;testing&gt;", msg="Unexpected output (%s)" % output)
diff --git a/meta/lib/oeqa/runtime/cases/gstreamer.py b/meta/lib/oeqa/runtime/cases/gstreamer.py
new file mode 100644
index 0000000000..f735f82e3b
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/gstreamer.py
@@ -0,0 +1,18 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class GstreamerCliTest(OERuntimeTestCase):
+
+ @OEHasPackage(['gstreamer1.0'])
+ def test_gst_inspect_can_list_all_plugins(self):
+ status, output = self.target.run('gst-inspect-1.0')
+ self.assertEqual(status, 0, 'gst-inspect-1.0 does not appear to be running.')
+
+ @OEHasPackage(['gstreamer1.0'])
+ def test_gst_launch_can_create_video_pipeline(self):
+ status, output = self.target.run('gst-launch-1.0 -v fakesrc silent=false num-buffers=3 ! fakesink silent=false')
+ self.assertEqual(status, 0, 'gst-launch-1.0 does not appear to be running.')
diff --git a/meta/lib/oeqa/runtime/cases/kernelmodule.py b/meta/lib/oeqa/runtime/cases/kernelmodule.py
new file mode 100644
index 0000000000..47fd2f850c
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/kernelmodule.py
@@ -0,0 +1,46 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotFeature
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class KernelModuleTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUp(cls):
+ src = os.path.join(cls.tc.runtime_files_dir, 'hellomod.c')
+ dst = '/tmp/hellomod.c'
+ cls.tc.target.copyTo(src, dst)
+
+ src = os.path.join(cls.tc.runtime_files_dir, 'hellomod_makefile')
+ dst = '/tmp/Makefile'
+ cls.tc.target.copyTo(src, dst)
+
+ @classmethod
+ def tearDown(cls):
+ files = '/tmp/Makefile /tmp/hellomod.c'
+ cls.tc.target.run('rm %s' % files)
+
+ @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',
+ 'cd /tmp && make',
+ 'cd /tmp && insmod hellomod.ko',
+ 'lsmod | grep hellomod',
+ 'dmesg | grep Hello',
+ 'rmmod hellomod', 'dmesg | grep "Cleaning up hellomod"'
+ ]
+ for cmd in cmds:
+ status, output = self.target.run(cmd, 900)
+ self.assertEqual(status, 0, msg='\n'.join([cmd, output]))
diff --git a/meta/lib/oeqa/runtime/cases/ksample.py b/meta/lib/oeqa/runtime/cases/ksample.py
new file mode 100644
index 0000000000..a9a1620ebd
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ksample.py
@@ -0,0 +1,231 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+import time
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotFeature
+
+# need some kernel fragments
+# echo "KERNEL_FEATURES_append += \" features\/kernel\-sample\/kernel\-sample.scc\"" >> local.conf
+class KSample(OERuntimeTestCase):
+ def cmd_and_check(self, cmd='', match_string=''):
+ status, output = self.target.run(cmd)
+ if not match_string:
+ # send cmd
+ msg = '%s failed, %s' % (cmd, output)
+ self.assertEqual(status, 0, msg=msg)
+ else:
+ # check result
+ result = ("%s" % match_string) in output
+ msg = output
+ self.assertTrue(result, msg)
+ self.assertEqual(status, 0, cmd)
+
+ def check_arch(self, archset=''):
+ status, output = self.target.run("uname -m")
+ result = ("%s" % output) in archset
+ if not result:
+ self.skipTest("This case doesn't support %s" % output)
+
+ def check_config(self, config_opt=''):
+ cmd = "zcat /proc/config.gz | grep %s" % config_opt
+ status, output = self.target.run(cmd)
+ result = ("%s=y" % config_opt) in output
+ if not result:
+ self.skipTest("%s is not set" % config_opt)
+
+ def check_module_exist(self, path='', module_name=''):
+ status, output = self.target.run("uname -r")
+ cmd = "ls " + "/lib/modules/" + output + "/kernel/samples/" + path + module_name
+ status, output = self.target.run(cmd)
+ if status != 0:
+ error_info = module_name + " doesn't exist"
+ self.skipTest(error_info)
+
+ def kfifo_func(self, name=''):
+ module_prename = name + "-example"
+ module_name = name + "-example.ko"
+ sysmbol_name = name + "_example"
+
+ # make sure if module exists
+ self.check_module_exist("kfifo/", module_name)
+ # modprobe
+ self.cmd_and_check("modprobe %s" % module_prename)
+ # lsmod
+ self.cmd_and_check("lsmod | grep %s | cut -d\' \' -f1" % sysmbol_name, sysmbol_name)
+ # check result
+ self.cmd_and_check("dmesg | grep \"test passed\" ", "test passed")
+ # rmmod
+ self.cmd_and_check("rmmod %s" % module_prename)
+
+ def kprobe_func(self, name=''):
+ # check config
+ self.check_config("CONFIG_KPROBES")
+
+ module_prename = name + "_example"
+ module_name = name + "_example.ko"
+ sysmbol_name = module_prename
+
+ # make sure if module exists
+ self.check_module_exist("kprobes/", module_name)
+ # modprobe
+ self.cmd_and_check("modprobe %s" % module_prename)
+ # lsmod
+ self.cmd_and_check("lsmod | grep %s | cut -d\' \' -f1" % sysmbol_name, sysmbol_name)
+ # check result
+ self.cmd_and_check("dmesg | grep Planted | head -n10", "Planted")
+ # rmmod
+ self.cmd_and_check("rmmod %s" % module_prename)
+
+ def kobject_func(self, name=''):
+ module_prename = name + "_example"
+ module_name = name + "-example.ko"
+ sysmbol_name = module_prename
+
+ # make sure if module exists
+ self.check_module_exist("kobject/", module_name)
+ # modprobe
+ self.cmd_and_check("modprobe %s" % module_prename)
+ # lsmod
+ self.cmd_and_check("lsmod | grep %s | cut -d\' \' -f1" % sysmbol_name, sysmbol_name)
+ # check result
+ self.cmd_and_check("ls /sys/kernel/%s/" % sysmbol_name, "bar")
+ # rmmod
+ self.cmd_and_check("rmmod %s" % module_prename)
+
+class KSampleTest(KSample):
+ # kfifo
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_kfifo_test(self):
+ index = ["dma", "bytestream", "inttype", "record"]
+ for i in index:
+ self.kfifo_func(i)
+
+ # kprobe
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_kprobe_test(self):
+ self.check_arch("x86_64 i686 ppc")
+ index = ["kprobe", "kretprobe"]
+ for i in index:
+ self.kprobe_func(i)
+
+ # kobject
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_kobject_test(self):
+ index = ["kobject", "kset"]
+ for i in index:
+ self.kobject_func(i)
+
+ #trace
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_trace_events(self):
+ # check config
+ self.check_config("CONFIG_TRACING_SUPPORT")
+ # make sure if module exists
+ self.check_module_exist("trace_events/", "trace-events-sample.ko")
+ # modprobe
+ self.cmd_and_check("modprobe trace-events-sample")
+ # lsmod
+ self.cmd_and_check("lsmod | grep trace_events_sample | cut -d\' \' -f1", "trace_events_sample")
+ # check dir
+ self.cmd_and_check("ls /sys/kernel/debug/tracing/events/ | grep sample-trace", "sample-trace")
+ # enable trace
+ self.cmd_and_check("echo 1 > /sys/kernel/debug/tracing/events/sample-trace/enable")
+ self.cmd_and_check("cat /sys/kernel/debug/tracing/events/sample-trace/enable")
+ # check result
+ status = 1
+ count = 0
+ while status != 0:
+ time.sleep(1)
+ status, output = self.target.run('cat /sys/kernel/debug/tracing/trace | grep hello | head -n1 | cut -d\':\' -f2')
+ if " foo_bar" in output:
+ break
+ count = count + 1
+ if count > 5:
+ self.assertTrue(False, "Time out when check result")
+ # disable trace
+ self.cmd_and_check("echo 0 > /sys/kernel/debug/tracing/events/sample-trace/enable")
+ # clean up trace
+ self.cmd_and_check("echo > /sys/kernel/debug/tracing/trace")
+ # rmmod
+ self.cmd_and_check("rmmod trace-events-sample")
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_trace_printk(self):
+ # check config
+ self.check_config("CONFIG_TRACING_SUPPORT")
+ # make sure if module exists
+ self.check_module_exist("trace_printk/", "trace-printk.ko")
+ # modprobe
+ self.cmd_and_check("modprobe trace-printk")
+ # lsmod
+ self.cmd_and_check("lsmod | grep trace_printk | cut -d\' \' -f1", "trace_printk")
+ # check result
+ self.cmd_and_check("cat /sys/kernel/debug/tracing/trace | grep trace_printk_irq_work | head -n1 | cut -d\':\' -f2", " trace_printk_irq_work")
+ # clean up trace
+ self.cmd_and_check("echo > /sys/kernel/debug/tracing/trace")
+ # rmmod
+ self.cmd_and_check("rmmod trace-printk")
+
+ # hw breakpoint
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_hw_breakpoint_example(self):
+ # check arch
+ status, output = self.target.run("uname -m")
+ result = ("x86_64" in output) or ("aarch64" in output)
+ if not result:
+ self.skipTest("the arch %s doesn't support hw breakpoint" % output)
+ # check config
+ self.check_config("CONFIG_KALLSYMS_ALL")
+ # make sure if module exists
+ self.check_module_exist("hw_breakpoint/", "data_breakpoint.ko")
+ # modprobe
+ self.cmd_and_check("modprobe data_breakpoint")
+ # lsmod
+ self.cmd_and_check("lsmod | grep data_breakpoint | cut -d\' \' -f1", "data_breakpoint")
+ # check result
+ self.cmd_and_check("cat /var/log/messages | grep sample_hbp_handler", "sample_hbp_handler")
+ # rmmod
+ self.cmd_and_check("rmmod data_breakpoint")
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_configfs_sample(self):
+ # check config
+ status, ret = self.target.run('zcat /proc/config.gz | grep CONFIG_CONFIGFS_FS')
+ if not ["CONFIG_CONFIGFS_FS=m" in ret or "CONFIG_CONFIGFS_FS=y" in ret]:
+ self.skipTest("CONFIG error")
+ # make sure if module exists
+ self.check_module_exist("configfs/", "configfs_sample.ko")
+ # modprobe
+ self.cmd_and_check("modprobe configfs_sample")
+ # lsmod
+ self.cmd_and_check("lsmod | grep configfs_sample | cut -d\' \' -f1 | head -n1", "configfs_sample")
+
+ status = 1
+ count = 0
+ while status != 0:
+ time.sleep(1)
+ status, ret = self.target.run('cat /sys/kernel/config/01-childless/description')
+ count = count + 1
+ if count > 200:
+ self.skipTest("Time out for check dir")
+
+ # rmmod
+ self.cmd_and_check("rmmod configfs_sample")
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_cn_test(self):
+ # make sure if module exists
+ self.check_module_exist("connector/", "cn_test.ko")
+ # modprobe
+ self.cmd_and_check("modprobe cn_test")
+ # lsmod
+ self.cmd_and_check("lsmod | grep cn_test | cut -d\' \' -f1", "cn_test")
+ # check result
+ self.cmd_and_check("cat /proc/net/connector | grep cn_test | head -n1 | cut -d\' \' -f1", "cn_test")
+ # rmmod
+ self.cmd_and_check("rmmod cn_test")
diff --git a/meta/lib/oeqa/runtime/cases/ldd.py b/meta/lib/oeqa/runtime/cases/ldd.py
new file mode 100644
index 0000000000..9c2caa8f65
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ldd.py
@@ -0,0 +1,26 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotFeature
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class LddTest(OERuntimeTestCase):
+
+ @OEHasPackage(["ldd"])
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_ldd(self):
+ status, output = self.target.run('which ldd')
+ msg = 'ldd does not exist in PATH: which ldd: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ cmd = ('for i in $(which ldd | xargs cat | grep "^RTLDLIST"| '
+ 'cut -d\'=\' -f2|tr -d \'"\'); '
+ 'do test -f $i && echo $i && break; done')
+ status, output = self.target.run(cmd)
+ self.assertEqual(status, 0, msg="ldd path not correct or RTLDLIST files don't exist.")
+
+ status, output = self.target.run("ldd /bin/true")
+ self.assertEqual(status, 0, msg="ldd failed to execute: %s" % output)
diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py
new file mode 100644
index 0000000000..bfa57c534a
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/logrotate.py
@@ -0,0 +1,49 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=289 testcase
+# Note that the image under test must have logrotate installed
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class LogrotateTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.tc.target.run('cp /etc/logrotate.d/wtmp $HOME/wtmp.oeqabak')
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.tc.target.run('mv -f $HOME/wtmp.oeqabak /etc/logrotate.d/wtmp && rm -rf $HOME/logrotate_dir')
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(['logrotate'])
+ def test_1_logrotate_setup(self):
+ status, output = self.target.run('mkdir $HOME/logrotate_dir')
+ msg = 'Could not create logrotate_dir. Output: %s' % output
+ self.assertEqual(status, 0, msg = msg)
+
+ cmd = ('sed -i "s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#"'
+ ' /etc/logrotate.d/wtmp')
+ status, output = self.target.run(cmd)
+ msg = ('Could not write to logrotate.d/wtmp file. Status and output: '
+ ' %s and %s' % (status, output))
+ self.assertEqual(status, 0, msg = msg)
+
+ @OETestDepends(['logrotate.LogrotateTest.test_1_logrotate_setup'])
+ def test_2_logrotate(self):
+ status, output = self.target.run('echo "create \n include /etc/logrotate.d" > /tmp/logrotate-test.conf')
+ status, output = self.target.run('logrotate -f /tmp/logrotate-test.conf')
+
+ msg = ('logrotate service could not be reloaded. Status and output: '
+ '%s and %s' % (status, output))
+ self.assertEqual(status, 0, msg = msg)
+
+ _, output = self.target.run('ls -la $HOME/logrotate_dir/ | wc -l')
+ msg = ('new logfile could not be created. List of files within log '
+ 'directory: %s' % (
+ self.target.run('ls -la $HOME/logrotate_dir')[1]))
+ self.assertTrue(int(output)>=3, msg = msg)
diff --git a/meta/lib/oeqa/runtime/cases/ltp.py b/meta/lib/oeqa/runtime/cases/ltp.py
new file mode 100644
index 0000000000..30548640bc
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ltp.py
@@ -0,0 +1,118 @@
+# LTP runtime
+#
+# Copyright (c) 2019 MontaVista Software, LLC
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import time
+import datetime
+import pprint
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+from oeqa.utils.logparser import LtpParser
+
+class LtpTestBase(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.ltp_startup()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.ltp_finishup()
+
+ @classmethod
+ def ltp_startup(cls):
+ cls.sections = {}
+ cls.failmsg = ""
+ test_log_dir = os.path.join(cls.td.get('WORKDIR', ''), 'testimage')
+ timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
+
+ cls.ltptest_log_dir_link = os.path.join(test_log_dir, 'ltp_log')
+ cls.ltptest_log_dir = '%s.%s' % (cls.ltptest_log_dir_link, timestamp)
+ os.makedirs(cls.ltptest_log_dir)
+
+ cls.tc.target.run("mkdir -p /opt/ltp/results")
+
+ if not hasattr(cls.tc, "extraresults"):
+ cls.tc.extraresults = {}
+ cls.extras = cls.tc.extraresults
+ cls.extras['ltpresult.rawlogs'] = {'log': ""}
+
+
+ @classmethod
+ def ltp_finishup(cls):
+ cls.extras['ltpresult.sections'] = cls.sections
+
+ # update symlink to ltp_log
+ if os.path.exists(cls.ltptest_log_dir_link):
+ os.remove(cls.ltptest_log_dir_link)
+ os.symlink(os.path.basename(cls.ltptest_log_dir), cls.ltptest_log_dir_link)
+
+ if cls.failmsg:
+ cls.fail(cls.failmsg)
+
+class LtpTest(LtpTestBase):
+
+ ltp_groups = ["math", "syscalls", "dio", "io", "mm", "ipc", "sched", "nptl", "pty", "containers", "controllers", "filecaps", "cap_bounds", "fcntl-locktests", "connectors","timers", "commands", "net.ipv6_lib", "input","fs_perms_simple"]
+
+ ltp_fs = ["fs", "fsx", "fs_bind", "fs_ext4"]
+ # skip kernel cpuhotplug
+ ltp_kernel = ["power_management_tests", "hyperthreading ", "kernel_misc", "hugetlb"]
+ ltp_groups += ltp_fs
+
+ def runltp(self, ltp_group):
+ cmd = '/opt/ltp/runltp -f %s -p -q -r /opt/ltp -l /opt/ltp/results/%s -I 1 -d /opt/ltp' % (ltp_group, ltp_group)
+ starttime = time.time()
+ (status, output) = self.target.run(cmd)
+ endtime = time.time()
+
+ with open(os.path.join(self.ltptest_log_dir, "%s-raw.log" % ltp_group), 'w') as f:
+ f.write(output)
+
+ self.extras['ltpresult.rawlogs']['log'] = self.extras['ltpresult.rawlogs']['log'] + output
+
+ # copy nice log from DUT
+ dst = os.path.join(self.ltptest_log_dir, "%s" % ltp_group )
+ remote_src = "/opt/ltp/results/%s" % ltp_group
+ (status, output) = self.target.copyFrom(remote_src, dst)
+ msg = 'File could not be copied. Output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ parser = LtpParser()
+ results, sections = parser.parse(dst)
+
+ runtime = int(endtime-starttime)
+ sections['duration'] = runtime
+ self.sections[ltp_group] = sections
+
+ failed_tests = {}
+ for test in results:
+ result = results[test]
+ testname = ("ltpresult." + ltp_group + "." + test)
+ self.extras[testname] = {'status': result}
+ if result == 'FAILED':
+ failed_tests[ltp_group] = test
+
+ if failed_tests:
+ self.failmsg = self.failmsg + "Failed ptests:\n%s" % pprint.pformat(failed_tests)
+
+ # LTP runtime tests
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(["ltp"])
+ def test_ltp_help(self):
+ (status, output) = self.target.run('/opt/ltp/runltp --help')
+ msg = 'Failed to get ltp help. Output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ @OETestDepends(['ltp.LtpTest.test_ltp_help'])
+ def test_ltp_groups(self):
+ for ltp_group in self.ltp_groups:
+ self.runltp(ltp_group)
+
+ @OETestDepends(['ltp.LtpTest.test_ltp_groups'])
+ def test_ltp_runltp_cve(self):
+ self.runltp("cve")
diff --git a/meta/lib/oeqa/runtime/cases/ltp_compliance.py b/meta/lib/oeqa/runtime/cases/ltp_compliance.py
new file mode 100644
index 0000000000..ba47c78fd4
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ltp_compliance.py
@@ -0,0 +1,97 @@
+# LTP compliance runtime
+#
+# Copyright (c) 2019 MontaVista Software, LLC
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import time
+import datetime
+import pprint
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+from oeqa.utils.logparser import LtpComplianceParser
+
+class LtpPosixBase(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.ltp_startup()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.ltp_finishup()
+
+ @classmethod
+ def ltp_startup(cls):
+ cls.sections = {}
+ cls.failmsg = ""
+ test_log_dir = os.path.join(cls.td.get('WORKDIR', ''), 'testimage')
+ timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
+
+ cls.ltptest_log_dir_link = os.path.join(test_log_dir, 'ltpcomp_log')
+ cls.ltptest_log_dir = '%s.%s' % (cls.ltptest_log_dir_link, timestamp)
+ os.makedirs(cls.ltptest_log_dir)
+
+ cls.tc.target.run("mkdir -p /opt/ltp/results")
+
+ if not hasattr(cls.tc, "extraresults"):
+ cls.tc.extraresults = {}
+ cls.extras = cls.tc.extraresults
+ cls.extras['ltpposixresult.rawlogs'] = {'log': ""}
+
+
+ @classmethod
+ def ltp_finishup(cls):
+ cls.extras['ltpposixresult.sections'] = cls.sections
+
+ # update symlink to ltp_log
+ if os.path.exists(cls.ltptest_log_dir_link):
+ os.remove(cls.ltptest_log_dir_link)
+
+ os.symlink(os.path.basename(cls.ltptest_log_dir), cls.ltptest_log_dir_link)
+
+ if cls.failmsg:
+ cls.fail(cls.failmsg)
+
+class LtpPosixTest(LtpPosixBase):
+ posix_groups = ["AIO", "MEM", "MSG", "SEM", "SIG", "THR", "TMR", "TPS"]
+
+ def runltp(self, posix_group):
+ cmd = "/opt/ltp/bin/run-posix-option-group-test.sh %s 2>@1 | tee /opt/ltp/results/%s" % (posix_group, posix_group)
+ starttime = time.time()
+ (status, output) = self.target.run(cmd)
+ endtime = time.time()
+
+ with open(os.path.join(self.ltptest_log_dir, "%s" % posix_group), 'w') as f:
+ f.write(output)
+
+ self.extras['ltpposixresult.rawlogs']['log'] = self.extras['ltpposixresult.rawlogs']['log'] + output
+
+ parser = LtpComplianceParser()
+ results, sections = parser.parse(os.path.join(self.ltptest_log_dir, "%s" % posix_group))
+
+ runtime = int(endtime-starttime)
+ sections['duration'] = runtime
+ self.sections[posix_group] = sections
+
+ failed_tests = {}
+ for test in results:
+ result = results[test]
+ testname = ("ltpposixresult." + posix_group + "." + test)
+ self.extras[testname] = {'status': result}
+ if result == 'FAILED':
+ failed_tests[posix_group] = test
+
+ if failed_tests:
+ self.failmsg = self.failmsg + "Failed ptests:\n%s" % pprint.pformat(failed_tests)
+
+ # LTP Posix compliance runtime tests
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(["ltp"])
+ def test_posix_groups(self):
+ for posix_group in self.posix_groups:
+ self.runltp(posix_group)
diff --git a/meta/lib/oeqa/runtime/cases/ltp_stress.py b/meta/lib/oeqa/runtime/cases/ltp_stress.py
new file mode 100644
index 0000000000..2445ffbc93
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ltp_stress.py
@@ -0,0 +1,98 @@
+# LTP Stress runtime
+#
+# Copyright (c) 2019 MontaVista Software, LLC
+#
+# SPDX-License-Identifier: MIT
+#
+
+import time
+import datetime
+import pprint
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+from oeqa.core.decorator.data import skipIfQemu
+from oeqa.utils.logparser import LtpParser
+
+class LtpStressBase(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.ltp_startup()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.ltp_finishup()
+
+ @classmethod
+ def ltp_startup(cls):
+ cls.sections = {}
+ cls.failmsg = ""
+ test_log_dir = os.path.join(cls.td.get('WORKDIR', ''), 'testimage')
+ timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
+
+ cls.ltptest_log_dir_link = os.path.join(test_log_dir, 'ltpstress_log')
+ cls.ltptest_log_dir = '%s.%s' % (cls.ltptest_log_dir_link, timestamp)
+ os.makedirs(cls.ltptest_log_dir)
+
+ cls.tc.target.run("mkdir -p /opt/ltp/results")
+
+ if not hasattr(cls.tc, "extraresults"):
+ cls.tc.extraresults = {}
+ cls.extras = cls.tc.extraresults
+ cls.extras['ltpstressresult.rawlogs'] = {'log': ""}
+
+
+ @classmethod
+ def ltp_finishup(cls):
+ cls.extras['ltpstressresult.sections'] = cls.sections
+
+ # update symlink to ltp_log
+ if os.path.exists(cls.ltptest_log_dir_link):
+ os.remove(cls.ltptest_log_dir_link)
+
+ os.symlink(os.path.basename(cls.ltptest_log_dir), cls.ltptest_log_dir_link)
+
+ if cls.failmsg:
+ cls.fail(cls.failmsg)
+
+class LtpStressTest(LtpStressBase):
+
+ def runltp(self, stress_group):
+ cmd = '/opt/ltp/runltp -f %s -p -q 2>@1 | tee /opt/ltp/results/%s' % (stress_group, stress_group)
+ starttime = time.time()
+ (status, output) = self.target.run(cmd)
+ endtime = time.time()
+ with open(os.path.join(self.ltptest_log_dir, "%s" % stress_group), 'w') as f:
+ f.write(output)
+
+ self.extras['ltpstressresult.rawlogs']['log'] = self.extras['ltpstressresult.rawlogs']['log'] + output
+
+ parser = LtpParser()
+ results, sections = parser.parse(os.path.join(self.ltptest_log_dir, "%s" % stress_group))
+
+ runtime = int(endtime-starttime)
+ sections['duration'] = runtime
+ self.sections[stress_group] = sections
+
+ failed_tests = {}
+ for test in results:
+ result = results[test]
+ testname = ("ltpstressresult." + stress_group + "." + test)
+ self.extras[testname] = {'status': result}
+ if result == 'FAILED':
+ failed_tests[stress_group] = test
+
+ if failed_tests:
+ self.failmsg = self.failmsg + "Failed ptests:\n%s" % pprint.pformat(failed_tests)
+
+ # LTP stress runtime tests
+ #
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(["ltp"])
+ def test_ltp_stress(self):
+ self.tc.target.run("sed -i -r 's/^fork12.*//' /opt/ltp/runtest/crashme")
+ self.runltp('crashme')
diff --git a/meta/lib/oeqa/runtime/cases/multilib.py b/meta/lib/oeqa/runtime/cases/multilib.py
new file mode 100644
index 0000000000..62e662b01c
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/multilib.py
@@ -0,0 +1,44 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotInDataVar
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class MultilibTest(OERuntimeTestCase):
+
+ def archtest(self, binary, arch):
+ """
+ Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64).
+ """
+
+ status, output = self.target.run('readelf -h %s' % binary)
+ self.assertEqual(status, 0, 'Failed to readelf %s' % binary)
+
+ l = [l.split()[1] for l in output.split('\n') if "Class:" in l]
+ if l:
+ theclass = l[0]
+ else:
+ self.fail('Cannot parse readelf. Output:\n%s' % output)
+
+ msg = "%s isn't %s (is %s)" % (binary, arch, theclass)
+ self.assertEqual(theclass, arch, msg=msg)
+
+ @skipIfNotInDataVar('MULTILIBS', 'multilib:lib32',
+ "This isn't a multilib:lib32 image")
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(['binutils'])
+ @OEHasPackage(['lib32-libc6'])
+ def test_check_multilib_libc(self):
+ """
+ Check that a multilib image has both 32-bit and 64-bit libc in.
+ """
+ self.archtest("/lib/libc.so.6", "ELF32")
+ self.archtest("/lib64/libc.so.6", "ELF64")
+
+ @OETestDepends(['multilib.MultilibTest.test_check_multilib_libc'])
+ @OEHasPackage(['lib32-connman', '!connman'])
+ def test_file_connman(self):
+ self.archtest("/usr/sbin/connmand", "ELF32")
diff --git a/meta/lib/oeqa/runtime/cases/oe_syslog.py b/meta/lib/oeqa/runtime/cases/oe_syslog.py
new file mode 100644
index 0000000000..f3c2bedbaf
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/oe_syslog.py
@@ -0,0 +1,131 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfDataVar
+from oeqa.runtime.decorator.package import OEHasPackage
+import time
+
+class SyslogTest(OERuntimeTestCase):
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(["busybox-syslog", "sysklogd", "rsyslog", "syslog-ng"])
+ def test_syslog_running(self):
+ status, output = self.target.run(self.tc.target_cmds['ps'])
+ msg = "Failed to execute %s" % self.tc.target_cmds['ps']
+ self.assertEqual(status, 0, msg=msg)
+ msg = "No syslog daemon process; %s output:\n%s" % (self.tc.target_cmds['ps'], output)
+ hasdaemon = "syslogd" in output or "syslog-ng" in output or "svlogd" in output
+ self.assertTrue(hasdaemon, msg=msg)
+
+class SyslogTestConfig(OERuntimeTestCase):
+
+ def verif_not_running(self, pids):
+ for pid in pids:
+ status, err_output = self.target.run('kill -0 %s' %pid)
+ if not status:
+ self.logger.debug("previous %s is still running" %pid)
+ return 1
+
+ def verify_running(self, names):
+ pids = []
+ for name in names:
+ status, pid = self.target.run('pidof %s' %name)
+ if status:
+ self.logger.debug("%s is not running" %name)
+ return 1, pids
+ pids.append(pid)
+ return 0, pids
+
+
+ def restart_sanity(self, names, restart_cmd, pidchange=True):
+ status, original_pids = self.verify_running(names)
+ if status:
+ return False
+
+ status, output = self.target.run(restart_cmd)
+
+ msg = ('Could not restart %s service. Status and output: %s and %s' % (names, status, output))
+ self.assertEqual(status, 0, msg)
+
+ if not pidchange:
+ return True
+
+ # Always check for an error, most likely a race between shutting down and starting up
+ timeout = time.time() + 30
+
+ restarted = False
+ status = ""
+ while time.time() < timeout:
+ # Verify the previous ones are no longer running
+ status = self.verif_not_running(original_pids)
+ if status:
+ status = "Original syslog processes still running"
+ continue
+
+ status, pids = self.verify_running(names)
+ if status:
+ status = "New syslog processes not running"
+ continue
+
+ # Everything is fine now, so exit to continue the test
+ restarted = True
+ break
+
+ msg = ('%s didn\'t appear to restart: %s' % (names, status))
+ self.assertTrue(restarted, msg)
+
+ return True
+
+ @OETestDepends(['oe_syslog.SyslogTest.test_syslog_running'])
+ def test_syslog_logger(self):
+ status, output = self.target.run('logger foobar')
+ msg = "Can't log into syslog. Output: %s " % output
+ self.assertEqual(status, 0, msg=msg)
+
+ # There is no way to flush the logger to disk in all cases
+ time.sleep(1)
+
+ status, output = self.target.run('grep foobar /var/log/messages')
+ if status != 0:
+ if self.tc.td.get("VIRTUAL-RUNTIME_init_manager") == "systemd":
+ status, output = self.target.run('journalctl -o cat | grep foobar')
+ else:
+ status, output = self.target.run('logread | grep foobar')
+ msg = ('Test log string not found in /var/log/messages or logread.'
+ ' Output: %s ' % output)
+ self.assertEqual(status, 0, msg=msg)
+
+
+ @OETestDepends(['oe_syslog.SyslogTest.test_syslog_running'])
+ def test_syslog_restart(self):
+ if self.restart_sanity(['systemd-journald'], 'systemctl restart syslog.service', pidchange=False):
+ pass
+ elif self.restart_sanity(['rsyslogd'], '/etc/init.d/rsyslog restart'):
+ pass
+ elif self.restart_sanity(['syslogd', 'klogd'], '/etc/init.d/syslog restart'):
+ pass
+ else:
+ self.logger.info("No syslog found to restart, ignoring")
+
+
+ @OETestDepends(['oe_syslog.SyslogTestConfig.test_syslog_logger'])
+ @OEHasPackage(["busybox-syslog"])
+ @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd',
+ 'Not appropiate for systemd image')
+ def test_syslog_startup_config(self):
+ cmd = 'echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf'
+ self.target.run(cmd)
+
+ self.test_syslog_restart()
+
+ cmd = 'logger foobar && grep foobar /var/log/test'
+ status,output = self.target.run(cmd)
+ msg = 'Test log string not found. Output: %s ' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ cmd = "sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf"
+ self.target.run(cmd)
+ self.test_syslog_restart()
diff --git a/meta/lib/oeqa/runtime/cases/opkg.py b/meta/lib/oeqa/runtime/cases/opkg.py
new file mode 100644
index 0000000000..9cfee1cd88
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/opkg.py
@@ -0,0 +1,58 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+from oeqa.utils.httpserver import HTTPService
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature, skipIfFeature
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class OpkgTest(OERuntimeTestCase):
+
+ def pkg(self, command, expected = 0):
+ command = 'opkg %s' % command
+ status, output = self.target.run(command, 1500)
+ message = os.linesep.join([command, output])
+ self.assertEqual(status, expected, message)
+ return output
+
+class OpkgRepoTest(OpkgTest):
+
+ @classmethod
+ def setUp(cls):
+ allarchfeed = 'all'
+ if cls.tc.td["MULTILIB_VARIANTS"]:
+ allarchfeed = cls.tc.td["TUNE_PKGARCH"]
+ service_repo = os.path.join(cls.tc.td['DEPLOY_DIR_IPK'], allarchfeed)
+ cls.repo_server = HTTPService(service_repo,
+ '0.0.0.0', port=cls.tc.target.server_port,
+ logger=cls.tc.logger)
+ cls.repo_server.start()
+
+ @classmethod
+ def tearDown(cls):
+ cls.repo_server.stop()
+
+ def setup_source_config_for_package_install(self):
+ apt_get_source_server = 'http://%s:%s/' % (self.tc.target.server_ip, self.repo_server.port)
+ apt_get_sourceslist_dir = '/etc/opkg/'
+ self.target.run('cd %s; echo src/gz all %s >> opkg.conf' % (apt_get_sourceslist_dir, apt_get_source_server))
+
+ def cleanup_source_config_for_package_install(self):
+ apt_get_sourceslist_dir = '/etc/opkg/'
+ self.target.run('cd %s; sed -i "/^src/d" opkg.conf' % (apt_get_sourceslist_dir))
+
+ @skipIfNotFeature('package-management',
+ 'Test requires package-management to be in IMAGE_FEATURES')
+ @skipIfNotDataVar('IMAGE_PKGTYPE', 'ipk',
+ 'IPK is not the primary package manager')
+ @skipIfFeature('read-only-rootfs',
+ 'Test does not work with read-only-rootfs in IMAGE_FEATURES')
+ @OEHasPackage(['opkg'])
+ def test_opkg_install_from_repo(self):
+ self.setup_source_config_for_package_install()
+ self.pkg('update')
+ self.pkg('remove run-postinsts-dev')
+ self.pkg('install run-postinsts-dev')
+ self.cleanup_source_config_for_package_install()
diff --git a/meta/lib/oeqa/runtime/cases/pam.py b/meta/lib/oeqa/runtime/cases/pam.py
new file mode 100644
index 0000000000..271a1943e3
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/pam.py
@@ -0,0 +1,35 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=287 testcase
+# Note that the image under test must have "pam" in DISTRO_FEATURES
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotFeature
+
+class PamBasicTest(OERuntimeTestCase):
+
+ @skipIfNotFeature('pam', 'Test requires pam to be in DISTRO_FEATURES')
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_pam(self):
+ status, output = self.target.run('login --help')
+ msg = ('login command does not work as expected. '
+ 'Status and output:%s and %s' % (status, output))
+ self.assertEqual(status, 1, msg = msg)
+
+ status, output = self.target.run('passwd --help')
+ msg = ('passwd command does not work as expected. '
+ 'Status and output:%s and %s' % (status, output))
+ self.assertEqual(status, 0, msg = msg)
+
+ status, output = self.target.run('su --help')
+ msg = ('su command does not work as expected. '
+ 'Status and output:%s and %s' % (status, output))
+ self.assertEqual(status, 0, msg = msg)
+
+ status, output = self.target.run('useradd --help')
+ msg = ('useradd command does not work as expected. '
+ 'Status and output:%s and %s' % (status, output))
+ self.assertEqual(status, 0, msg = msg)
diff --git a/meta/lib/oeqa/runtime/parselogs.py b/meta/lib/oeqa/runtime/cases/parselogs.py
index 2d4a13375b..b7c7b30adf 100644
--- a/meta/lib/oeqa/runtime/parselogs.py
+++ b/meta/lib/oeqa/runtime/cases/parselogs.py
@@ -1,8 +1,15 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
import os
-import unittest
-import subprocess
-from oeqa.oetest import oeRuntimeTest
-from oeqa.utils.decorators import *
+
+from subprocess import check_output
+from shutil import rmtree
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfDataVar
+from oeqa.runtime.decorator.package import OEHasPackage
#in the future these lists could be moved outside of module
errors = ["error", "cannot", "can\'t", "failed"]
@@ -43,6 +50,13 @@ common_errors = [
"controller can't do DEVSLP, turning off",
"stmmac_dvr_probe: warning: cannot get CSR clock",
"error: couldn\'t mount because of unsupported optional features",
+ "GPT: Use GNU Parted to correct GPT errors",
+ "Cannot set xattr user.Librepo.DownloadInProgress",
+ "Failed to read /var/lib/nfs/statd/state: Success",
+ "error retry time-out =",
+ "logind: cannot setup systemd-logind helper (-61), using legacy fallback",
+ "Error changing net interface name 'eth0' to ",
+ "Cannot find a map file"
]
video_related = [
@@ -57,6 +71,10 @@ x86_common = [
'pmd_set_huge: Cannot satisfy',
'failed to setup card detect gpio',
'amd_nb: Cannot enumerate AMD northbridges',
+ 'failed to retrieve link info, disabling eDP',
+ 'Direct firmware load for iwlwifi',
+ 'Direct firmware load for regulatory.db',
+ 'failed to load regulatory.db',
] + common_errors
qemux86_common = [
@@ -64,15 +82,15 @@ qemux86_common = [
"fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.",
"can't claim BAR ",
'amd_nb: Cannot enumerate AMD northbridges',
- 'uvesafb: 5000 ms task timeout error',
- 'detected fb_set_par error, error code: -22',
- 'Getting VBE info block failed',
- 'vbe_init() failed with -22',
- 'uvesafb: mode switch failed',
+ 'uvesafb: 5000 ms task timeout, infinitely waiting',
'tsc: HPET/PMTIMER calibration failed',
+ "modeset(0): Failed to initialize the DRI2 extension",
+ "uvesafb: cannot reserve video memory at",
+ "uvesafb: probe of uvesafb.0 failed with error",
+ "glamor initialization failed",
] + common_errors
-ignore_errors = {
+ignore_errors = {
'default' : common_errors,
'qemux86' : [
'Failed to access perfctr msr (MSR',
@@ -82,9 +100,11 @@ ignore_errors = {
'qemumips' : [
'Failed to load module "glx"',
'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
+ 'cacheinfo: Failed to find cpu0 device node',
] + common_errors,
'qemumips64' : [
'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
+ 'cacheinfo: Failed to find cpu0 device node',
] + common_errors,
'qemuppc' : [
'PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff]',
@@ -103,6 +123,7 @@ ignore_errors = {
'OF: amba_device_add() failed (-19) for /amba/sctl@101e0000',
'OF: amba_device_add() failed (-19) for /amba/watchdog@101e1000',
'OF: amba_device_add() failed (-19) for /amba/sci@101f0000',
+ 'OF: amba_device_add() failed (-19) for /amba/spi@101f4000',
'OF: amba_device_add() failed (-19) for /amba/ssp@101f4000',
'OF: amba_device_add() failed (-19) for /amba/fpga/sci@a000',
'Failed to initialize \'/amba/timer@101e3000\': -22',
@@ -114,15 +135,6 @@ ignore_errors = {
'dmi: Firmware registration failed.',
'irq: type mismatch, failed to map hwirq-27 for /intc',
] + common_errors,
- 'emenlow' : [
- '[Firmware Bug]: ACPI: No _BQC method, cannot determine initial brightness',
- '(EE) Failed to load module "psb"',
- '(EE) Failed to load module psb',
- '(EE) Failed to load module "psbdrv"',
- '(EE) Failed to load module psbdrv',
- '(EE) open /dev/fb0: No such file or directory',
- '(EE) AIGLX: reverting to software rendering',
- ] + x86_common,
'intel-core2-32' : [
'ACPI: No _BQC method, cannot determine initial brightness',
'[Firmware Bug]: ACPI: No _BQC method, cannot determine initial brightness',
@@ -135,165 +147,219 @@ ignore_errors = {
'dmi: Firmware registration failed.',
'ioremap error for 0x78',
] + x86_common,
- 'intel-corei7-64' : x86_common,
- 'crownbay' : x86_common,
+ 'intel-corei7-64' : [
+ 'can\'t set Max Payload Size to 256',
+ 'intel_punit_ipc: can\'t request region for resource',
+ '[drm] parse error at position 4 in video mode \'efifb\'',
+ 'ACPI Error: Could not enable RealTimeClock event',
+ 'ACPI Warning: Could not enable fixed event - RealTimeClock',
+ 'hci_intel INT33E1:00: Unable to retrieve gpio',
+ 'hci_intel: probe of INT33E1:00 failed',
+ 'can\'t derive routing for PCI INT A',
+ 'failed to read out thermal zone',
+ 'Bluetooth: hci0: Setting Intel event mask failed',
+ 'ttyS2 - failed to request DMA',
+ 'Bluetooth: hci0: Failed to send firmware data (-38)',
+ 'atkbd serio0: Failed to enable keyboard on isa0060/serio0',
+ ] + x86_common,
'genericx86' : x86_common,
'genericx86-64' : [
'Direct firmware load for i915',
'Failed to load firmware i915',
'Failed to fetch GuC',
'Failed to initialize GuC',
+ 'Failed to load DMC firmware',
'The driver is built-in, so to load the firmware you need to',
] + x86_common,
'edgerouter' : [
+ 'not creating \'/sys/firmware/fdt\'',
+ 'Failed to find cpu0 device node',
'Fatal server error:',
+ 'Server terminated with error',
] + common_errors,
- 'jasperforest' : [
- 'Activated service \'org.bluez\' failed:',
- 'Unable to find NFC netlink family',
+ 'beaglebone-yocto' : [
+ 'Direct firmware load for regulatory.db',
+ 'failed to load regulatory.db',
+ 'l4_wkup_cm',
+ 'Failed to load module "glx"',
+ 'Failed to make EGL context current',
+ 'glamor initialization failed',
+ ] + common_errors,
+ 'mpc8315e-rdb' : [
+ 'of_irq_parse_pci: failed with',
+ 'Fatal server error:',
+ 'Server terminated with error',
] + common_errors,
}
log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"]
-class ParseLogsTest(oeRuntimeTest):
+class ParseLogsTest(OERuntimeTestCase):
@classmethod
- def setUpClass(self):
- self.errors = errors
+ def setUpClass(cls):
+ cls.errors = errors
# When systemd is enabled we need to notice errors on
# circular dependencies in units.
- if self.hasFeature("systemd"):
- self.errors.extend([
+ if 'systemd' in cls.td.get('DISTRO_FEATURES', ''):
+ cls.errors.extend([
'Found ordering cycle on',
'Breaking ordering cycle by deleting job',
'deleted to break ordering cycle',
'Ordering cycle found, skipping',
])
- self.ignore_errors = ignore_errors
- self.log_locations = log_locations
- self.msg = ""
- (is_lsb, location) = oeRuntimeTest.tc.target.run("which LSB_Test.sh")
+ cls.ignore_errors = ignore_errors
+ cls.log_locations = log_locations
+ cls.msg = ''
+ is_lsb, _ = cls.tc.target.run("which LSB_Test.sh")
if is_lsb == 0:
- for machine in self.ignore_errors:
- self.ignore_errors[machine] = self.ignore_errors[machine] + video_related
+ for machine in cls.ignore_errors:
+ cls.ignore_errors[machine] = cls.ignore_errors[machine] \
+ + video_related
def getMachine(self):
- return oeRuntimeTest.tc.d.getVar("MACHINE", True)
+ return self.td.get('MACHINE', '')
def getWorkdir(self):
- return oeRuntimeTest.tc.d.getVar("WORKDIR", True)
+ return self.td.get('WORKDIR', '')
- #get some information on the CPU of the machine to display at the beginning of the output. This info might be useful in some cases.
+ # Get some information on the CPU of the machine to display at the
+ # beginning of the output. This info might be useful in some cases.
def getHardwareInfo(self):
hwi = ""
- (status, cpu_name) = self.target.run("cat /proc/cpuinfo | grep \"model name\" | head -n1 | awk 'BEGIN{FS=\":\"}{print $2}'")
- (status, cpu_physical_cores) = self.target.run("cat /proc/cpuinfo | grep \"cpu cores\" | head -n1 | awk {'print $4'}")
- (status, cpu_logical_cores) = self.target.run("cat /proc/cpuinfo | grep \"processor\" | wc -l")
- (status, cpu_arch) = self.target.run("uname -m")
- hwi += "Machine information: \n"
- hwi += "*******************************\n"
- hwi += "Machine name: "+self.getMachine()+"\n"
- hwi += "CPU: "+str(cpu_name)+"\n"
- hwi += "Arch: "+str(cpu_arch)+"\n"
- hwi += "Physical cores: "+str(cpu_physical_cores)+"\n"
- hwi += "Logical cores: "+str(cpu_logical_cores)+"\n"
- hwi += "*******************************\n"
+ cmd = ('cat /proc/cpuinfo | grep "model name" | head -n1 | '
+ " awk 'BEGIN{FS=\":\"}{print $2}'")
+ _, cpu_name = self.target.run(cmd)
+
+ cmd = ('cat /proc/cpuinfo | grep "cpu cores" | head -n1 | '
+ "awk {'print $4'}")
+ _, cpu_physical_cores = self.target.run(cmd)
+
+ cmd = 'cat /proc/cpuinfo | grep "processor" | wc -l'
+ _, cpu_logical_cores = self.target.run(cmd)
+
+ _, cpu_arch = self.target.run('uname -m')
+
+ hwi += 'Machine information: \n'
+ hwi += '*******************************\n'
+ hwi += 'Machine name: ' + self.getMachine() + '\n'
+ hwi += 'CPU: ' + str(cpu_name) + '\n'
+ hwi += 'Arch: ' + str(cpu_arch)+ '\n'
+ hwi += 'Physical cores: ' + str(cpu_physical_cores) + '\n'
+ hwi += 'Logical cores: ' + str(cpu_logical_cores) + '\n'
+ hwi += '*******************************\n'
+
return hwi
- #go through the log locations provided and if it's a folder create a list with all the .log files in it, if it's a file just add
- #it to that list
+ # Go through the log locations provided and if it's a folder
+ # create a list with all the .log files in it, if it's a file
+ # just add it to that list.
def getLogList(self, log_locations):
logs = []
for location in log_locations:
- (status, output) = self.target.run("test -f "+str(location))
- if (status == 0):
+ status, _ = self.target.run('test -f ' + str(location))
+ if status == 0:
logs.append(str(location))
else:
- (status, output) = self.target.run("test -d "+str(location))
- if (status == 0):
- (status, output) = self.target.run("find "+str(location)+"/*.log -maxdepth 1 -type f")
- if (status == 0):
+ status, _ = self.target.run('test -d ' + str(location))
+ if status == 0:
+ cmd = 'find ' + str(location) + '/*.log -maxdepth 1 -type f'
+ status, output = self.target.run(cmd)
+ if status == 0:
output = output.splitlines()
for logfile in output:
- logs.append(os.path.join(location,str(logfile)))
+ logs.append(os.path.join(location, str(logfile)))
return logs
- #copy the log files to be parsed locally
+ # Copy the log files to be parsed locally
def transfer_logs(self, log_list):
workdir = self.getWorkdir()
self.target_logs = workdir + '/' + 'target_logs'
target_logs = self.target_logs
- if not os.path.exists(target_logs):
- os.makedirs(target_logs)
- bb.utils.remove(self.target_logs + "/*")
+ if os.path.exists(target_logs):
+ rmtree(self.target_logs)
+ os.makedirs(target_logs)
for f in log_list:
- self.target.copy_from(f, target_logs)
+ self.target.copyFrom(str(f), target_logs)
- #get the local list of logs
+ # Get the local list of logs
def get_local_log_list(self, log_locations):
self.transfer_logs(self.getLogList(log_locations))
- logs = [ os.path.join(self.target_logs, f) for f in os.listdir(self.target_logs) if os.path.isfile(os.path.join(self.target_logs, f)) ]
+ list_dir = os.listdir(self.target_logs)
+ dir_files = [os.path.join(self.target_logs, f) for f in list_dir]
+ logs = [f for f in dir_files if os.path.isfile(f)]
return logs
- #build the grep command to be used with filters and exclusions
+ # Build the grep command to be used with filters and exclusions
def build_grepcmd(self, errors, ignore_errors, log):
- grepcmd = "grep "
- grepcmd +="-Ei \""
+ grepcmd = 'grep '
+ grepcmd += '-Ei "'
for error in errors:
- grepcmd += error+"|"
+ grepcmd += '\<' + error + '\>' + '|'
grepcmd = grepcmd[:-1]
- grepcmd += "\" "+str(log)+" | grep -Eiv \'"
+ grepcmd += '" ' + str(log) + " | grep -Eiv \'"
+
try:
errorlist = ignore_errors[self.getMachine()]
except KeyError:
- self.msg += "No ignore list found for this machine, using default\n"
+ self.msg += 'No ignore list found for this machine, using default\n'
errorlist = ignore_errors['default']
+
for ignore_error in errorlist:
- ignore_error = ignore_error.replace("(", "\(")
- ignore_error = ignore_error.replace(")", "\)")
- ignore_error = ignore_error.replace("'", ".")
- ignore_error = ignore_error.replace("?", "\?")
- ignore_error = ignore_error.replace("[", "\[")
- ignore_error = ignore_error.replace("]", "\]")
- ignore_error = ignore_error.replace("*", "\*")
- ignore_error = ignore_error.replace("0-9", "[0-9]")
- grepcmd += ignore_error+"|"
+ ignore_error = ignore_error.replace('(', '\(')
+ ignore_error = ignore_error.replace(')', '\)')
+ ignore_error = ignore_error.replace("'", '.')
+ ignore_error = ignore_error.replace('?', '\?')
+ ignore_error = ignore_error.replace('[', '\[')
+ ignore_error = ignore_error.replace(']', '\]')
+ ignore_error = ignore_error.replace('*', '\*')
+ ignore_error = ignore_error.replace('0-9', '[0-9]')
+ grepcmd += ignore_error + '|'
grepcmd = grepcmd[:-1]
grepcmd += "\'"
+
return grepcmd
- #grep only the errors so that their context could be collected. Default context is 10 lines before and after the error itself
- def parse_logs(self, errors, ignore_errors, logs, lines_before = 10, lines_after = 10):
+ # Grep only the errors so that their context could be collected.
+ # Default context is 10 lines before and after the error itself
+ def parse_logs(self, errors, ignore_errors, logs,
+ lines_before = 10, lines_after = 10):
results = {}
rez = []
grep_output = ''
+
for log in logs:
result = None
thegrep = self.build_grepcmd(errors, ignore_errors, log)
+
try:
- result = subprocess.check_output(thegrep, shell=True).decode("utf-8")
+ result = check_output(thegrep, shell=True).decode('utf-8')
except:
pass
- if (result is not None):
- results[log.replace('target_logs/','')] = {}
+
+ if result is not None:
+ results[log] = {}
rez = result.splitlines()
+
for xrez in rez:
try:
- grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]).decode("utf-8")
+ cmd = ['grep', '-F', xrez, '-B', str(lines_before)]
+ cmd += ['-A', str(lines_after), log]
+ grep_output = check_output(cmd).decode('utf-8')
except:
pass
- results[log.replace('target_logs/','')][xrez]=grep_output
+ results[log][xrez]=grep_output
+
return results
- #get the output of dmesg and write it in a file. This file is added to log_locations.
+ # Get the output of dmesg and write it in a file.
+ # This file is added to log_locations.
def write_dmesg(self):
- (status, dmesg) = self.target.run("dmesg > /tmp/dmesg_output.log")
+ (status, dmesg) = self.target.run('dmesg > /tmp/dmesg_output.log')
- @testcase(1059)
- @skipUnlessPassed('test_ssh')
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
def test_parselogs(self):
self.write_dmesg()
log_list = self.get_local_log_list(self.log_locations)
@@ -301,13 +367,13 @@ class ParseLogsTest(oeRuntimeTest):
print(self.getHardwareInfo())
errcount = 0
for log in result:
- self.msg += "Log: "+log+"\n"
- self.msg += "-----------------------\n"
+ self.msg += 'Log: ' + log + '\n'
+ self.msg += '-----------------------\n'
for error in result[log]:
errcount += 1
- self.msg += "Central error: "+str(error)+"\n"
- self.msg += "***********************\n"
- self.msg += result[str(log)][str(error)]+"\n"
- self.msg += "***********************\n"
- self.msg += "%s errors found in logs." % errcount
+ self.msg += 'Central error: ' + str(error) + '\n'
+ self.msg += '***********************\n'
+ self.msg += result[str(log)][str(error)] + '\n'
+ self.msg += '***********************\n'
+ self.msg += '%s errors found in logs.' % errcount
self.assertEqual(errcount, 0, msg=self.msg)
diff --git a/meta/lib/oeqa/runtime/cases/perl.py b/meta/lib/oeqa/runtime/cases/perl.py
new file mode 100644
index 0000000000..2c6b3b7846
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/perl.py
@@ -0,0 +1,17 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class PerlTest(OERuntimeTestCase):
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(['perl'])
+ def test_perl_works(self):
+ status, output = self.target.run("perl -e '$_=\"Uryyb, jbeyq\"; tr/a-zA-Z/n-za-mN-ZA-M/;print'")
+ self.assertEqual(status, 0)
+ self.assertEqual(output, "Hello, world")
diff --git a/meta/lib/oeqa/runtime/cases/ping.py b/meta/lib/oeqa/runtime/cases/ping.py
new file mode 100644
index 0000000000..f6603f75ec
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ping.py
@@ -0,0 +1,26 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from subprocess import Popen, PIPE
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.oetimeout import OETimeout
+
+class PingTest(OERuntimeTestCase):
+
+ @OETimeout(30)
+ def test_ping(self):
+ output = ''
+ count = 0
+ while count < 5:
+ cmd = 'ping -c 1 %s' % self.target.ip
+ proc = Popen(cmd, shell=True, stdout=PIPE)
+ output += proc.communicate()[0].decode('utf-8')
+ if proc.poll() == 0:
+ count += 1
+ else:
+ count = 0
+ msg = ('Expected 5 consecutive, got %d.\n'
+ 'ping output is:\n%s' % (count,output))
+ self.assertEqual(count, 5, msg = msg)
diff --git a/meta/lib/oeqa/runtime/cases/ptest.py b/meta/lib/oeqa/runtime/cases/ptest.py
new file mode 100644
index 0000000000..d8d1e1b344
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ptest.py
@@ -0,0 +1,84 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import unittest
+import pprint
+import datetime
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotFeature
+from oeqa.runtime.decorator.package import OEHasPackage
+from oeqa.utils.logparser import PtestParser
+
+class PtestRunnerTest(OERuntimeTestCase):
+
+ @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)
+ if status != 0:
+ self.skipTest("No -ptest packages are installed in the image")
+
+ test_log_dir = self.td.get('TEST_LOG_DIR', '')
+ # The TEST_LOG_DIR maybe NULL when testimage is added after
+ # testdata.json is generated.
+ if not test_log_dir:
+ test_log_dir = os.path.join(self.td.get('WORKDIR', ''), 'testimage')
+ # Don't use self.td.get('DATETIME'), it's from testdata.json, not
+ # up-to-date, and may cause "File exists" when re-reun.
+ timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
+ ptest_log_dir_link = os.path.join(test_log_dir, 'ptest_log')
+ ptest_log_dir = '%s.%s' % (ptest_log_dir_link, timestamp)
+ ptest_runner_log = os.path.join(ptest_log_dir, 'ptest-runner.log')
+
+ status, output = self.target.run('ptest-runner', 0)
+ os.makedirs(ptest_log_dir)
+ with open(ptest_runner_log, 'w') as f:
+ f.write(output)
+
+ # status != 0 is OK since some ptest tests may fail
+ self.assertTrue(status != 127, msg="Cannot execute ptest-runner!")
+
+ if not hasattr(self.tc, "extraresults"):
+ self.tc.extraresults = {}
+ extras = self.tc.extraresults
+ extras['ptestresult.rawlogs'] = {'log': output}
+
+ # Parse and save results
+ parser = PtestParser()
+ results, sections = parser.parse(ptest_runner_log)
+ parser.results_as_files(ptest_log_dir)
+ if os.path.exists(ptest_log_dir_link):
+ # Remove the old link to create a new one
+ os.remove(ptest_log_dir_link)
+ os.symlink(os.path.basename(ptest_log_dir), ptest_log_dir_link)
+
+ extras['ptestresult.sections'] = sections
+
+ trans = str.maketrans("()", "__")
+ for section in results:
+ for test in results[section]:
+ result = results[section][test]
+ testname = "ptestresult." + (section or "No-section") + "." + "_".join(test.translate(trans).split())
+ extras[testname] = {'status': result}
+
+ failed_tests = {}
+ for section in results:
+ failed_testcases = [ "_".join(test.translate(trans).split()) for test in results[section] if results[section][test] == 'fail' ]
+ if failed_testcases:
+ failed_tests[section] = failed_testcases
+
+ failmsg = ""
+ status, output = self.target.run('dmesg | grep "Killed process"', 0)
+ if output:
+ failmsg = "ERROR: Processes were killed by the OOM Killer:\n%s\n" % output
+
+ if failed_tests:
+ failmsg = failmsg + "Failed ptests:\n%s" % pprint.pformat(failed_tests)
+
+ if failmsg:
+ self.fail(failmsg)
diff --git a/meta/lib/oeqa/runtime/cases/python.py b/meta/lib/oeqa/runtime/cases/python.py
new file mode 100644
index 0000000000..ec54f1e1db
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/python.py
@@ -0,0 +1,19 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class PythonTest(OERuntimeTestCase):
+ @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)
+ msg = 'Exit status was not 0. Output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ msg = 'Incorrect output: %s' % output
+ self.assertEqual(output, "Hello, world", msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py
new file mode 100644
index 0000000000..8e18b426f8
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/rpm.py
@@ -0,0 +1,153 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+import fnmatch
+import time
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfDataVar
+from oeqa.runtime.decorator.package import OEHasPackage
+from oeqa.core.utils.path import findFile
+
+class RpmBasicTest(OERuntimeTestCase):
+
+ @OEHasPackage(['rpm'])
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_rpm_help(self):
+ status, output = self.target.run('rpm --help')
+ msg = 'status and output: %s and %s' % (status, output)
+ self.assertEqual(status, 0, msg=msg)
+
+ @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)
+
+ @OETestDepends(['rpm.RpmBasicTest.test_rpm_query'])
+ def test_rpm_query_nonroot(self):
+
+ def set_up_test_user(u):
+ status, output = self.target.run('id -u %s' % u)
+ if status:
+ status, output = self.target.run('useradd %s' % u)
+ msg = 'Failed to create new user: %s' % output
+ self.assertTrue(status == 0, msg=msg)
+
+ def exec_as_test_user(u):
+ status, output = self.target.run('su -c id %s' % u)
+ msg = 'Failed to execute as new user'
+ self.assertTrue("({0})".format(u) in output, msg=msg)
+
+ status, output = self.target.run('su -c "rpm -qa" %s ' % u)
+ msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output)
+ self.assertEqual(status, 0, msg=msg)
+
+ def check_no_process_for_user(u):
+ _, output = self.target.run(self.tc.target_cmds['ps'])
+ if u + ' ' in output:
+ return False
+ else:
+ return True
+
+ def unset_up_test_user(u):
+ # ensure no test1 process in running
+ timeout = time.time() + 30
+ while time.time() < timeout:
+ if check_no_process_for_user(u):
+ break
+ else:
+ time.sleep(1)
+ status, output = self.target.run('userdel -r %s' % u)
+ msg = 'Failed to erase user: %s' % output
+ self.assertTrue(status == 0, msg=msg)
+
+ tuser = 'test1'
+
+ try:
+ set_up_test_user(tuser)
+ exec_as_test_user(tuser)
+ finally:
+ unset_up_test_user(tuser)
+
+
+class RpmInstallRemoveTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ 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):
+ cls.test_file = os.path.join(rpmdir, f)
+ cls.dst = '/tmp/base-passwd-doc.rpm'
+
+ @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)
+
+ @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install'])
+ def test_rpm_remove(self):
+ status,output = self.target.run('rpm -e base-passwd-doc')
+ msg = 'Failed to remove base-passwd-doc package: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_remove'])
+ def test_check_rpm_install_removal_log_file_size(self):
+ """
+ Summary: Check that rpm writes into /var/log/messages
+ Expected: There should be some RPM prefixed entries in the above file.
+ Product: BSPs
+ Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com>
+ Author: Alexander Kanavin <alex.kanavin@gmail.com>
+ AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
+ """
+ db_files_cmd = 'ls /var/lib/rpm/__db.*'
+ check_log_cmd = "grep RPM /var/log/messages | wc -l"
+
+ # Make sure that some database files are under /var/lib/rpm as '__db.xxx'
+ status, output = self.target.run(db_files_cmd)
+ 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')
+
+ # Install/Remove a package 10 times
+ for i in range(10):
+ status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm')
+ msg = 'Failed to install base-passwd-doc package. Reason: {}'.format(output)
+ self.assertEqual(0, status, msg=msg)
+
+ status, output = self.target.run('rpm -e base-passwd-doc')
+ 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
+ status, output = self.target.run(check_log_cmd)
+ msg = 'Failed to get the final size of the log file.'
+ self.assertEqual(0, status, msg=msg)
+
+ # Check that there's enough of them
+ self.assertGreaterEqual(int(output), 80,
+ 'Cound not find sufficient amount of rpm entries in /var/log/messages, found {} entries'.format(output))
diff --git a/meta/lib/oeqa/runtime/cases/scons.py b/meta/lib/oeqa/runtime/cases/scons.py
new file mode 100644
index 0000000000..3c7c7f7270
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/scons.py
@@ -0,0 +1,37 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class SconsCompileTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUp(cls):
+ dst = '/tmp/'
+ src = os.path.join(cls.tc.runtime_files_dir, 'hello.c')
+ cls.tc.target.copyTo(src, dst)
+
+ src = os.path.join(cls.tc.runtime_files_dir, 'SConstruct')
+ cls.tc.target.copyTo(src, dst)
+
+ @classmethod
+ def tearDown(cls):
+ files = '/tmp/hello.c /tmp/hello.o /tmp/hello /tmp/SConstruct'
+ cls.tc.target.run('rm %s' % files)
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(['gcc'])
+ @OEHasPackage(['python3-scons'])
+ def test_scons_compile(self):
+ status, output = self.target.run('cd /tmp/ && scons')
+ msg = 'scons compile failed, output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ status, output = self.target.run('/tmp/hello')
+ msg = 'running compiled file failed, output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/scp.py b/meta/lib/oeqa/runtime/cases/scp.py
new file mode 100644
index 0000000000..3a5f292152
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/scp.py
@@ -0,0 +1,37 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+from tempfile import mkstemp
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class ScpTest(OERuntimeTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.tmp_fd, cls.tmp_path = mkstemp()
+ with os.fdopen(cls.tmp_fd, 'w') as f:
+ f.seek(2 ** 22 -1)
+ f.write(os.linesep)
+
+ @classmethod
+ def tearDownClass(cls):
+ os.remove(cls.tmp_path)
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(['openssh-scp', 'dropbear'])
+ def test_scp_file(self):
+ dst = '/tmp/test_scp_file'
+
+ (status, output) = self.target.copyTo(self.tmp_path, dst)
+ msg = 'File could not be copied. Output: %s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ (status, output) = self.target.run('ls -la %s' % dst)
+ self.assertEqual(status, 0, msg = 'SCP test failed')
+
+ self.target.run('rm %s' % dst)
diff --git a/meta/lib/oeqa/runtime/cases/skeletoninit.py b/meta/lib/oeqa/runtime/cases/skeletoninit.py
new file mode 100644
index 0000000000..4779cd6bb4
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/skeletoninit.py
@@ -0,0 +1,35 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=284
+# testcase. Image under test must have meta-skeleton layer in bblayers and
+# IMAGE_INSTALL_append = " service" in local.conf
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfDataVar
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class SkeletonBasicTest(OERuntimeTestCase):
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ @OEHasPackage(['service'])
+ @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd',
+ 'Not appropiate for systemd image')
+ def test_skeleton_availability(self):
+ status, output = self.target.run('ls /etc/init.d/skeleton')
+ msg = 'skeleton init script not found. Output:\n%s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ status, output = self.target.run('ls /usr/sbin/skeleton-test')
+ msg = 'skeleton-test not found. Output:\n%s' % output
+ self.assertEqual(status, 0, msg=msg)
+
+ @OETestDepends(['skeletoninit.SkeletonBasicTest.test_skeleton_availability'])
+ def test_skeleton_script(self):
+ output1 = self.target.run("/etc/init.d/skeleton start")[1]
+ cmd = '%s | grep [s]keleton-test' % self.tc.target_cmds['ps']
+ status, output2 = self.target.run(cmd)
+ msg = ('Skeleton script could not be started:'
+ '\n%s\n%s' % (output1, output2))
+ self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/ssh.py b/meta/lib/oeqa/runtime/cases/ssh.py
new file mode 100644
index 0000000000..60a5fbbfbf
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ssh.py
@@ -0,0 +1,19 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class SSHTest(OERuntimeTestCase):
+
+ @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)
+ (status, output) = self.target.run('cat /etc/masterimage')
+ msg = "This isn't the right image - /etc/masterimage " \
+ "shouldn't be here %s" % output
+ self.assertEqual(status, 1, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/stap.py b/meta/lib/oeqa/runtime/cases/stap.py
new file mode 100644
index 0000000000..5342f6ac34
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/stap.py
@@ -0,0 +1,37 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotFeature
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class StapTest(OERuntimeTestCase):
+
+ @classmethod
+ 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 tearDown(cls):
+ files = '/tmp/hello.stp'
+ cls.tc.target.run('rm %s' % files)
+
+ @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',
+ 'cd /lib/modules/`uname -r` && (if [ ! -e build ]; then ln -s /usr/src/kernel build; fi)',
+ 'stap --disable-cache -DSTP_NO_VERREL_CHECK /tmp/hello.stp'
+ ]
+ for cmd in cmds:
+ status, output = self.target.run(cmd, 900)
+ self.assertEqual(status, 0, msg='\n'.join([cmd, output]))
diff --git a/meta/lib/oeqa/runtime/cases/storage.py b/meta/lib/oeqa/runtime/cases/storage.py
new file mode 100644
index 0000000000..166d26b252
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/storage.py
@@ -0,0 +1,149 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import re
+import time
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfQemu
+
+class StorageBase(OERuntimeTestCase):
+ def storage_mount(cls, tmo=1):
+
+ (status, output) = cls.target.run('mkdir -p %s' % cls.mount_point)
+ (status, output) = cls.target.run('mount %s %s' % (cls.device, cls.mount_point))
+ msg = ('Mount failed: %s.' % status)
+ cls.assertFalse(output, msg = msg)
+ time.sleep(tmo)
+ (status, output) = cls.target.run('cat /proc/mounts')
+ match = re.search('%s' % cls.device, output)
+ if match:
+ msg = ('Device %s not mounted.' % cls.device)
+ cls.assertTrue(match, msg = msg)
+
+ (status, output) = cls.target.run('mkdir -p %s' % cls.test_dir)
+
+ (status, output) = cls.target.run('rm -f %s/*' % cls.test_dir)
+ msg = ('Failed to cleanup files @ %s/*' % cls.test_dir)
+ cls.assertFalse(output, msg = msg)
+
+
+ def storage_basic(cls):
+ # create file on device
+ (status, output) = cls.target.run('touch %s/%s' % (cls.test_dir, cls.test_file))
+ msg = ('File %s not created on %s' % (cls.test_file, cls.device))
+ cls.assertFalse(status, msg = msg)
+ # move file
+ (status, output) = cls.target.run('mv %s/%s %s/%s1' %
+ (cls.test_dir, cls.test_file, cls.test_dir, cls.test_file))
+ msg = ('File %s not moved to %s' % (cls.test_file, cls.device))
+ cls.assertFalse(status, msg = msg)
+ # remove file
+ (status, output) = cls.target.run('rm %s/%s1' % (cls.test_dir, cls.test_file))
+ msg = ('File %s not removed on %s' % (cls.test_file, cls.device))
+ cls.assertFalse(status, msg = msg)
+
+ def storage_read(cls):
+ # check if message is in file
+ (status, output) = cls.target.run('cat %s/%s' %
+ (cls.test_dir, cls.test_file))
+
+ match = re.search('%s' % cls.test_msg, output)
+ msg = ('Test message %s not in file %s.' % (cls.test_msg, cls.test_file))
+ cls.assertEqual(status, 0, msg = msg)
+
+ def storage_write(cls):
+ # create test message in file on device
+ (status, output) = cls.target.run('echo "%s" > %s/%s' %
+ (cls.test_msg, cls.test_dir, cls.test_file))
+ msg = ('File %s not create test message on %s' % (cls.test_file, cls.device))
+ cls.assertEqual(status, 0, msg = msg)
+
+ def storage_umount(cls, tmo=1):
+ time.sleep(tmo)
+ (status, output) = cls.target.run('umount %s' % cls.mount_point)
+
+ if status == 32:
+ # already unmounted, should it fail?
+ return
+ else:
+ msg = ('Device not unmount %s' % cls.mount_point)
+ cls.assertEqual(status, 0, msg = msg)
+
+ (status, output) = cls.target.run('cat /proc/mounts')
+ match = re.search('%s' % cls.device, output)
+ if match:
+ msg = ('Device %s still mounted.' % cls.device)
+ cls.assertTrue(match, msg = msg)
+
+
+class UsbTest(StorageBase):
+ '''
+ This is to mimic the usb test previously done in manual bsp-hw.json
+ '''
+ @classmethod
+ def setUpClass(self):
+ self.test_msg = "Hello World - USB"
+ self.mount_point = "/media/usb"
+ self.device = "/dev/sda1"
+ self.test_file = "usb.tst"
+ self.test_dir = os.path.join(self.mount_point, "oeqa")
+
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_usb_mount(self):
+ self.storage_umount(2)
+ self.storage_mount(5)
+
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['storage.UsbTest.test_usb_mount'])
+ def test_usb_basic_operations(self):
+ self.storage_basic()
+
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['storage.UsbTest.test_usb_basic_operations'])
+ def test_usb_basic_rw(self):
+ self.storage_write()
+ self.storage_read()
+
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['storage.UsbTest.test_usb_mount'])
+ def test_usb_umount(self):
+ self.storage_umount(2)
+
+
+class MMCTest(StorageBase):
+ '''
+ This is to mimic the usb test previously done in manual bsp-hw.json
+ '''
+ @classmethod
+ def setUpClass(self):
+ self.test_msg = "Hello World - MMC"
+ self.mount_point = "/media/mmc"
+ self.device = "/dev/mmcblk1p1"
+ self.test_file = "mmc.tst"
+ self.test_dir = os.path.join(self.mount_point, "oeqa")
+
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_mmc_mount(self):
+ self.storage_umount(2)
+ self.storage_mount()
+
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['storage.MMCTest.test_mmc_mount'])
+ def test_mmc_basic_operations(self):
+ self.storage_basic()
+
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['storage.MMCTest.test_mmc_basic_operations'])
+ def test_mmc_basic_rw(self):
+ self.storage_write()
+ self.storage_read()
+
+ @skipIfQemu('qemuall', 'Test only runs on real hardware')
+ @OETestDepends(['storage.MMCTest.test_mmc_mount'])
+ def test_mmc_umount(self):
+ self.storage_umount(2)
diff --git a/meta/lib/oeqa/runtime/cases/systemd.py b/meta/lib/oeqa/runtime/cases/systemd.py
new file mode 100644
index 0000000000..7c44abe8ed
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/systemd.py
@@ -0,0 +1,194 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import re
+import time
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfDataVar, skipIfNotDataVar
+from oeqa.runtime.decorator.package import OEHasPackage
+from oeqa.core.decorator.data import skipIfNotFeature, skipIfFeature
+
+class SystemdTest(OERuntimeTestCase):
+
+ def systemctl(self, action='', target='', expected=0, verbose=False):
+ command = 'SYSTEMD_BUS_TIMEOUT=240s systemctl %s %s' % (action, target)
+ status, output = self.target.run(command)
+ message = '\n'.join([command, output])
+ if status != expected and verbose:
+ cmd = 'SYSTEMD_BUS_TIMEOUT=240s systemctl status --full %s' % target
+ message += self.target.run(cmd)[1]
+ self.assertEqual(status, expected, message)
+ return output
+
+ #TODO: use pyjournalctl instead
+ def journalctl(self, args='',l_match_units=None):
+ """
+ Request for the journalctl output to the current target system
+
+ Arguments:
+ -args, an optional argument pass through argument
+ -l_match_units, an optional list of units to filter the output
+ Returns:
+ -string output of the journalctl command
+ Raises:
+ -AssertionError, on remote commands that fail
+ -ValueError, on a journalctl call with filtering by l_match_units that
+ returned no entries
+ """
+
+ query_units=''
+ if l_match_units:
+ query_units = ['_SYSTEMD_UNIT='+unit for unit in l_match_units]
+ query_units = ' '.join(query_units)
+ command = 'journalctl %s %s' %(args, query_units)
+ status, output = self.target.run(command)
+ if status:
+ raise AssertionError("Command '%s' returned non-zero exit "
+ 'code %d:\n%s' % (command, status, output))
+ if len(output) == 1 and "-- No entries --" in output:
+ raise ValueError('List of units to match: %s, returned no entries'
+ % l_match_units)
+ return output
+
+class SystemdBasicTests(SystemdTest):
+
+ def settle(self):
+ """
+ Block until systemd has finished activating any units being activated,
+ or until two minutes has elapsed.
+
+ Returns a tuple, either (True, '') if all units have finished
+ activating, or (False, message string) if there are still units
+ activating (generally, failing units that restart).
+ """
+ endtime = time.time() + (60 * 2)
+ while True:
+ status, output = self.target.run('SYSTEMD_BUS_TIMEOUT=240s systemctl --state=activating')
+ if "0 loaded units listed" in output:
+ return (True, '')
+ if time.time() >= endtime:
+ return (False, output)
+ time.sleep(10)
+
+ @skipIfNotFeature('systemd',
+ 'Test requires systemd to be in DISTRO_FEATURES')
+ @skipIfNotDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd',
+ 'systemd is not the init manager for this image')
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_systemd_basic(self):
+ self.systemctl('--version')
+
+ @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
+ def test_systemd_list(self):
+ self.systemctl('list-unit-files')
+
+ @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
+ def test_systemd_failed(self):
+ settled, output = self.settle()
+ msg = "Timed out waiting for systemd to settle:\n%s" % output
+ self.assertTrue(settled, msg=msg)
+
+ output = self.systemctl('list-units', '--failed')
+ match = re.search('0 loaded units listed', output)
+ if not match:
+ output += self.systemctl('status --full --failed')
+ self.assertTrue(match, msg='Some systemd units failed:\n%s' % output)
+
+
+class SystemdServiceTests(SystemdTest):
+
+ @OEHasPackage(['avahi-daemon'])
+ @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
+ def test_systemd_status(self):
+ self.systemctl('status --full', 'avahi-daemon.service')
+
+ @OETestDepends(['systemd.SystemdServiceTests.test_systemd_status'])
+ def test_systemd_stop_start(self):
+ self.systemctl('stop', 'avahi-daemon.service')
+ self.systemctl('is-active', 'avahi-daemon.service',
+ expected=3, verbose=True)
+ self.systemctl('start','avahi-daemon.service')
+ self.systemctl('is-active', 'avahi-daemon.service', verbose=True)
+
+ @OETestDepends(['systemd.SystemdServiceTests.test_systemd_status'])
+ @skipIfFeature('read-only-rootfs',
+ 'Test is only meant to run without read-only-rootfs in IMAGE_FEATURES')
+ def test_systemd_disable_enable(self):
+ self.systemctl('disable', 'avahi-daemon.service')
+ self.systemctl('is-enabled', 'avahi-daemon.service', expected=1)
+ self.systemctl('enable', 'avahi-daemon.service')
+ self.systemctl('is-enabled', 'avahi-daemon.service')
+
+ @OETestDepends(['systemd.SystemdServiceTests.test_systemd_status'])
+ @skipIfNotFeature('read-only-rootfs',
+ 'Test is only meant to run with read-only-rootfs in IMAGE_FEATURES')
+ def test_systemd_disable_enable_ro(self):
+ status = self.target.run('mount -orw,remount /')[0]
+ self.assertTrue(status == 0, msg='Remounting / as r/w failed')
+ try:
+ self.test_systemd_disable_enable()
+ finally:
+ status = self.target.run('mount -oro,remount /')[0]
+ self.assertTrue(status == 0, msg='Remounting / as r/o failed')
+
+class SystemdJournalTests(SystemdTest):
+
+ @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
+ def test_systemd_journal(self):
+ status, output = self.target.run('journalctl')
+ self.assertEqual(status, 0, output)
+
+ @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
+ def test_systemd_boot_time(self, systemd_TimeoutStartSec=90):
+ """
+ Get the target boot time from journalctl and log it
+
+ Arguments:
+ -systemd_TimeoutStartSec, an optional argument containing systemd's
+ unit start timeout to compare against
+ """
+
+ # The expression chain that uniquely identifies the time boot message.
+ expr_items=['Startup finished', 'kernel', 'userspace','\.$']
+ try:
+ output = self.journalctl(args='-o cat --reverse')
+ except AssertionError:
+ self.fail('Error occurred while calling journalctl')
+ if not len(output):
+ self.fail('Error, unable to get startup time from systemd journal')
+
+ # Check for the regular expression items that match the startup time.
+ for line in output.split('\n'):
+ check_match = ''.join(re.findall('.*'.join(expr_items), line))
+ if check_match:
+ break
+ # Put the startup time in the test log
+ if check_match:
+ self.tc.logger.info('%s' % check_match)
+ else:
+ self.skipTest('Error at obtaining the boot time from journalctl')
+ boot_time_sec = 0
+
+ # Get the numeric values from the string and convert them to seconds
+ # same data will be placed in list and string for manipulation.
+ l_boot_time = check_match.split(' ')[-2:]
+ s_boot_time = ' '.join(l_boot_time)
+ try:
+ # Obtain the minutes it took to boot.
+ if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit():
+ boot_time_min = s_boot_time.split('min')[0]
+ # Convert to seconds and accumulate it.
+ boot_time_sec += int(boot_time_min) * 60
+ # Obtain the seconds it took to boot and accumulate.
+ boot_time_sec += float(l_boot_time[1].split('s')[0])
+ except ValueError:
+ self.skipTest('Error when parsing time from boot string')
+
+ # Assert the target boot time against systemd's unit start timeout.
+ if boot_time_sec > systemd_TimeoutStartSec:
+ msg = ("Target boot time %s exceeds systemd's TimeoutStartSec %s"
+ % (boot_time_sec, systemd_TimeoutStartSec))
+ self.tc.logger.info(msg)
diff --git a/meta/lib/oeqa/runtime/cases/x32lib.py b/meta/lib/oeqa/runtime/cases/x32lib.py
new file mode 100644
index 0000000000..ddf220140e
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/x32lib.py
@@ -0,0 +1,21 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotInDataVar
+
+class X32libTest(OERuntimeTestCase):
+
+ @skipIfNotInDataVar('DEFAULTTUNE', 'x86-64-x32',
+ 'DEFAULTTUNE is not set to x86-64-x32')
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_x32_file(self):
+ cmd = 'readelf -h /bin/ls | grep Class | grep ELF32'
+ status1 = self.target.run(cmd)[0]
+ cmd = 'readelf -h /bin/ls | grep Machine | grep X86-64'
+ status2 = self.target.run(cmd)[0]
+ msg = ("/bin/ls isn't an X86-64 ELF32 binary. readelf says: %s" %
+ self.target.run("readelf -h /bin/ls")[1])
+ self.assertTrue(status1 == 0 and status2 == 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/xorg.py b/meta/lib/oeqa/runtime/cases/xorg.py
new file mode 100644
index 0000000000..d6845587c2
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/xorg.py
@@ -0,0 +1,21 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfNotFeature
+from oeqa.runtime.decorator.package import OEHasPackage
+
+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)
+ msg = ('Xorg does not appear to be running %s' %
+ self.target.run(self.tc.target_cmds['ps'])[1])
+ self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/connman.py b/meta/lib/oeqa/runtime/connman.py
deleted file mode 100644
index 003fefe2ce..0000000000
--- a/meta/lib/oeqa/runtime/connman.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasPackage("connman"):
- skipModule("No connman package in image")
-
-
-class ConnmanTest(oeRuntimeTest):
-
- def service_status(self, service):
- if oeRuntimeTest.hasFeature("systemd"):
- (status, output) = self.target.run('systemctl status -l %s' % service)
- return output
- else:
- return "Unable to get status or logs for %s" % service
-
- @testcase(961)
- @skipUnlessPassed('test_ssh')
- def test_connmand_help(self):
- (status, output) = self.target.run('/usr/sbin/connmand --help')
- self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
-
- @testcase(221)
- @skipUnlessPassed('test_connmand_help')
- def test_connmand_running(self):
- (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand')
- if status != 0:
- print(self.service_status("connman"))
- self.fail("No connmand process running")
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
new file mode 100644
index 0000000000..2ecb1a8f01
--- /dev/null
+++ b/meta/lib/oeqa/runtime/context.py
@@ -0,0 +1,226 @@
+#
+# Copyright (C) 2016 Intel Corporation
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.core.context import OETestContext, OETestContextExecutor
+from oeqa.core.target.ssh import OESSHTarget
+from oeqa.core.target.qemu import OEQemuTarget
+from oeqa.utils.dump import HostDumper
+
+from oeqa.runtime.loader import OERuntimeTestLoader
+
+class OERuntimeTestContext(OETestContext):
+ loaderClass = OERuntimeTestLoader
+ runtime_files_dir = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), "files")
+
+ def __init__(self, td, logger, target,
+ host_dumper, image_packages, extract_dir):
+ super(OERuntimeTestContext, self).__init__(td, logger)
+
+ self.target = target
+ self.image_packages = image_packages
+ self.host_dumper = host_dumper
+ self.extract_dir = extract_dir
+ self._set_target_cmds()
+
+ def _set_target_cmds(self):
+ self.target_cmds = {}
+
+ self.target_cmds['ps'] = 'ps'
+ if 'procps' in self.image_packages:
+ self.target_cmds['ps'] = self.target_cmds['ps'] + ' -ef'
+
+class OERuntimeTestContextExecutor(OETestContextExecutor):
+ _context_class = OERuntimeTestContext
+
+ name = 'runtime'
+ help = 'runtime test component'
+ description = 'executes runtime tests over targets'
+
+ default_cases = os.path.join(os.path.abspath(os.path.dirname(__file__)),
+ 'cases')
+ default_data = None
+ default_test_data = 'data/testdata.json'
+ default_tests = ''
+
+ default_target_type = 'simpleremote'
+ default_manifest = 'data/manifest'
+ default_server_ip = '192.168.7.1'
+ default_target_ip = '192.168.7.2'
+ default_extract_dir = 'packages/extracted'
+
+ def register_commands(self, logger, subparsers):
+ super(OERuntimeTestContextExecutor, self).register_commands(logger, subparsers)
+
+ runtime_group = self.parser.add_argument_group('runtime options')
+
+ runtime_group.add_argument('--target-type', action='store',
+ default=self.default_target_type, choices=['simpleremote', 'qemu'],
+ help="Target type of device under test, default: %s" \
+ % self.default_target_type)
+ runtime_group.add_argument('--target-ip', action='store',
+ default=self.default_target_ip,
+ help="IP address of device under test, default: %s" \
+ % self.default_target_ip)
+ runtime_group.add_argument('--server-ip', action='store',
+ default=self.default_target_ip,
+ help="IP address of device under test, default: %s" \
+ % self.default_server_ip)
+
+ runtime_group.add_argument('--host-dumper-dir', action='store',
+ help="Directory where host status is dumped, if tests fails")
+
+ runtime_group.add_argument('--packages-manifest', action='store',
+ default=self.default_manifest,
+ help="Package manifest of the image under testi, default: %s" \
+ % self.default_manifest)
+
+ runtime_group.add_argument('--extract-dir', action='store',
+ default=self.default_extract_dir,
+ help='Directory where extracted packages reside, default: %s' \
+ % self.default_extract_dir)
+
+ runtime_group.add_argument('--qemu-boot', action='store',
+ help="Qemu boot configuration, only needed when target_type is QEMU.")
+
+ @staticmethod
+ def getTarget(target_type, logger, target_ip, server_ip, **kwargs):
+ target = None
+
+ if target_ip:
+ target_ip_port = target_ip.split(':')
+ if len(target_ip_port) == 2:
+ target_ip = target_ip_port[0]
+ kwargs['port'] = target_ip_port[1]
+
+ if server_ip:
+ server_ip_port = server_ip.split(':')
+ if len(server_ip_port) == 2:
+ server_ip = server_ip_port[0]
+ kwargs['server_port'] = int(server_ip_port[1])
+
+ if target_type == 'simpleremote':
+ target = OESSHTarget(logger, target_ip, server_ip, **kwargs)
+ elif target_type == 'qemu':
+ 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
+ # most of the time was just a wrapper.
+ # XXX: This code tries to import modules from lib/oeqa/controllers
+ # directory and treat them as controllers, it will less error prone
+ # to use introspection to load such modules.
+ # XXX: Don't base your targets on this code it will be refactored
+ # in the near future.
+ # Custom target module loading
+ target_modules_path = kwargs.get('target_modules_path', '')
+ controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path)
+ target = controller(logger, target_ip, server_ip, **kwargs)
+
+ return target
+
+ # Search oeqa.controllers module directory for and return a controller
+ # corresponding to the given target name.
+ # AttributeError raised if not found.
+ # ImportError raised if a provided module can not be imported.
+ @staticmethod
+ def getControllerModule(target, target_modules_path):
+ controllerslist = OERuntimeTestContextExecutor._getControllerModulenames(target_modules_path)
+ controller = OERuntimeTestContextExecutor._loadControllerFromName(target, controllerslist)
+ return controller
+
+ # Return a list of all python modules in lib/oeqa/controllers for each
+ # layer in bbpath
+ @staticmethod
+ def _getControllerModulenames(target_modules_path):
+
+ controllerslist = []
+
+ def add_controller_list(path):
+ if not os.path.exists(os.path.join(path, '__init__.py')):
+ raise OSError('Controllers directory %s exists but is missing __init__.py' % path)
+ files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_') and not f.startswith('.#')])
+ for f in files:
+ module = 'oeqa.controllers.' + f[:-3]
+ if module not in controllerslist:
+ controllerslist.append(module)
+ else:
+ raise RuntimeError("Duplicate controller module found for %s. Layers should create unique controller module names" % module)
+
+ extpath = target_modules_path.split(':')
+ for p in extpath:
+ controllerpath = os.path.join(p, 'lib', 'oeqa', 'controllers')
+ if os.path.exists(controllerpath):
+ add_controller_list(controllerpath)
+ return controllerslist
+
+ # Search for and return a controller from given target name and
+ # set of module names.
+ # Raise AttributeError if not found.
+ # Raise ImportError if a provided module can not be imported
+ @staticmethod
+ def _loadControllerFromName(target, modulenames):
+ for name in modulenames:
+ obj = OERuntimeTestContextExecutor._loadControllerFromModule(target, name)
+ if obj:
+ return obj
+ raise AttributeError("Unable to load {0} from available modules: {1}".format(target, str(modulenames)))
+
+ # Search for and return a controller or None from given module name
+ @staticmethod
+ def _loadControllerFromModule(target, modulename):
+ obj = None
+ # import module, allowing it to raise import exception
+ module = __import__(modulename, globals(), locals(), [target])
+ # look for target class in the module, catching any exceptions as it
+ # is valid that a module may not have the target class.
+ try:
+ obj = getattr(module, target)
+ except:
+ obj = None
+ return obj
+
+ @staticmethod
+ def readPackagesManifest(manifest):
+ if not manifest or not os.path.exists(manifest):
+ raise OSError("Manifest file not exists: %s" % manifest)
+
+ image_packages = set()
+ with open(manifest, 'r') as f:
+ for line in f.readlines():
+ line = line.strip()
+ if line and not line.startswith("#"):
+ image_packages.add(line.split()[0])
+
+ return image_packages
+
+ @staticmethod
+ def getHostDumper(cmds, directory):
+ return HostDumper(cmds, directory)
+
+ def _process_args(self, logger, args):
+ if not args.packages_manifest:
+ raise TypeError('Manifest file not provided')
+
+ super(OERuntimeTestContextExecutor, self)._process_args(logger, args)
+
+ target_kwargs = {}
+ target_kwargs['qemuboot'] = args.qemu_boot
+
+ self.tc_kwargs['init']['target'] = \
+ OERuntimeTestContextExecutor.getTarget(args.target_type,
+ None, args.target_ip, args.server_ip, **target_kwargs)
+ self.tc_kwargs['init']['host_dumper'] = \
+ OERuntimeTestContextExecutor.getHostDumper(None,
+ args.host_dumper_dir)
+ self.tc_kwargs['init']['image_packages'] = \
+ OERuntimeTestContextExecutor.readPackagesManifest(
+ args.packages_manifest)
+ self.tc_kwargs['init']['extract_dir'] = args.extract_dir
+
+_executor_class = OERuntimeTestContextExecutor
diff --git a/meta/lib/oeqa/runtime/date.py b/meta/lib/oeqa/runtime/date.py
deleted file mode 100644
index 447987e075..0000000000
--- a/meta/lib/oeqa/runtime/date.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from oeqa.oetest import oeRuntimeTest
-from oeqa.utils.decorators import *
-import re
-
-class DateTest(oeRuntimeTest):
-
- def setUpLocal(self):
- if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", True) == "systemd":
- self.target.run('systemctl stop systemd-timesyncd')
-
- def tearDownLocal(self):
- if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", True) == "systemd":
- self.target.run('systemctl start systemd-timesyncd')
-
- @testcase(211)
- @skipUnlessPassed("test_ssh")
- def test_date(self):
- (status, output) = self.target.run('date +"%Y-%m-%d %T"')
- self.assertEqual(status, 0, msg="Failed to get initial date, output: %s" % output)
- oldDate = output
-
- sampleDate = '"2016-08-09 10:00:00"'
- (status, output) = self.target.run("date -s %s" % sampleDate)
- self.assertEqual(status, 0, msg="Date set failed, output: %s" % output)
-
- (status, output) = self.target.run("date -R")
- p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output)
- self.assertTrue(p, msg="The date was not set correctly, output: %s" % output)
-
- (status, output) = self.target.run('date -s "%s"' % oldDate)
- self.assertEqual(status, 0, msg="Failed to reset date, output: %s" % output)
diff --git a/meta/lib/oeqa/runtime/decorator/package.py b/meta/lib/oeqa/runtime/decorator/package.py
new file mode 100644
index 0000000000..4c5ca198b0
--- /dev/null
+++ b/meta/lib/oeqa/runtime/decorator/package.py
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2016 Intel Corporation
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.core.decorator import OETestDecorator, registerDecorator
+from oeqa.core.utils.misc import strToSet
+
+@registerDecorator
+class OEHasPackage(OETestDecorator):
+ """
+ Checks if image has packages (un)installed.
+
+ The argument must be a string, set, or list of packages that must be
+ installed or not present in the image.
+
+ The way to tell a package must not be in an image is using an
+ exclamation point ('!') before the name of the package.
+
+ If test depends on pkg1 or pkg2 you need to use:
+ @OEHasPackage({'pkg1', 'pkg2'})
+
+ If test depends on pkg1 and pkg2 you need to use:
+ @OEHasPackage('pkg1')
+ @OEHasPackage('pkg2')
+
+ If test depends on pkg1 but pkg2 must not be present use:
+ @OEHasPackage({'pkg1', '!pkg2'})
+ """
+
+ attrs = ('need_pkgs',)
+
+ def setUpDecorator(self):
+ need_pkgs = set()
+ unneed_pkgs = set()
+ pkgs = strToSet(self.need_pkgs)
+ for pkg in pkgs:
+ if pkg.startswith('!'):
+ unneed_pkgs.add(pkg[1:])
+ else:
+ need_pkgs.add(pkg)
+
+ if unneed_pkgs:
+ msg = 'Checking if %s is not installed' % ', '.join(unneed_pkgs)
+ self.logger.debug(msg)
+ if not self.case.tc.image_packages.isdisjoint(unneed_pkgs):
+ msg = "Test can't run with %s installed" % ', or'.join(unneed_pkgs)
+ self.case.skipTest(msg)
+
+ if need_pkgs:
+ msg = 'Checking if at least one of %s is installed' % ', '.join(need_pkgs)
+ self.logger.debug(msg)
+ if self.case.tc.image_packages.isdisjoint(need_pkgs):
+ msg = "Test requires %s to be installed" % ', or'.join(need_pkgs)
+ self.case.skipTest(msg)
diff --git a/meta/lib/oeqa/runtime/df.py b/meta/lib/oeqa/runtime/df.py
deleted file mode 100644
index 09569d5ff6..0000000000
--- a/meta/lib/oeqa/runtime/df.py
+++ /dev/null
@@ -1,12 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest
-from oeqa.utils.decorators import *
-
-
-class DfTest(oeRuntimeTest):
-
- @testcase(234)
- @skipUnlessPassed("test_ssh")
- def test_df(self):
- (status,output) = self.target.run("df / | sed -n '2p' | awk '{print $4}'")
- self.assertTrue(int(output)>5120, msg="Not enough space on image. Current size is %s" % output)
diff --git a/meta/lib/oeqa/runtime/files/SConstruct b/meta/lib/oeqa/runtime/files/SConstruct
new file mode 100644
index 0000000000..d2cb6dd122
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/SConstruct
@@ -0,0 +1 @@
+Program('hello.c')
diff --git a/meta/lib/oeqa/runtime/files/hello.c b/meta/lib/oeqa/runtime/files/hello.c
new file mode 100644
index 0000000000..b0697a3304
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/hello.c
@@ -0,0 +1,5 @@
+int
+ main()
+ {
+ printf("Hello, world!\n");
+ }
diff --git a/meta/lib/oeqa/runtime/files/hello.stp b/meta/lib/oeqa/runtime/files/hello.stp
new file mode 100644
index 0000000000..3677147162
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/hello.stp
@@ -0,0 +1 @@
+probe oneshot { println("hello world") }
diff --git a/meta/lib/oeqa/runtime/files/test.c b/meta/lib/oeqa/runtime/files/test.c
deleted file mode 100644
index 2d8389c92e..0000000000
--- a/meta/lib/oeqa/runtime/files/test.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <stdio.h>
-#include <math.h>
-#include <stdlib.h>
-
-double convert(long long l)
-{
- return (double)l;
-}
-
-int main(int argc, char * argv[]) {
-
- long long l = 10;
- double f;
- double check = 10.0;
-
- f = convert(l);
- printf("convert: %lld => %f\n", l, f);
- if ( f != check ) exit(1);
-
- f = 1234.67;
- check = 1234.0;
- printf("floorf(%f) = %f\n", f, floorf(f));
- if ( floorf(f) != check) exit(1);
-
- return 0;
-}
diff --git a/meta/lib/oeqa/runtime/files/test.cpp b/meta/lib/oeqa/runtime/files/test.cpp
deleted file mode 100644
index 9e1a76473d..0000000000
--- a/meta/lib/oeqa/runtime/files/test.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <limits>
-
-int main() {} \ No newline at end of file
diff --git a/meta/lib/oeqa/runtime/files/test.pl b/meta/lib/oeqa/runtime/files/test.pl
deleted file mode 100644
index 689c8f1635..0000000000
--- a/meta/lib/oeqa/runtime/files/test.pl
+++ /dev/null
@@ -1,2 +0,0 @@
-$a = 9.01e+21 - 9.01e+21 + 0.01;
-print ("the value of a is ", $a, "\n");
diff --git a/meta/lib/oeqa/runtime/files/test.py b/meta/lib/oeqa/runtime/files/test.py
deleted file mode 100644
index f389225d72..0000000000
--- a/meta/lib/oeqa/runtime/files/test.py
+++ /dev/null
@@ -1,6 +0,0 @@
-import os
-
-os.system('touch /tmp/testfile.python')
-
-a = 9.01e+21 - 9.01e+21 + 0.01
-print("the value of a is %s" % a)
diff --git a/meta/lib/oeqa/runtime/files/testsdkmakefile b/meta/lib/oeqa/runtime/files/testsdkmakefile
deleted file mode 100644
index fb05f822f3..0000000000
--- a/meta/lib/oeqa/runtime/files/testsdkmakefile
+++ /dev/null
@@ -1,5 +0,0 @@
-test: test.o
- $(CC) -o test test.o -lm
-test.o: test.c
- $(CC) -c test.c
-
diff --git a/meta/lib/oeqa/runtime/gcc.py b/meta/lib/oeqa/runtime/gcc.py
deleted file mode 100644
index d90cd1799a..0000000000
--- a/meta/lib/oeqa/runtime/gcc.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import unittest
-import os
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("tools-sdk"):
- skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
-
-
-class GccCompileTest(oeRuntimeTest):
-
- @classmethod
- def setUpClass(self):
- oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.c"), "/tmp/test.c")
- oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "testmakefile"), "/tmp/testmakefile")
- oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.cpp"), "/tmp/test.cpp")
-
- @testcase(203)
- def test_gcc_compile(self):
- (status, output) = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
- self.assertEqual(status, 0, msg="gcc compile failed, output: %s" % output)
- (status, output) = self.target.run('/tmp/test')
- self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
-
- @testcase(200)
- def test_gpp_compile(self):
- (status, output) = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
- self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output)
- (status, output) = self.target.run('/tmp/test')
- self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
-
- @testcase(1142)
- def test_gpp2_compile(self):
- (status, output) = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm')
- self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output)
- (status, output) = self.target.run('/tmp/test')
- self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
-
- @testcase(204)
- def test_make(self):
- (status, output) = self.target.run('cd /tmp; make -f testmakefile')
- self.assertEqual(status, 0, msg="running make failed, output %s" % output)
-
- @classmethod
- def tearDownClass(self):
- oeRuntimeTest.tc.target.run("rm /tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile")
diff --git a/meta/lib/oeqa/runtime/kernelmodule.py b/meta/lib/oeqa/runtime/kernelmodule.py
deleted file mode 100644
index 38ca184540..0000000000
--- a/meta/lib/oeqa/runtime/kernelmodule.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import unittest
-import os
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("tools-sdk"):
- skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
-
-
-class KernelModuleTest(oeRuntimeTest):
-
- def setUpLocal(self):
- self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod.c"), "/tmp/hellomod.c")
- self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod_makefile"), "/tmp/Makefile")
-
- @testcase('316')
- @skipUnlessPassed('test_ssh')
- @skipUnlessPassed('test_gcc_compile')
- def test_kernel_module(self):
- cmds = [
- 'cd /usr/src/kernel && make scripts',
- 'cd /tmp && make',
- 'cd /tmp && insmod hellomod.ko',
- 'lsmod | grep hellomod',
- 'dmesg | grep Hello',
- 'rmmod hellomod', 'dmesg | grep "Cleaning up hellomod"'
- ]
- for cmd in cmds:
- (status, output) = self.target.run(cmd, 900)
- self.assertEqual(status, 0, msg="\n".join([cmd, output]))
-
- def tearDownLocal(self):
- self.target.run('rm -f /tmp/Makefile /tmp/hellomod.c')
diff --git a/meta/lib/oeqa/runtime/ldd.py b/meta/lib/oeqa/runtime/ldd.py
deleted file mode 100644
index 47b3885df2..0000000000
--- a/meta/lib/oeqa/runtime/ldd.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("tools-sdk"):
- skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
-
-class LddTest(oeRuntimeTest):
-
- @testcase(962)
- @skipUnlessPassed('test_ssh')
- def test_ldd_exists(self):
- (status, output) = self.target.run('which ldd')
- self.assertEqual(status, 0, msg = "ldd does not exist in PATH: which ldd: %s" % output)
-
- @testcase(239)
- @skipUnlessPassed('test_ldd_exists')
- def test_ldd_rtldlist_check(self):
- (status, output) = self.target.run('for i in $(which ldd | xargs cat | grep "^RTLDLIST"|cut -d\'=\' -f2|tr -d \'"\'); do test -f $i && echo $i && break; done')
- self.assertEqual(status, 0, msg = "ldd path not correct or RTLDLIST files don't exist. ")
diff --git a/meta/lib/oeqa/runtime/loader.py b/meta/lib/oeqa/runtime/loader.py
new file mode 100644
index 0000000000..7041ddfde8
--- /dev/null
+++ b/meta/lib/oeqa/runtime/loader.py
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 2016 Intel Corporation
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.core.loader import OETestLoader
+from oeqa.runtime.case import OERuntimeTestCase
+
+class OERuntimeTestLoader(OETestLoader):
+ caseClass = OERuntimeTestCase
+
+ def _getTestCase(self, testCaseClass, tcName):
+ case = super(OERuntimeTestLoader, self)._getTestCase(testCaseClass, tcName)
+
+ # Adds custom attributes to the OERuntimeTestCase
+ setattr(case, 'target', self.tc.target)
+
+ return case
diff --git a/meta/lib/oeqa/runtime/logrotate.py b/meta/lib/oeqa/runtime/logrotate.py
deleted file mode 100644
index de300bf55f..0000000000
--- a/meta/lib/oeqa/runtime/logrotate.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=289 testcase
-# Note that the image under test must have logrotate installed
-
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasPackage("logrotate"):
- skipModule("No logrotate package in image")
-
-
-class LogrotateTest(oeRuntimeTest):
-
- @skipUnlessPassed("test_ssh")
- def test_1_logrotate_setup(self):
- (status, output) = self.target.run('mkdir $HOME/logrotate_dir')
- self.assertEqual(status, 0, msg = "Could not create logrotate_dir. Output: %s" % output)
- (status, output) = self.target.run("sed -i \"s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#\" /etc/logrotate.conf")
- self.assertEqual(status, 0, msg = "Could not write to logrotate.conf file. Status and output: %s and %s)" % (status, output))
-
- @testcase(289)
- @skipUnlessPassed("test_1_logrotate_setup")
- def test_2_logrotate(self):
- (status, output) = self.target.run('logrotate -f /etc/logrotate.conf')
- self.assertEqual(status, 0, msg = "logrotate service could not be reloaded. Status and output: %s and %s" % (status, output))
- output = self.target.run('ls -la $HOME/logrotate_dir/ | wc -l')[1]
- self.assertTrue(int(output)>=3, msg = "new logfile could not be created. List of files within log directory: %s" %(self.target.run('ls -la $HOME/logrotate_dir')[1]))
diff --git a/meta/lib/oeqa/runtime/multilib.py b/meta/lib/oeqa/runtime/multilib.py
deleted file mode 100644
index 593d385021..0000000000
--- a/meta/lib/oeqa/runtime/multilib.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- multilibs = oeRuntimeTest.tc.d.getVar("MULTILIBS", True) or ""
- if "multilib:lib32" not in multilibs:
- skipModule("this isn't a multilib:lib32 image")
-
-
-class MultilibTest(oeRuntimeTest):
-
- def archtest(self, binary, arch):
- """
- Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64).
- """
-
- (status, output) = self.target.run("readelf -h %s" % binary)
- self.assertEqual(status, 0, "Failed to readelf %s" % binary)
-
- l = [l.split()[1] for l in output.split('\n') if "Class:" in l]
- if l:
- theclass = l[0]
- else:
- self.fail("Cannot parse readelf output\n" + s)
-
- self.assertEqual(theclass, arch, msg="%s isn't %s (is %s)" % (binary, arch, theclass))
-
- @skipUnlessPassed('test_ssh')
- def test_check_multilib_libc(self):
- """
- Check that a multilib image has both 32-bit and 64-bit libc in.
- """
- self.archtest("/lib/libc.so.6", "ELF32")
- self.archtest("/lib64/libc.so.6", "ELF64")
-
- @testcase('279')
- @skipUnlessPassed('test_check_multilib_libc')
- def test_file_connman(self):
- self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman'), msg="This test assumes lib32-connman is installed")
-
- self.archtest("/usr/sbin/connmand", "ELF32")
diff --git a/meta/lib/oeqa/runtime/pam.py b/meta/lib/oeqa/runtime/pam.py
deleted file mode 100644
index c8205c9abc..0000000000
--- a/meta/lib/oeqa/runtime/pam.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=287 testcase
-# Note that the image under test must have "pam" in DISTRO_FEATURES
-
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("pam"):
- skipModule("target doesn't have 'pam' in DISTRO_FEATURES")
-
-
-class PamBasicTest(oeRuntimeTest):
-
- @testcase(287)
- @skipUnlessPassed('test_ssh')
- def test_pam(self):
- (status, output) = self.target.run('login --help')
- self.assertEqual(status, 1, msg = "login command does not work as expected. Status and output:%s and %s" %(status, output))
- (status, output) = self.target.run('passwd --help')
- self.assertEqual(status, 0, msg = "passwd command does not work as expected. Status and output:%s and %s" %(status, output))
- (status, output) = self.target.run('su --help')
- self.assertEqual(status, 0, msg = "su command does not work as expected. Status and output:%s and %s" %(status, output))
- (status, output) = self.target.run('useradd --help')
- self.assertEqual(status, 0, msg = "useradd command does not work as expected. Status and output:%s and %s" %(status, output))
diff --git a/meta/lib/oeqa/runtime/perl.py b/meta/lib/oeqa/runtime/perl.py
deleted file mode 100644
index e044d0a5fe..0000000000
--- a/meta/lib/oeqa/runtime/perl.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import unittest
-import os
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasPackage("perl"):
- skipModule("No perl package in the image")
-
-
-class PerlTest(oeRuntimeTest):
-
- @classmethod
- def setUpClass(self):
- oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.pl"), "/tmp/test.pl")
-
- @testcase(1141)
- def test_perl_exists(self):
- (status, output) = self.target.run('which perl')
- self.assertEqual(status, 0, msg="Perl binary not in PATH or not on target.")
-
- @testcase(208)
- def test_perl_works(self):
- (status, output) = self.target.run('perl /tmp/test.pl')
- self.assertEqual(status, 0, msg="Exit status was not 0. Output: %s" % output)
- self.assertEqual(output, "the value of a is 0.01", msg="Incorrect output: %s" % output)
-
- @classmethod
- def tearDownClass(self):
- oeRuntimeTest.tc.target.run("rm /tmp/test.pl")
diff --git a/meta/lib/oeqa/runtime/ping.py b/meta/lib/oeqa/runtime/ping.py
deleted file mode 100644
index 0f27447926..0000000000
--- a/meta/lib/oeqa/runtime/ping.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import subprocess
-import unittest
-import sys
-import time
-from oeqa.oetest import oeRuntimeTest
-from oeqa.utils.decorators import *
-
-class PingTest(oeRuntimeTest):
-
- @testcase(964)
- def test_ping(self):
- output = ''
- count = 0
- endtime = time.time() + 60
- while count < 5 and time.time() < endtime:
- proc = subprocess.Popen("ping -c 1 %s" % self.target.ip, shell=True, stdout=subprocess.PIPE)
- output += proc.communicate()[0].decode("utf-8")
- if proc.poll() == 0:
- count += 1
- else:
- count = 0
- self.assertEqual(count, 5, msg = "Expected 5 consecutive replies, got %d.\nping output is:\n%s" % (count,output))
diff --git a/meta/lib/oeqa/runtime/python.py b/meta/lib/oeqa/runtime/python.py
deleted file mode 100644
index 29a231c7c3..0000000000
--- a/meta/lib/oeqa/runtime/python.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import unittest
-import os
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasPackage("python-core"):
- skipModule("No python package in the image")
-
-
-class PythonTest(oeRuntimeTest):
-
- @classmethod
- def setUpClass(self):
- oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.py"), "/tmp/test.py")
-
- @testcase(1145)
- def test_python_exists(self):
- (status, output) = self.target.run('which python')
- self.assertEqual(status, 0, msg="Python binary not in PATH or not on target.")
-
- @testcase(965)
- def test_python_stdout(self):
- (status, output) = self.target.run('python /tmp/test.py')
- self.assertEqual(status, 0, msg="Exit status was not 0. Output: %s" % output)
- self.assertEqual(output, "the value of a is 0.01", msg="Incorrect output: %s" % output)
-
- @testcase(1146)
- def test_python_testfile(self):
- (status, output) = self.target.run('ls /tmp/testfile.python')
- self.assertEqual(status, 0, msg="Python test file generate failed.")
-
- @classmethod
- def tearDownClass(self):
- oeRuntimeTest.tc.target.run("rm /tmp/test.py /tmp/testfile.python")
diff --git a/meta/lib/oeqa/runtime/rpm.py b/meta/lib/oeqa/runtime/rpm.py
deleted file mode 100644
index 7f514ca00c..0000000000
--- a/meta/lib/oeqa/runtime/rpm.py
+++ /dev/null
@@ -1,120 +0,0 @@
-import unittest
-import os
-import fnmatch
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("package-management"):
- skipModule("rpm module skipped: target doesn't have package-management in IMAGE_FEATURES")
- if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
- skipModule("rpm module skipped: target doesn't have rpm as primary package manager")
-
-
-class RpmBasicTest(oeRuntimeTest):
-
- @testcase(960)
- @skipUnlessPassed('test_ssh')
- def test_rpm_help(self):
- (status, output) = self.target.run('rpm --help')
- self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
-
- @testcase(191)
- @skipUnlessPassed('test_rpm_help')
- def test_rpm_query(self):
- (status, output) = self.target.run('rpm -q rpm')
- self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
-
-class RpmInstallRemoveTest(oeRuntimeTest):
-
- @classmethod
- def setUpClass(self):
- pkgarch = oeRuntimeTest.tc.d.getVar('TUNE_PKGARCH', True).replace("-", "_")
- rpmdir = os.path.join(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True), "rpm", pkgarch)
- # pick rpm-doc as a test file to get installed, because it's small and it will always be built for standard targets
- for f in fnmatch.filter(os.listdir(rpmdir), "rpm-doc-*.%s.rpm" % pkgarch):
- testrpmfile = f
- oeRuntimeTest.tc.target.copy_to(os.path.join(rpmdir,testrpmfile), "/tmp/rpm-doc.rpm")
-
- @testcase(192)
- @skipUnlessPassed('test_rpm_help')
- def test_rpm_install(self):
- (status, output) = self.target.run('rpm -ivh /tmp/rpm-doc.rpm')
- self.assertEqual(status, 0, msg="Failed to install rpm-doc package: %s" % output)
-
- @testcase(194)
- @skipUnlessPassed('test_rpm_install')
- def test_rpm_remove(self):
- (status,output) = self.target.run('rpm -e rpm-doc')
- self.assertEqual(status, 0, msg="Failed to remove rpm-doc package: %s" % output)
-
- @testcase(1096)
- @skipUnlessPassed('test_ssh')
- def test_rpm_query_nonroot(self):
-
- def set_up_test_user(u):
- (status, output) = self.target.run("id -u %s" % u)
- if status == 0:
- pass
- else:
- (status, output) = self.target.run("useradd %s" % u)
- self.assertTrue(status == 0, msg="Failed to create new user: " + output)
-
- def exec_as_test_user(u):
- (status, output) = self.target.run("su -c id %s" % u)
- self.assertTrue("({0})".format(u) in output, msg="Failed to execute as new user")
- (status, output) = self.target.run("su -c \"rpm -qa\" %s " % u)
- self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa: %s" % (status, output))
-
- def unset_up_test_user(u):
- (status, output) = self.target.run("userdel -r %s" % u)
- self.assertTrue(status == 0, msg="Failed to erase user: %s" % output)
-
- tuser = 'test1'
-
- try:
- set_up_test_user(tuser)
- exec_as_test_user(tuser)
- finally:
- unset_up_test_user(tuser)
-
- @testcase(195)
- @skipUnlessPassed('test_rpm_install')
- def test_check_rpm_install_removal_log_file_size(self):
- """
- Summary: Check rpm install/removal log file size
- Expected: There should be some method to keep rpm log in a small size .
- Product: BSPs
- Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com>
- AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
- """
- db_files_cmd = 'ls /var/lib/rpm/__db.*'
- get_log_size_cmd = "du /var/lib/rpm/log/log.* | awk '{print $1}'"
-
- # Make sure that some database files are under /var/lib/rpm as '__db.xxx'
- (status, output) = self.target.run(db_files_cmd)
- self.assertEqual(0, status, 'Failed to find database files under /var/lib/rpm/ as __db.xxx')
-
- # Remove the package just in case
- self.target.run('rpm -e rpm-doc')
-
- # Install/Remove a package 10 times
- for i in range(10):
- (status, output) = self.target.run('rpm -ivh /tmp/rpm-doc.rpm')
- self.assertEqual(0, status, "Failed to install rpm-doc package. Reason: {}".format(output))
-
- (status, output) = self.target.run('rpm -e rpm-doc')
- self.assertEqual(0, status, "Failed to remove rpm-doc package. Reason: {}".format(output))
-
- # Get the size of log file
- (status, output) = self.target.run(get_log_size_cmd)
- self.assertEqual(0, status, 'Failed to get the final size of the log file.')
-
- # Compare each log size
- for log_file_size in output:
- self.assertLessEqual(int(log_file_size), 11264,
- 'Log file size is greater that expected (~10MB), found {} bytes'.format(log_file_size))
-
- @classmethod
- def tearDownClass(self):
- oeRuntimeTest.tc.target.run('rm -f /tmp/rpm-doc.rpm')
diff --git a/meta/lib/oeqa/runtime/scanelf.py b/meta/lib/oeqa/runtime/scanelf.py
deleted file mode 100644
index 67e02ff455..0000000000
--- a/meta/lib/oeqa/runtime/scanelf.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasPackage("pax-utils"):
- skipModule("pax-utils package not installed")
-
-class ScanelfTest(oeRuntimeTest):
-
- def setUpLocal(self):
- self.scancmd = 'scanelf --quiet --recursive --mount --ldpath --path'
-
- @testcase(966)
- @skipUnlessPassed('test_ssh')
- def test_scanelf_textrel(self):
- # print TEXTREL information
- self.scancmd += " --textrel"
- (status, output) = self.target.run(self.scancmd)
- self.assertEqual(output.strip(), "", "\n".join([self.scancmd, output]))
-
- @testcase(967)
- @skipUnlessPassed('test_ssh')
- def test_scanelf_rpath(self):
- # print RPATH information
- self.scancmd += " --rpath"
- (status, output) = self.target.run(self.scancmd)
- self.assertEqual(output.strip(), "", "\n".join([self.scancmd, output]))
diff --git a/meta/lib/oeqa/runtime/scp.py b/meta/lib/oeqa/runtime/scp.py
deleted file mode 100644
index 48e87d2d0b..0000000000
--- a/meta/lib/oeqa/runtime/scp.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import os
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import skipUnlessPassed, testcase
-
-def setUpModule():
- if not (oeRuntimeTest.hasPackage("dropbear") or oeRuntimeTest.hasPackage("openssh-sshd")):
- skipModule("No ssh package in image")
-
-class ScpTest(oeRuntimeTest):
-
- @testcase(220)
- @skipUnlessPassed('test_ssh')
- def test_scp_file(self):
- test_log_dir = oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR", True)
- test_file_path = os.path.join(test_log_dir, 'test_scp_file')
- with open(test_file_path, 'w') as test_scp_file:
- test_scp_file.seek(2 ** 22 - 1)
- test_scp_file.write(os.linesep)
- (status, output) = self.target.copy_to(test_file_path, '/tmp/test_scp_file')
- self.assertEqual(status, 0, msg = "File could not be copied. Output: %s" % output)
- (status, output) = self.target.run("ls -la /tmp/test_scp_file")
- self.assertEqual(status, 0, msg = "SCP test failed")
diff --git a/meta/lib/oeqa/runtime/skeletoninit.py b/meta/lib/oeqa/runtime/skeletoninit.py
deleted file mode 100644
index cb0cb9b4cf..0000000000
--- a/meta/lib/oeqa/runtime/skeletoninit.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=284 testcase
-# Note that the image under test must have meta-skeleton layer in bblayers and IMAGE_INSTALL_append = " service" in local.conf
-
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasPackage("service"):
- skipModule("No service package in image")
-
-
-class SkeletonBasicTest(oeRuntimeTest):
-
- @skipUnlessPassed('test_ssh')
- @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False), "Not appropiate for systemd image")
- def test_skeleton_availability(self):
- (status, output) = self.target.run('ls /etc/init.d/skeleton')
- self.assertEqual(status, 0, msg = "skeleton init script not found. Output:\n%s " % output)
- (status, output) = self.target.run('ls /usr/sbin/skeleton-test')
- self.assertEqual(status, 0, msg = "skeleton-test not found. Output:\n%s" % output)
-
- @testcase(284)
- @skipUnlessPassed('test_skeleton_availability')
- @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False), "Not appropiate for systemd image")
- def test_skeleton_script(self):
- output1 = self.target.run("/etc/init.d/skeleton start")[1]
- (status, output2) = self.target.run(oeRuntimeTest.pscmd + ' | grep [s]keleton-test')
- self.assertEqual(status, 0, msg = "Skeleton script could not be started:\n%s\n%s" % (output1, output2))
diff --git a/meta/lib/oeqa/runtime/smart.py b/meta/lib/oeqa/runtime/smart.py
deleted file mode 100644
index 6cdb10d631..0000000000
--- a/meta/lib/oeqa/runtime/smart.py
+++ /dev/null
@@ -1,218 +0,0 @@
-import unittest
-import re
-import oe
-import subprocess
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-from oeqa.utils.httpserver import HTTPService
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("package-management"):
- skipModule("Image doesn't have package management feature")
- if not oeRuntimeTest.hasPackage("smartpm"):
- skipModule("Image doesn't have smart installed")
- if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
- skipModule("Rpm is not the primary package manager")
-
-class SmartTest(oeRuntimeTest):
-
- @skipUnlessPassed('test_smart_help')
- def smart(self, command, expected = 0):
- command = 'smart %s' % command
- status, output = self.target.run(command, 1500)
- message = os.linesep.join([command, output])
- self.assertEqual(status, expected, message)
- self.assertFalse("Cannot allocate memory" in output, message)
- return output
-
-class SmartBasicTest(SmartTest):
-
- @testcase(716)
- @skipUnlessPassed('test_ssh')
- def test_smart_help(self):
- self.smart('--help')
-
- @testcase(968)
- def test_smart_version(self):
- self.smart('--version')
-
- @testcase(721)
- def test_smart_info(self):
- self.smart('info python-smartpm')
-
- @testcase(421)
- def test_smart_query(self):
- self.smart('query python-smartpm')
-
- @testcase(720)
- def test_smart_search(self):
- self.smart('search python-smartpm')
-
- @testcase(722)
- def test_smart_stats(self):
- self.smart('stats')
-
-class SmartRepoTest(SmartTest):
-
- @classmethod
- def create_index(self, arg):
- index_cmd = arg
- try:
- bb.note("Executing '%s' ..." % index_cmd)
- result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
- except subprocess.CalledProcessError as e:
- return("Index creation command '%s' failed with return code %d:\n%s" %
- (e.cmd, e.returncode, e.output.decode("utf-8")))
- if result:
- bb.note(result)
- return None
-
- @classmethod
- def setUpClass(self):
- self.repolist = []
-
- # Index RPMs
- rpm_createrepo = bb.utils.which(os.getenv('PATH'), "createrepo")
- index_cmds = []
- rpm_dirs_found = False
- archs = (oeRuntimeTest.tc.d.getVar('ALL_MULTILIB_PACKAGE_ARCHS', True) or "").replace('-', '_').split()
- for arch in archs:
- rpm_dir = os.path.join(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM', True), arch)
- idx_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR', True), 'rpm', arch)
- db_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR', True), 'rpmdb', arch)
- if not os.path.isdir(rpm_dir):
- continue
- if os.path.exists(db_path):
- bb.utils.remove(dbpath, True)
- lockfilename = oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM', True) + "/rpm.lock"
- lf = bb.utils.lockfile(lockfilename, False)
- oe.path.copyhardlinktree(rpm_dir, idx_path)
- # Full indexes overload a 256MB image so reduce the number of rpms
- # in the feed. Filter to p* since we use the psplash packages and
- # this leaves some allarch and machine arch packages too.
- bb.utils.remove(idx_path + "*/[a-oq-z]*.rpm")
- bb.utils.unlockfile(lf)
- index_cmds.append("%s --dbpath %s --update -q %s" % (rpm_createrepo, db_path, idx_path))
- rpm_dirs_found = True
- # Create repodata¬
- result = oe.utils.multiprocess_exec(index_cmds, self.create_index)
- if result:
- bb.fatal('%s' % ('\n'.join(result)))
- self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('WORKDIR', True), oeRuntimeTest.tc.target.server_ip)
- self.repo_server.start()
-
- @classmethod
- def tearDownClass(self):
- self.repo_server.stop()
- for i in self.repolist:
- oeRuntimeTest.tc.target.run('smart channel -y --remove '+str(i))
-
- @testcase(1143)
- def test_smart_channel(self):
- self.smart('channel', 1)
-
- @testcase(719)
- def test_smart_channel_add(self):
- image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
- deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
- pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True).replace("-","_").split()
- for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
- if arch in pkgarchs:
- self.smart('channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url))
- self.repolist.append(arch)
- self.smart('update')
-
- @testcase(969)
- def test_smart_channel_help(self):
- self.smart('channel --help')
-
- @testcase(970)
- def test_smart_channel_list(self):
- self.smart('channel --list')
-
- @testcase(971)
- def test_smart_channel_show(self):
- self.smart('channel --show')
-
- @testcase(717)
- def test_smart_channel_rpmsys(self):
- self.smart('channel --show rpmsys')
- self.smart('channel --disable rpmsys')
- self.smart('channel --enable rpmsys')
-
- @testcase(1144)
- @skipUnlessPassed('test_smart_channel_add')
- def test_smart_install(self):
- self.smart('remove -y psplash-default')
- self.smart('install -y psplash-default')
-
- @testcase(728)
- @skipUnlessPassed('test_smart_install')
- def test_smart_install_dependency(self):
- self.smart('remove -y psplash')
- self.smart('install -y psplash-default')
-
- @testcase(723)
- @skipUnlessPassed('test_smart_channel_add')
- def test_smart_install_from_disk(self):
- self.smart('remove -y psplash-default')
- self.smart('download psplash-default')
- self.smart('install -y ./psplash-default*')
-
- @testcase(725)
- @skipUnlessPassed('test_smart_channel_add')
- def test_smart_install_from_http(self):
- output = self.smart('download --urls psplash-default')
- url = re.search('(http://.*/psplash-default.*\.rpm)', output)
- self.assertTrue(url, msg="Couln't find download url in %s" % output)
- self.smart('remove -y psplash-default')
- self.smart('install -y %s' % url.group(0))
-
- @testcase(729)
- @skipUnlessPassed('test_smart_install')
- def test_smart_reinstall(self):
- self.smart('reinstall -y psplash-default')
-
- @testcase(727)
- @skipUnlessPassed('test_smart_channel_add')
- def test_smart_remote_repo(self):
- self.smart('update')
- self.smart('install -y psplash')
- self.smart('remove -y psplash')
-
- @testcase(726)
- def test_smart_local_dir(self):
- self.target.run('mkdir /tmp/myrpmdir')
- self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
- self.target.run('cd /tmp/myrpmdir')
- self.smart('download psplash')
- output = self.smart('channel --list')
- for i in output.split("\n"):
- if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
- self.smart('channel --disable '+str(i))
- self.target.run('cd $HOME')
- self.smart('install psplash')
- for i in output.split("\n"):
- if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
- self.smart('channel --enable '+str(i))
- self.smart('channel --remove myrpmdir -y')
- self.target.run("rm -rf /tmp/myrpmdir")
-
- @testcase(718)
- def test_smart_add_rpmdir(self):
- self.target.run('mkdir /tmp/myrpmdir')
- self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
- self.smart('channel --disable myrpmdir -y')
- output = self.smart('channel --show myrpmdir')
- self.assertTrue("disabled = yes" in output, msg="Failed to disable rpm dir")
- self.smart('channel --enable myrpmdir -y')
- output = self.smart('channel --show myrpmdir')
- self.assertFalse("disabled = yes" in output, msg="Failed to enable rpm dir")
- self.smart('channel --remove myrpmdir -y')
- self.target.run("rm -rf /tmp/myrpmdir")
-
- @testcase(731)
- @skipUnlessPassed('test_smart_channel_add')
- def test_smart_remove_package(self):
- self.smart('install -y psplash')
- self.smart('remove -y psplash')
diff --git a/meta/lib/oeqa/runtime/ssh.py b/meta/lib/oeqa/runtime/ssh.py
deleted file mode 100644
index 0e76d5d512..0000000000
--- a/meta/lib/oeqa/runtime/ssh.py
+++ /dev/null
@@ -1,19 +0,0 @@
-import subprocess
-import unittest
-import sys
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not (oeRuntimeTest.hasPackage("dropbear") or oeRuntimeTest.hasPackage("openssh")):
- skipModule("No ssh package in image")
-
-class SshTest(oeRuntimeTest):
-
- @testcase(224)
- @skipUnlessPassed('test_ping')
- def test_ssh(self):
- (status, output) = self.target.run('uname -a')
- self.assertEqual(status, 0, msg="SSH Test failed: %s" % output)
- (status, output) = self.target.run('cat /etc/masterimage')
- self.assertEqual(status, 1, msg="This isn't the right image - /etc/masterimage shouldn't be here %s" % output)
diff --git a/meta/lib/oeqa/runtime/syslog.py b/meta/lib/oeqa/runtime/syslog.py
deleted file mode 100644
index 8f550329e7..0000000000
--- a/meta/lib/oeqa/runtime/syslog.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not (oeRuntimeTest.hasPackage("busybox-syslog") or oeRuntimeTest.hasPackage("sysklogd")):
- skipModule("No syslog package in image")
-
-class SyslogTest(oeRuntimeTest):
-
- @testcase(201)
- def test_syslog_running(self):
- (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd')
- self.assertEqual(status, 0, msg="no syslogd process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1])
-
-class SyslogTestConfig(oeRuntimeTest):
-
- @testcase(1149)
- @skipUnlessPassed("test_syslog_running")
- def test_syslog_logger(self):
- (status, output) = self.target.run('logger foobar')
- self.assertEqual(status, 0, msg="Can't log into syslog. Output: %s " % output)
-
- (status, output) = self.target.run('grep foobar /var/log/messages')
- if status != 0:
- if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", "") == "systemd":
- (status, output) = self.target.run('journalctl -o cat | grep foobar')
- else:
- (status, output) = self.target.run('logread | grep foobar')
- self.assertEqual(status, 0, msg="Test log string not found in /var/log/messages or logread. Output: %s " % output)
-
- @testcase(1150)
- @skipUnlessPassed("test_syslog_running")
- def test_syslog_restart(self):
- if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False):
- (status,output) = self.target.run('/etc/init.d/syslog restart')
- else:
- (status,output) = self.target.run('systemctl restart syslog.service')
-
- @testcase(202)
- @skipUnlessPassed("test_syslog_restart")
- @skipUnlessPassed("test_syslog_logger")
- @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False), "Not appropiate for systemd image")
- @unittest.skipIf(oeRuntimeTest.hasPackage("sysklogd") or not oeRuntimeTest.hasPackage("busybox"), "Non-busybox syslog")
- def test_syslog_startup_config(self):
- self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf')
- (status,output) = self.target.run('/etc/init.d/syslog restart')
- self.assertEqual(status, 0, msg="Could not restart syslog service. Status and output: %s and %s" % (status,output))
- (status,output) = self.target.run('logger foobar && grep foobar /var/log/test')
- self.assertEqual(status, 0, msg="Test log string not found. Output: %s " % output)
- self.target.run("sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf")
- self.target.run('/etc/init.d/syslog restart')
diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py
deleted file mode 100644
index 8de799cd63..0000000000
--- a/meta/lib/oeqa/runtime/systemd.py
+++ /dev/null
@@ -1,178 +0,0 @@
-import unittest
-import re
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("systemd"):
- skipModule("target doesn't have systemd in DISTRO_FEATURES")
- if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", True):
- skipModule("systemd is not the init manager for this image")
-
-
-class SystemdTest(oeRuntimeTest):
-
- def systemctl(self, action = '', target = '', expected = 0, verbose = False):
- command = 'systemctl %s %s' % (action, target)
- status, output = self.target.run(command)
- message = '\n'.join([command, output])
- if status != expected and verbose:
- message += self.target.run('systemctl status --full %s' % target)[1]
- self.assertEqual(status, expected, message)
- return output
-
- #TODO: use pyjournalctl instead
- def journalctl(self, args='',l_match_units=[]):
- """
- Request for the journalctl output to the current target system
-
- Arguments:
- -args, an optional argument pass through argument
- -l_match_units, an optional list of units to filter the output
- Returns:
- -string output of the journalctl command
- Raises:
- -AssertionError, on remote commands that fail
- -ValueError, on a journalctl call with filtering by l_match_units that
- returned no entries
- """
- query_units=""
- if len(l_match_units):
- query_units = ['_SYSTEMD_UNIT='+unit for unit in l_match_units]
- query_units = " ".join(query_units)
- command = 'journalctl %s %s' %(args, query_units)
- status, output = self.target.run(command)
- if status:
- raise AssertionError("Command '%s' returned non-zero exit \
- code %d:\n%s" % (command, status, output))
- if len(output) == 1 and "-- No entries --" in output:
- raise ValueError("List of units to match: %s, returned no entries"
- % l_match_units)
- return output
-
-class SystemdBasicTests(SystemdTest):
-
- @skipUnlessPassed('test_ssh')
- def test_systemd_basic(self):
- self.systemctl('--version')
-
- @testcase(551)
- @skipUnlessPassed('test_systemd_basic')
- def test_systemd_list(self):
- self.systemctl('list-unit-files')
-
- def settle(self):
- """
- Block until systemd has finished activating any units being activated,
- or until two minutes has elapsed.
-
- Returns a tuple, either (True, '') if all units have finished
- activating, or (False, message string) if there are still units
- activating (generally, failing units that restart).
- """
- import time
- endtime = time.time() + (60 * 2)
- while True:
- status, output = self.target.run('systemctl --state=activating')
- if "0 loaded units listed" in output:
- return (True, '')
- if time.time() >= endtime:
- return (False, output)
- time.sleep(10)
-
- @testcase(550)
- @skipUnlessPassed('test_systemd_basic')
- def test_systemd_failed(self):
- settled, output = self.settle()
- self.assertTrue(settled, msg="Timed out waiting for systemd to settle:\n" + output)
-
- output = self.systemctl('list-units', '--failed')
- match = re.search("0 loaded units listed", output)
- if not match:
- output += self.systemctl('status --full --failed')
- self.assertTrue(match, msg="Some systemd units failed:\n%s" % output)
-
-
-class SystemdServiceTests(SystemdTest):
-
- def check_for_avahi(self):
- if not self.hasPackage('avahi-daemon'):
- raise unittest.SkipTest("Testcase dependency not met: need avahi-daemon installed on target")
-
- @skipUnlessPassed('test_systemd_basic')
- def test_systemd_status(self):
- self.check_for_avahi()
- self.systemctl('status --full', 'avahi-daemon.service')
-
- @testcase(695)
- @skipUnlessPassed('test_systemd_status')
- def test_systemd_stop_start(self):
- self.check_for_avahi()
- self.systemctl('stop', 'avahi-daemon.service')
- self.systemctl('is-active', 'avahi-daemon.service', expected=3, verbose=True)
- self.systemctl('start','avahi-daemon.service')
- self.systemctl('is-active', 'avahi-daemon.service', verbose=True)
-
- @testcase(696)
- @skipUnlessPassed('test_systemd_basic')
- def test_systemd_disable_enable(self):
- self.check_for_avahi()
- self.systemctl('disable', 'avahi-daemon.service')
- self.systemctl('is-enabled', 'avahi-daemon.service', expected=1)
- self.systemctl('enable', 'avahi-daemon.service')
- self.systemctl('is-enabled', 'avahi-daemon.service')
-
-class SystemdJournalTests(SystemdTest):
- @skipUnlessPassed('test_ssh')
- def test_systemd_journal(self):
- (status, output) = self.target.run('journalctl')
- self.assertEqual(status, 0, output)
-
- @skipUnlessPassed('test_systemd_basic')
- def test_systemd_boot_time(self, systemd_TimeoutStartSec=90):
- """
- Get the target boot time from journalctl and log it
-
- Arguments:
- -systemd_TimeoutStartSec, an optional argument containing systemd's
- unit start timeout to compare against
- """
-
- # the expression chain that uniquely identifies the time boot message
- expr_items=["Startup finished","kernel", "userspace","\.$"]
- try:
- output = self.journalctl(args="-o cat --reverse")
- except AssertionError:
- self.fail("Error occurred while calling journalctl")
- if not len(output):
- self.fail("Error, unable to get startup time from systemd journal")
-
- # check for the regular expression items that match the startup time
- for line in output.split('\n'):
- check_match = "".join(re.findall(".*".join(expr_items), line))
- if check_match: break
- # put the startup time in the test log
- if check_match:
- print("%s" % check_match)
- else:
- self.skipTest("Error at obtaining the boot time from journalctl")
- boot_time_sec = 0
-
- # get the numeric values from the string and convert them to seconds
- # same data will be placed in list and string for manipulation
- l_boot_time = check_match.split(" ")[-2:]
- s_boot_time = " ".join(l_boot_time)
- try:
- # Obtain the minutes it took to boot
- if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit():
- boot_time_min = s_boot_time.split("min")[0]
- # convert to seconds and accumulate it
- boot_time_sec += int(boot_time_min) * 60
- # Obtain the seconds it took to boot and accumulate
- boot_time_sec += float(l_boot_time[1].split("s")[0])
- except ValueError:
- self.skipTest("Error when parsing time from boot string")
- #Assert the target boot time against systemd's unit start timeout
- if boot_time_sec > systemd_TimeoutStartSec:
- print("Target boot time %s exceeds systemd's TimeoutStartSec %s"\
- %(boot_time_sec, systemd_TimeoutStartSec))
diff --git a/meta/lib/oeqa/runtime/utils/__init__.py b/meta/lib/oeqa/runtime/utils/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/meta/lib/oeqa/runtime/utils/__init__.py
diff --git a/meta/lib/oeqa/runtime/utils/targetbuildproject.py b/meta/lib/oeqa/runtime/utils/targetbuildproject.py
new file mode 100644
index 0000000000..f4f4816a9b
--- /dev/null
+++ b/meta/lib/oeqa/runtime/utils/targetbuildproject.py
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2016 Intel Corporation
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.utils.buildproject import BuildProject
+
+class TargetBuildProject(BuildProject):
+
+ def __init__(self, target, uri, foldername=None, dl_dir=None):
+ self.target = target
+ self.targetdir = "~/buildtest/"
+ BuildProject.__init__(self, uri, foldername, dl_dir=dl_dir)
+
+ def download_archive(self):
+ self.target.run("mkdir " + self.targetdir + " || true")
+
+ self._download_archive()
+
+ status, output = self.target.copyTo(self.localarchive, self.targetdir)
+ if status:
+ raise Exception('Failed to copy archive to target, '
+ 'output: %s' % output)
+
+ cmd = 'tar xf %s%s -C %s' % (self.targetdir,
+ self.archive,
+ self.targetdir)
+ status, output = self.target.run(cmd)
+ if status:
+ raise Exception('Failed to extract archive, '
+ 'output: %s' % output)
+
+ # Change targetdir to project folder
+ self.targetdir = self.targetdir + self.fname
+
+ # The timeout parameter of target.run is set to 0
+ # to make the ssh command run with no timeout.
+ def _run(self, cmd):
+ ret = self.target.run(cmd, 0)
+ msg = "Command %s failed with exit code %s: %s" % (cmd, ret[0], ret[1])
+ if ret[0] != 0:
+ raise Exception(msg)
+ return ret[0]
diff --git a/meta/lib/oeqa/runtime/x32lib.py b/meta/lib/oeqa/runtime/x32lib.py
deleted file mode 100644
index ce5e214035..0000000000
--- a/meta/lib/oeqa/runtime/x32lib.py
+++ /dev/null
@@ -1,18 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- #check if DEFAULTTUNE is set and it's value is: x86-64-x32
- defaulttune = oeRuntimeTest.tc.d.getVar("DEFAULTTUNE", True)
- if "x86-64-x32" not in defaulttune:
- skipModule("DEFAULTTUNE is not set to x86-64-x32")
-
-class X32libTest(oeRuntimeTest):
-
- @testcase(281)
- @skipUnlessPassed("test_ssh")
- def test_x32_file(self):
- status1 = self.target.run("readelf -h /bin/ls | grep Class | grep ELF32")[0]
- status2 = self.target.run("readelf -h /bin/ls | grep Machine | grep X86-64")[0]
- self.assertTrue(status1 == 0 and status2 == 0, msg="/bin/ls isn't an X86-64 ELF32 binary. readelf says: %s" % self.target.run("readelf -h /bin/ls")[1])
diff --git a/meta/lib/oeqa/runtime/xorg.py b/meta/lib/oeqa/runtime/xorg.py
deleted file mode 100644
index 12bcd371af..0000000000
--- a/meta/lib/oeqa/runtime/xorg.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import unittest
-from oeqa.oetest import oeRuntimeTest, skipModule
-from oeqa.utils.decorators import *
-
-def setUpModule():
- if not oeRuntimeTest.hasFeature("x11-base"):
- skipModule("target doesn't have x11 in IMAGE_FEATURES")
-
-
-class XorgTest(oeRuntimeTest):
-
- @testcase(1151)
- @skipUnlessPassed('test_ssh')
- def test_xorg_running(self):
- (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -v xinit | grep [X]org')
- self.assertEqual(status, 0, msg="Xorg does not appear to be running %s" % self.target.run(oeRuntimeTest.pscmd)[1])