diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases')
59 files changed, 698 insertions, 403 deletions
diff --git a/meta/lib/oeqa/runtime/cases/_qemutiny.py b/meta/lib/oeqa/runtime/cases/_qemutiny.py index 6886e36502..816fd4a7cb 100644 --- a/meta/lib/oeqa/runtime/cases/_qemutiny.py +++ b/meta/lib/oeqa/runtime/cases/_qemutiny.py @@ -1,12 +1,19 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.target.qemu import OEQemuTarget 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) + # Until the target has explicit run_serial support, check that the + # target is the qemu runner + if isinstance(self.target, OEQemuTarget): + status, output = self.target.runner.run_serial('uname -a') + self.assertIn("Linux", output) + else: + self.skipTest("Target %s is not OEQemuTarget" % self.target) diff --git a/meta/lib/oeqa/runtime/cases/apt.py b/meta/lib/oeqa/runtime/cases/apt.py index 574a34f148..8000645843 100644 --- a/meta/lib/oeqa/runtime/cases/apt.py +++ b/meta/lib/oeqa/runtime/cases/apt.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -37,9 +39,9 @@ class AptRepoTest(AptTest): self.target.run('cd %s; echo deb [ allow-insecure=yes ] %s/all ./ > sources.list' % (apt_get_sourceslist_dir, apt_get_source_server)) def setup_source_config_for_package_install_signed(self): - apt_get_source_server = 'http:\/\/%s:%s' % (self.tc.target.server_ip, self.repo_server.port) + 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; cp sources.list sources.list.bak; sed -i 's/\[trusted=yes\] http:\/\/bogus_ip:bogus_port/%s/g' sources.list" % (apt_get_sourceslist_dir, apt_get_source_server)) + self.target.run("cd %s; cp sources.list sources.list.bak; sed -i 's|\[trusted=yes\] http://bogus_ip:bogus_port|%s|g' sources.list" % (apt_get_sourceslist_dir, apt_get_source_server)) def cleanup_source_config_for_package_install(self): apt_get_sourceslist_dir = '/etc/apt/' diff --git a/meta/lib/oeqa/runtime/cases/boot.py b/meta/lib/oeqa/runtime/cases/boot.py index e1ad88a174..dcee3311f7 100644 --- a/meta/lib/oeqa/runtime/cases/boot.py +++ b/meta/lib/oeqa/runtime/cases/boot.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/buildcpio.py b/meta/lib/oeqa/runtime/cases/buildcpio.py index e29bf16ccb..7be734cb4f 100644 --- a/meta/lib/oeqa/runtime/cases/buildcpio.py +++ b/meta/lib/oeqa/runtime/cases/buildcpio.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -12,7 +14,7 @@ class BuildCpioTest(OERuntimeTestCase): @classmethod def setUpClass(cls): - uri = 'https://downloads.yoctoproject.org/mirror/sources/cpio-2.13.tar.gz' + uri = 'https://downloads.yoctoproject.org/mirror/sources/cpio-2.15.tar.gz' cls.project = TargetBuildProject(cls.tc.target, uri, dl_dir = cls.tc.td['DL_DIR']) @@ -27,7 +29,6 @@ class BuildCpioTest(OERuntimeTestCase): @OEHasPackage(['autoconf']) def test_cpio(self): self.project.download_archive() - self.project.run_configure('--disable-maintainer-mode', - 'sed -i -e "/char \*program_name/d" src/global.c;') + 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 index e5cc3e2888..2cfb3243dc 100644 --- a/meta/lib/oeqa/runtime/cases/buildgalculator.py +++ b/meta/lib/oeqa/runtime/cases/buildgalculator.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/buildlzip.py b/meta/lib/oeqa/runtime/cases/buildlzip.py index bc70b41461..44f4f1be71 100644 --- a/meta/lib/oeqa/runtime/cases/buildlzip.py +++ b/meta/lib/oeqa/runtime/cases/buildlzip.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/connman.py b/meta/lib/oeqa/runtime/cases/connman.py index f0d15fac9b..a488752e3f 100644 --- a/meta/lib/oeqa/runtime/cases/connman.py +++ b/meta/lib/oeqa/runtime/cases/connman.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/date.py b/meta/lib/oeqa/runtime/cases/date.py index bd6537400e..a2523de67a 100644 --- a/meta/lib/oeqa/runtime/cases/date.py +++ b/meta/lib/oeqa/runtime/cases/date.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/df.py b/meta/lib/oeqa/runtime/cases/df.py index bb155c9cf9..43e0ebf9ea 100644 --- a/meta/lib/oeqa/runtime/cases/df.py +++ b/meta/lib/oeqa/runtime/cases/df.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/dnf.py b/meta/lib/oeqa/runtime/cases/dnf.py index f40c63026e..3ccb18ce83 100644 --- a/meta/lib/oeqa/runtime/cases/dnf.py +++ b/meta/lib/oeqa/runtime/cases/dnf.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -73,48 +75,43 @@ class DnfRepoTest(DnfTest): 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') + self.dnf_with_repo('remove -y dnf-test-*') + self.dnf_with_repo('install -y dnf-test-dep') @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') + self.dnf_with_repo('remove -y dnf-test-*') + self.dnf_with_repo('install -y dnf-test-main') + output = self.dnf('list --installed dnf-test-*') + self.assertIn("dnf-test-main.", output) + self.assertIn("dnf-test-dep.", output) @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.dnf_with_repo('remove -y dnf-test-dep') + self.dnf_with_repo('install -y --downloadonly dnf-test-dep') + status, output = self.target.run('find /var/cache/dnf -name dnf-test-dep*rpm') 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"), + output = subprocess.check_output('%s %s -name dnf-test-dep*' % (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('remove -y dnf-test-dep') 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') + self.dnf_with_repo('reinstall -y dnf-test-main') @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache']) @skipIfInDataVar('DISTRO_FEATURES', 'usrmerge', 'Test run when not enable usrmerge') @@ -137,55 +134,40 @@ class DnfRepoTest(DnfTest): 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) + self.dnf_with_repo('install --installroot=%s -v -y --rpmverbosity=debug busybox' % 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') + @skipIfNotInDataVar('DISTRO_FEATURES', 'usrmerge', 'Test run when enable usrmerge') @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) + self.target.run('mkdir -p %s/etc' % rootpath) + self.target.run('mkdir -p %s/usr/bin %s/usr/sbin' % (rootpath, rootpath)) + self.target.run('ln -sf usr/bin %s/bin' % (rootpath)) + self.target.run('ln -sf usr/sbin %s/sbin' % (rootpath)) + self.target.run('mkdir -p %s/dev' % rootpath) #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.target.run("for l in /lib*; do mkdir -p %s/usr/$l; ln -s usr/$l %s/$l; done" % (rootpath, rootpath)) + self.target.run('cp -r /etc/rpm %s/etc' % rootpath) + self.target.run('cp -r /etc/dnf %s/etc' % rootpath) + self.target.run('cp /bin/busybox %s/bin/sh' % rootpath) + self.target.run('mount -o bind /dev %s/dev/' % rootpath) + self.dnf_with_repo('install --installroot=%s -v -y --rpmverbosity=debug busybox' % rootpath) + status, output = self.target.run('test -e %s/var/cache/dnf' % rootpath) self.assertEqual(0, status, output) - status, output = self.target.run('test -e %s/bin/busybox' % rootpath, 1500) + status, output = self.target.run('test -e %s/bin/busybox' % rootpath) 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) + self.dnf_with_repo('remove -y dnf-test-*') + self.dnf_with_repo('install -y --exclude=dnf-test-dep dnf-test-*') + output = self.dnf('list --installed dnf-test-*') + self.assertIn("dnf-test-main.", output) + self.assertNotIn("dnf-test-dev.", output) diff --git a/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py b/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py index b93ee29941..eac8f2d082 100644 --- a/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py +++ b/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py @@ -1,3 +1,8 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.data import skipIfQemu diff --git a/meta/lib/oeqa/runtime/cases/gcc.py b/meta/lib/oeqa/runtime/cases/gcc.py index 1b6e431bf4..17b1483e8d 100644 --- a/meta/lib/oeqa/runtime/cases/gcc.py +++ b/meta/lib/oeqa/runtime/cases/gcc.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/gi.py b/meta/lib/oeqa/runtime/cases/gi.py index 42bd100a31..78c7ddda2c 100644 --- a/meta/lib/oeqa/runtime/cases/gi.py +++ b/meta/lib/oeqa/runtime/cases/gi.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/go.py b/meta/lib/oeqa/runtime/cases/go.py index 89ba2c3ecb..39a80f4dca 100644 --- a/meta/lib/oeqa/runtime/cases/go.py +++ b/meta/lib/oeqa/runtime/cases/go.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -16,4 +18,4 @@ class GoHelloworldTest(OERuntimeTestCase): self.assertEqual(status, 0, msg=msg) msg = 'Incorrect output: %s' % output - self.assertEqual(output, "Hello, Go examples!", msg=msg) + self.assertEqual(output, "Hello, world!", msg=msg) diff --git a/meta/lib/oeqa/runtime/cases/gstreamer.py b/meta/lib/oeqa/runtime/cases/gstreamer.py index f735f82e3b..2295769cfd 100644 --- a/meta/lib/oeqa/runtime/cases/gstreamer.py +++ b/meta/lib/oeqa/runtime/cases/gstreamer.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/kernelmodule.py b/meta/lib/oeqa/runtime/cases/kernelmodule.py index 47fd2f850c..9c42fcc586 100644 --- a/meta/lib/oeqa/runtime/cases/kernelmodule.py +++ b/meta/lib/oeqa/runtime/cases/kernelmodule.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/ksample.py b/meta/lib/oeqa/runtime/cases/ksample.py index c69e3fe4ac..b6848762e3 100644 --- a/meta/lib/oeqa/runtime/cases/ksample.py +++ b/meta/lib/oeqa/runtime/cases/ksample.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/ldd.py b/meta/lib/oeqa/runtime/cases/ldd.py index 9c2caa8f65..f6841c6675 100644 --- a/meta/lib/oeqa/runtime/cases/ldd.py +++ b/meta/lib/oeqa/runtime/cases/ldd.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/login.py b/meta/lib/oeqa/runtime/cases/login.py new file mode 100644 index 0000000000..e1bc60d49b --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/login.py @@ -0,0 +1,116 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import shutil +import subprocess +import tempfile +import time +import os +from datetime import datetime +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.runtime.decorator.package import OEHasPackage + +### Status of qemu images. +# - runqemu qemuppc64 comes up blank. (skip) +# - qemuarmv5 comes up with multiple heads but sending "head" to screendump. +# seems to create a png with a bad header? (skip for now, but come back to fix) +# - qemuriscv32 and qemuloongarch64 doesn't work with testimage apparently? (skip) +# - qemumips64 is missing mouse icon. +# - qemumips takes forever to render and is missing mouse icon. +# - qemuarm and qemuppc are odd as they don't resize so we need to just set width. +# - All images have home and screen flipper icons not always rendered fully at first. +# the sleep seems to help this out some, depending on machine load. +### + +class LoginTest(OERuntimeTestCase): + @OEHasPackage(['matchbox-desktop', 'dbus-wait']) + def test_screenshot(self): + if self.td.get('MACHINE') in ("qemuppc64", "qemuarmv5", "qemuriscv32", "qemuriscv64", "qemuloongarch64"): + self.skipTest("{0} is not currently supported.".format(self.td.get('MACHINE'))) + + pn = self.td.get('PN') + + ourenv = os.environ.copy() + origpath = self.td.get("ORIGPATH") + if origpath: + ourenv['PATH'] = ourenv['PATH'] + ":" + origpath + + for cmd in ["identify.im7", "convert.im7", "compare.im7"]: + try: + subprocess.check_output(["which", cmd], env=ourenv) + except subprocess.CalledProcessError: + self.skipTest("%s (from imagemagick) not available" % cmd) + + + # Store images so we can debug them if needed + saved_screenshots_dir = self.td.get('T') + "/saved-screenshots/" + + ### + # This is a really horrible way of doing this but I've not found the + # right event to determine "The system is loaded and screen is rendered" + # + # Using dbus-wait for matchbox is the wrong answer because while it + # ensures the system is up, it doesn't mean the screen is rendered. + # + # Checking the qmp socket doesn't work afaik either. + # + # One way to do this is to do compares of known good screendumps until + # we either get expected or close to expected or we time out. Part of the + # issue here with that is that there is a very fine difference in the + # diff between a screendump where the icons haven't loaded yet and + # one where they won't load. I'll look at that next, but, for now, this. + # + # Which is ugly and I hate it but it 'works' for various definitions of + # 'works'. + ### + # RP: if the signal is sent before we run this, it will never be seen and we'd timeout + #status, output = self.target.run('dbus-wait org.matchbox_project.desktop Loaded') + #if status != 0 or "Timeout" in output: + # self.fail('dbus-wait failed (%s, %s). This could mean that the image never loaded the matchbox desktop.' % (status, output)) + + # Start taking screenshots every 2 seconds until diff=0 or timeout is 60 seconds + timeout = time.time() + 60 + diff = True + with tempfile.NamedTemporaryFile(prefix="oeqa-screenshot-login", suffix=".png") as t: + while diff != 0 and time.time() < timeout: + time.sleep(2) + ret = self.target.runner.run_monitor("screendump", args={"filename": t.name, "format":"png"}) + + # Find out size of image so we can determine where to blank out clock. + # qemuarm and qemuppc are odd as it doesn't resize the window and returns + # incorrect widths + if self.td.get('MACHINE') == "qemuarm" or self.td.get('MACHINE') == "qemuppc": + width = "640" + else: + cmd = "identify.im7 -ping -format '%w' {0}".format(t.name) + width = subprocess.check_output(cmd, shell=True, env=ourenv).decode() + + rblank = int(float(width)) + lblank = rblank-80 + + # Use the meta-oe version of convert, along with it's suffix. This blanks out the clock. + cmd = "convert.im7 {0} -fill white -draw 'rectangle {1},4 {2},28' {3}".format(t.name, str(rblank), str(lblank), t.name) + convert_out=subprocess.check_output(cmd, shell=True, env=ourenv).decode() + + bb.utils.mkdirhier(saved_screenshots_dir) + savedfile = "{0}/saved-{1}-{2}-{3}.png".format(saved_screenshots_dir, \ + datetime.timestamp(datetime.now()), \ + pn, \ + self.td.get('MACHINE')) + shutil.copy2(t.name, savedfile) + + refimage = self.td.get('COREBASE') + "/meta/files/screenshot-tests/" + pn + "-" + self.td.get('MACHINE') +".png" + if not os.path.exists(refimage): + self.skipTest("No reference image for comparision (%s)" % refimage) + + cmd = "compare.im7 -metric MSE {0} {1} /dev/null".format(t.name, refimage) + compare_out = subprocess.run(cmd, shell=True, capture_output=True, text=True, env=ourenv) + diff=float(compare_out.stderr.replace("(", "").replace(")","").split()[1]) + if diff > 0: + # Keep a copy of the failed screenshot so we can see what happened. + self.fail("Screenshot diff is {0}. Failed image stored in {1}".format(str(diff), savedfile)) + else: + self.assertEqual(0, diff, "Screenshot diff is {0}.".format(str(diff))) diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py index 2bff08f9da..6ad980cb6a 100644 --- a/meta/lib/oeqa/runtime/cases/logrotate.py +++ b/meta/lib/oeqa/runtime/cases/logrotate.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/ltp.py b/meta/lib/oeqa/runtime/cases/ltp.py index a66d5d13d7..f588a93200 100644 --- a/meta/lib/oeqa/runtime/cases/ltp.py +++ b/meta/lib/oeqa/runtime/cases/ltp.py @@ -57,37 +57,47 @@ class LtpTestBase(OERuntimeTestCase): class LtpTest(LtpTestBase): - ltp_groups = ["math", "syscalls", "dio", "io", "mm", "ipc", "sched", "nptl", "pty", "containers", "controllers", "filecaps", "cap_bounds", "fcntl-locktests", "connectors", "commands", "net.ipv6_lib", "input","fs_perms_simple"] + ltp_groups = ["math", "syscalls", "dio", "io", "mm", "ipc", "sched", "nptl", "pty", "containers", "controllers", "filecaps", "cap_bounds", "fcntl-locktests", "commands", "net.ipv6_lib", "input","fs_perms_simple", "cve", "crypto", "ima", "net.nfs", "net_stress.ipsec_icmp", "net.ipv6", "numa", "uevent", "ltp-aiodio.part1", "ltp-aiodio.part2", "ltp-aiodio.part3", "ltp-aiodio.part4"] - ltp_fs = ["fs", "fsx", "fs_bind"] + ltp_fs = ["fs", "fs_bind"] # 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) + # LTP appends to log files, so ensure we start with a clean log + self.target.deleteFiles("/opt/ltp/results/", ltp_group) + + cmd = '/opt/ltp/runltp -f %s -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) + (status, output) = self.target.run(cmd, timeout=1200) endtime = time.time() + # status of 1 is 'just' tests failing. 255 likely was a command output timeout + if status and status != 1: + msg = 'Command %s returned exit code %s' % (cmd, status) + self.target.logger.warning(msg) + + # Write the console log to disk for convenience with open(os.path.join(self.ltptest_log_dir, "%s-raw.log" % ltp_group), 'w') as f: f.write(output) + # Also put the console log into the test result JSON 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 ) + # Copy the machine-readable test results locally so we can parse it + dst = os.path.join(self.ltptest_log_dir, ltp_group) remote_src = "/opt/ltp/results/%s" % ltp_group (status, output) = self.target.copyFrom(remote_src, dst, True) - msg = 'File could not be copied. Output: %s' % output if status: + msg = 'File could not be copied. Output: %s' % output self.target.logger.warning(msg) parser = LtpParser() results, sections = parser.parse(dst) - runtime = int(endtime-starttime) - sections['duration'] = runtime + sections['duration'] = int(endtime-starttime) self.sections[ltp_group] = sections failed_tests = {} diff --git a/meta/lib/oeqa/runtime/cases/maturin.py b/meta/lib/oeqa/runtime/cases/maturin.py new file mode 100644 index 0000000000..4e6384fe5e --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/maturin.py @@ -0,0 +1,58 @@ +# +# Copyright OpenEmbedded Contributors +# +# 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 MaturinTest(OERuntimeTestCase): + @OETestDepends(['ssh.SSHTest.test_ssh', 'python.PythonTest.test_python3']) + @OEHasPackage(['python3-maturin']) + def test_maturin_list_python(self): + status, output = self.target.run("maturin list-python") + self.assertEqual(status, 0) + _, py_major = self.target.run("python3 -c 'import sys; print(sys.version_info.major)'") + _, py_minor = self.target.run("python3 -c 'import sys; print(sys.version_info.minor)'") + python_version = "%s.%s" % (py_major, py_minor) + self.assertEqual(output, "🐍 1 python interpreter found:\n" + " - CPython %s at /usr/bin/python%s" % (python_version, python_version)) + + +class MaturinDevelopTest(OERuntimeTestCase): + @classmethod + def setUp(cls): + dst = '/tmp' + src = os.path.join(cls.tc.files_dir, "maturin/guessing-game") + cls.tc.target.copyTo(src, dst) + + @classmethod + def tearDown(cls): + cls.tc.target.run('rm -rf %s' % '/tmp/guessing-game/target') + + @OETestDepends(['ssh.SSHTest.test_ssh', 'python.PythonTest.test_python3']) + @OEHasPackage(['python3-maturin']) + def test_maturin_develop(self): + """ + This test case requires: + (1) that a .venv can been created. + (2) DNS nameserver to resolve crate URIs for fetching + (3) a functional 'rustc' and 'cargo' + """ + targetdir = os.path.join("/tmp", "guessing-game") + self.target.run("cd %s; python3 -m venv .venv" % targetdir) + self.target.run("echo 'nameserver 8.8.8.8' > /etc/resolv.conf") + cmd = "cd %s; maturin develop" % targetdir + status, output = self.target.run(cmd) + self.assertRegex(output, r"🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8") + self.assertRegex(output, r"🐍 Not using a specific python interpreter") + self.assertRegex(output, r"📡 Using build options features from pyproject.toml") + self.assertRegex(output, r"Compiling guessing-game v0.1.0") + self.assertRegex(output, r"📦 Built wheel for abi3 Python ≥ 3.8") + self.assertRegex(output, r"🛠 Installed guessing-game-0.1.0") + self.assertEqual(status, 0) diff --git a/meta/lib/oeqa/runtime/cases/multilib.py b/meta/lib/oeqa/runtime/cases/multilib.py index 0d1b9ae2c9..68556e45c5 100644 --- a/meta/lib/oeqa/runtime/cases/multilib.py +++ b/meta/lib/oeqa/runtime/cases/multilib.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/oe_syslog.py b/meta/lib/oeqa/runtime/cases/oe_syslog.py index 150b70d9f0..adb876160d 100644 --- a/meta/lib/oeqa/runtime/cases/oe_syslog.py +++ b/meta/lib/oeqa/runtime/cases/oe_syslog.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -114,7 +116,7 @@ class SyslogTestConfig(OERuntimeTestCase): @OETestDepends(['oe_syslog.SyslogTestConfig.test_syslog_logger']) @OEHasPackage(["busybox-syslog"]) @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd', - 'Not appropiate for systemd image') + 'Not appropriate for systemd image') def test_syslog_startup_config(self): cmd = 'echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf' self.target.run(cmd) diff --git a/meta/lib/oeqa/runtime/cases/opkg.py b/meta/lib/oeqa/runtime/cases/opkg.py index 9cfee1cd88..a29c93e59a 100644 --- a/meta/lib/oeqa/runtime/cases/opkg.py +++ b/meta/lib/oeqa/runtime/cases/opkg.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/pam.py b/meta/lib/oeqa/runtime/cases/pam.py index a482ded945..b3e8b56c3c 100644 --- a/meta/lib/oeqa/runtime/cases/pam.py +++ b/meta/lib/oeqa/runtime/cases/pam.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-common.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-common.txt new file mode 100644 index 0000000000..f91abbc941 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-common.txt @@ -0,0 +1,62 @@ +# Xserver explains what the short codes mean +(WW) warning, (EE) error, (NI) not implemented, (??) unknown. + +# Xserver warns if compiled with ACPI but no acpid running +Open ACPI failed (/var/run/acpid.socket) (No such file or directory) + +# Some machines (eg qemux86) don't enable PAE (they probably should though) +NX (Execute Disable) protection cannot be enabled: non-PAE kernel! + +# Connman's pacrunner warns if external connectivity isn't available +Failed to find URL:http://ipv4.connman.net/online/status.html +Failed to find URL:http://ipv6.connman.net/online/status.html + +# x86 on 6.6+ outputs this message, it is informational, not an error +ACPI: _OSC evaluation for CPUs failed, trying _PDC + +# These should be reviewed to see if they are still needed +dma timeout +can\'t add hid device: +usbhid: probe of +_OSC failed (AE_ERROR) +_OSC failed (AE_SUPPORT) +AE_ALREADY_EXISTS +ACPI _OSC request failed (AE_SUPPORT) +can\'t disable ASPM +Failed to load module "vesa" +Failed to load module "modesetting" +Failed to load module "glx" +Failed to load module "fbdev" +Failed to load module "ati" +[drm] Cannot find any crtc or sizes +_OSC failed (AE_NOT_FOUND); disabling ASPM +hd.: possibly failed opcode +NETLINK INITIALIZATION FAILED +kernel: Cannot find map file +omap_hwmod: debugss: _wait_target_disable failed +VGA arbiter: cannot open kernel arbiter, no multi-card support +Online check failed for +netlink init failed +Fast TSC calibration +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 +Failed to rename network interface +Failed to process device, ignoring: Device or resource busy +Cannot find a map file +[rdrand]: Initialization Failed +[rndr ]: Initialization Failed +[pulseaudio] authkey.c: Failed to open cookie file +[pulseaudio] authkey.c: Failed to load authentication key +was skipped because of a failed condition check +was skipped because all trigger condition checks failed +xf86OpenConsole: Switching VT failed +Failed to read LoaderConfigTimeoutOneShot variable, ignoring: Operation not supported +Failed to read LoaderEntryOneShot variable, ignoring: Operation not supported +Direct firmware load for regulatory.db +failed to load regulatory.db diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-mipsarch.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-mipsarch.txt new file mode 100644 index 0000000000..2c0bd9a247 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-mipsarch.txt @@ -0,0 +1,2 @@ +# These should be reviewed to see if they are still needed +cacheinfo: Failed to find cpu0 device node diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuall.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuall.txt new file mode 100644 index 0000000000..b0c0fc9ddf --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuall.txt @@ -0,0 +1,27 @@ +# psplash +FBIOPUT_VSCREENINFO failed, double buffering disabled + +# PCI host bridge to bus 0000:00 +# pci_bus 0000:00: root bus resource [mem 0x10000000-0x17ffffff] +# pci_bus 0000:00: root bus resource [io 0x1000-0x1fffff] +# pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff] +# pci 0000:00:00.0: [2046:ab11] type 00 class 0x100000 +# pci 0000:00:00.0: [Firmware Bug]: reg 0x10: invalid BAR (can't size) +# pci 0000:00:00.0: [Firmware Bug]: reg 0x14: invalid BAR (can't size) +# pci 0000:00:00.0: [Firmware Bug]: reg 0x18: invalid BAR (can't size) +# pci 0000:00:00.0: [Firmware Bug]: reg 0x1c: invalid BAR (can't size) +# pci 0000:00:00.0: [Firmware Bug]: reg 0x20: invalid BAR (can't size) +# pci 0000:00:00.0: [Firmware Bug]: reg 0x24: invalid BAR (can't size) +invalid BAR (can't size) + +# These should be reviewed to see if they are still needed +wrong ELF class +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 +tsc: HPET/PMTIMER calibration failed +modeset(0): Failed to initialize the DRI2 extension +glamor initialization failed +blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ) +floppy: error +failed to IDENTIFY (I/O error, err_mask=0x4) diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuarm64.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuarm64.txt new file mode 100644 index 0000000000..260cdde620 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuarm64.txt @@ -0,0 +1,6 @@ +# These should be reviewed to see if they are still needed +Fatal server error: +(EE) Server terminated with error (1). Closing log file. +dmi: Firmware registration failed. +irq: type mismatch, failed to map hwirq-27 for /intc +logind: failed to get session seat
\ No newline at end of file diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuarmv5.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuarmv5.txt new file mode 100644 index 0000000000..ed91107b7d --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuarmv5.txt @@ -0,0 +1,19 @@ +# Code is 2 JENT_ECOARSETIME: Timer too coarse for RNG. +jitterentropy: Initialization failed with host not compliant with requirements: 2 + +# These should be reviewed to see if they are still needed +mmci-pl18x: probe of fpga:05 failed with error -22 +mmci-pl18x: probe of fpga:0b failed with error -22 + +OF: amba_device_add() failed (-19) for /amba/smc@10100000 +OF: amba_device_add() failed (-19) for /amba/mpmc@10110000 +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 + +clcd-pl11x: probe of 10120000.display failed with error -2 +arm-charlcd 10008000.lcd: error -ENXIO: IRQ index 0 not found diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuppc.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuppc.txt new file mode 100644 index 0000000000..d9b58b58f1 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuppc.txt @@ -0,0 +1,6 @@ +# These should be reviewed to see if they are still needed +PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff] +host side 80-wire cable detection failed, limiting max speed +mode "640x480" test failed +can't handle BAR above 4GB +Cannot reserve Legacy IO
\ No newline at end of file diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuppc64.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuppc64.txt new file mode 100644 index 0000000000..b736a2aeb7 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemuppc64.txt @@ -0,0 +1,4 @@ +# These should be reviewed to see if they are still needed +vio vio: uevent: failed to send synthetic uevent +synth uevent: /devices/vio: failed to send uevent +PCI 0000:00 Cannot reserve Legacy IO [io 0x10000-0x10fff]
\ No newline at end of file diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemux86.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemux86.txt new file mode 100644 index 0000000000..ebb76f1221 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-qemux86.txt @@ -0,0 +1,2 @@ +# These should be reviewed to see if they are still needed +Failed to access perfctr msr (MSR diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-x86.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-x86.txt new file mode 100644 index 0000000000..5985247daf --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-x86.txt @@ -0,0 +1,10 @@ +# These should be reviewed to see if they are still needed +[drm:psb_do_init] *ERROR* Debug is +wrong ELF class +Could not enable PowerButton event +probe of LNXPWRBN:00 failed with error -22 +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 diff --git a/meta/lib/oeqa/runtime/cases/parselogs-ignores-x86_64.txt b/meta/lib/oeqa/runtime/cases/parselogs-ignores-x86_64.txt new file mode 120000 index 0000000000..404e384c32 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/parselogs-ignores-x86_64.txt @@ -0,0 +1 @@ +parselogs-ignores-x86.txt
\ No newline at end of file diff --git a/meta/lib/oeqa/runtime/cases/parselogs.py b/meta/lib/oeqa/runtime/cases/parselogs.py index 1f9365f3a8..6966923c94 100644 --- a/meta/lib/oeqa/runtime/cases/parselogs.py +++ b/meta/lib/oeqa/runtime/cases/parselogs.py @@ -1,216 +1,49 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # +import collections import os +import sys -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"] - -common_errors = [ - "(WW) warning, (EE) error, (NI) not implemented, (??) unknown.", - "dma timeout", - "can\'t add hid device:", - "usbhid: probe of ", - "_OSC failed (AE_ERROR)", - "_OSC failed (AE_SUPPORT)", - "AE_ALREADY_EXISTS", - "ACPI _OSC request failed (AE_SUPPORT)", - "can\'t disable ASPM", - "Failed to load module \"vesa\"", - "Failed to load module vesa", - "Failed to load module \"modesetting\"", - "Failed to load module modesetting", - "Failed to load module \"glx\"", - "Failed to load module \"fbdev\"", - "Failed to load module fbdev", - "Failed to load module glx", - "[drm] Cannot find any crtc or sizes", - "_OSC failed (AE_NOT_FOUND); disabling ASPM", - "Open ACPI failed (/var/run/acpid.socket) (No such file or directory)", - "NX (Execute Disable) protection cannot be enabled: non-PAE kernel!", - "hd.: possibly failed opcode", - 'NETLINK INITIALIZATION FAILED', - 'kernel: Cannot find map file', - 'omap_hwmod: debugss: _wait_target_disable failed', - 'VGA arbiter: cannot open kernel arbiter, no multi-card support', - 'Failed to find URL:http://ipv4.connman.net/online/status.html', - 'Online check failed for', - 'netlink init failed', - 'Fast TSC calibration', - "BAR 0-9", - "Failed to load module \"ati\"", - "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", - "Failed to rename network interface", - "Failed to process device, ignoring: Device or resource busy", - "Cannot find a map file", - "[rdrand]: Initialization Failed", - "[rndr ]: Initialization Failed", - "[pulseaudio] authkey.c: Failed to open cookie file", - "[pulseaudio] authkey.c: Failed to load authentication key", - "was skipped because of a failed condition check", - "was skipped because all trigger condition checks failed", - ] -video_related = [ -] +# importlib.resources.open_text in Python <3.10 doesn't search all directories +# when a package is split across multiple directories. Until we can rely on +# 3.10+, reimplement the searching logic. +if sys.version_info < (3, 10): + def _open_text(package, resource): + import importlib, pathlib + module = importlib.import_module(package) + for path in module.__path__: + candidate = pathlib.Path(path) / resource + if candidate.exists(): + return candidate.open(encoding='utf-8') + raise FileNotFoundError +else: + from importlib.resources import open_text as _open_text -x86_common = [ - '[drm:psb_do_init] *ERROR* Debug is', - 'wrong ELF class', - 'Could not enable PowerButton event', - 'probe of LNXPWRBN:00 failed with error -22', - '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 = [ - 'wrong ELF class', - "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', - 'tsc: HPET/PMTIMER calibration failed', - "modeset(0): Failed to initialize the DRI2 extension", - "glamor initialization failed", - "blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ)", - "floppy: error", - 'failed to IDENTIFY (I/O error, err_mask=0x4)', -] + common_errors +class ParseLogsTest(OERuntimeTestCase): -ignore_errors = { - 'default' : common_errors, - 'qemux86' : [ - 'Failed to access perfctr msr (MSR', - 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)', - ] + qemux86_common, - 'qemux86-64' : qemux86_common, - '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]', - 'host side 80-wire cable detection failed, limiting max speed', - 'mode "640x480" test failed', - 'Failed to load module "glx"', - 'can\'t handle BAR above 4GB', - 'Cannot reserve Legacy IO', - ] + common_errors, - 'qemuppc64' : [ - 'vio vio: uevent: failed to send synthetic uevent', - 'synth uevent: /devices/vio: failed to send uevent', - 'PCI 0000:00 Cannot reserve Legacy IO [io 0x10000-0x10fff]', - ] + common_errors, - 'qemuarmv5' : [ - 'mmci-pl18x: probe of fpga:05 failed with error -22', - 'mmci-pl18x: probe of fpga:0b failed with error -22', - 'Failed to load module "glx"', - 'OF: amba_device_add() failed (-19) for /amba/smc@10100000', - 'OF: amba_device_add() failed (-19) for /amba/mpmc@10110000', - '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', - 'jitterentropy: Initialization failed with host not compliant with requirements: 2', - 'clcd-pl11x: probe of 10120000.display failed with error -2', - ] + common_errors, - 'qemuarm64' : [ - 'Fatal server error:', - '(EE) Server terminated with error (1). Closing log file.', - 'dmi: Firmware registration failed.', - 'irq: type mismatch, failed to map hwirq-27 for /intc', - 'logind: failed to get session seat', - ] + common_errors, - 'intel-core2-32' : [ - 'ACPI: No _BQC method, cannot determine initial brightness', - '[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', - 'dmi: Firmware registration failed.', - 'ioremap error for 0x78', - ] + 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, - '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, -} + # Which log files should be collected + log_locations = ["/var/log/", "/var/log/dmesg", "/tmp/dmesg_output.log"] -log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"] + # The keywords that identify error messages in the log files + errors = ["error", "cannot", "can't", "failed"] -class ParseLogsTest(OERuntimeTestCase): + # A list of error messages that should be ignored + ignore_errors = [] @classmethod def setUpClass(cls): - cls.errors = errors - # When systemd is enabled we need to notice errors on # circular dependencies in units. - if 'systemd' in cls.td.get('DISTRO_FEATURES', ''): + if 'systemd' in cls.td.get('DISTRO_FEATURES'): cls.errors.extend([ 'Found ordering cycle on', 'Breaking ordering cycle by deleting job', @@ -218,48 +51,22 @@ class ParseLogsTest(OERuntimeTestCase): 'Ordering cycle found, skipping', ]) - 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 cls.ignore_errors: - cls.ignore_errors[machine] = cls.ignore_errors[machine] \ - + video_related - - def getMachine(self): - return self.td.get('MACHINE', '') - - def getWorkdir(self): - 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. - def getHardwareInfo(self): - hwi = "" - 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') + cls.errors = [s.casefold() for s in cls.errors] - 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' + cls.load_machine_ignores() - return hwi + @classmethod + def load_machine_ignores(cls): + # Add TARGET_ARCH explicitly as not every machine has that in MACHINEOVERRDES (eg qemux86-64) + for candidate in ["common", cls.td.get("TARGET_ARCH")] + cls.td.get("MACHINEOVERRIDES").split(":"): + try: + name = f"parselogs-ignores-{candidate}.txt" + for line in _open_text("oeqa.runtime.cases", name): + line = line.strip() + if line and not line.startswith("#"): + cls.ignore_errors.append(line.casefold()) + except FileNotFoundError: + pass # 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 @@ -267,23 +74,23 @@ class ParseLogsTest(OERuntimeTestCase): def getLogList(self, log_locations): logs = [] for location in log_locations: - status, _ = self.target.run('test -f ' + str(location)) + status, _ = self.target.run('test -f %s' % location) if status == 0: - logs.append(str(location)) + logs.append(location) else: - status, _ = self.target.run('test -d ' + str(location)) + status, _ = self.target.run('test -d %s' % location) if status == 0: - cmd = 'find ' + str(location) + '/*.log -maxdepth 1 -type f' + cmd = 'find %s -name \\*.log -maxdepth 1 -type f' % location 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, logfile)) return logs # Copy the log files to be parsed locally def transfer_logs(self, log_list): - workdir = self.getWorkdir() + workdir = self.td.get('WORKDIR') self.target_logs = workdir + '/' + 'target_logs' target_logs = self.target_logs if os.path.exists(target_logs): @@ -300,65 +107,55 @@ class ParseLogsTest(OERuntimeTestCase): 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 - def build_grepcmd(self, errors, ignore_errors, log): - grepcmd = 'grep ' - grepcmd += '-Ei "' - for error in errors: - grepcmd += r'\<' + error + r'\>' + '|' - grepcmd = grepcmd[:-1] - 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' - errorlist = ignore_errors['default'] - - for ignore_error in errorlist: - ignore_error = ignore_error.replace('(', r'\(') - ignore_error = ignore_error.replace(')', r'\)') - ignore_error = ignore_error.replace("'", '.') - ignore_error = ignore_error.replace('?', r'\?') - ignore_error = ignore_error.replace('[', r'\[') - ignore_error = ignore_error.replace(']', r'\]') - ignore_error = ignore_error.replace('*', r'\*') - 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): - results = {} - rez = [] - grep_output = '' + def get_context(self, lines, index, before=6, after=3): + """ + Given a set of lines and the index of the line that is important, return + a number of lines surrounding that line. + """ + last = len(lines) + + start = index - before + end = index + after + 1 + + if start < 0: + end -= start + start = 0 + if end > last: + start -= end - last + end = last + + return lines[start:end] + + def test_get_context(self): + """ + A test case for the test case. + """ + lines = list(range(0,10)) + self.assertEqual(self.get_context(lines, 0, 2, 1), [0, 1, 2, 3]) + self.assertEqual(self.get_context(lines, 5, 2, 1), [3, 4, 5, 6]) + self.assertEqual(self.get_context(lines, 9, 2, 1), [6, 7, 8, 9]) + + def parse_logs(self, logs, lines_before=10, lines_after=10): + """ + Search the log files @logs looking for error lines (marked by + @self.errors), ignoring anything listed in @self.ignore_errors. + + Returns a dictionary of log filenames to a dictionary of error lines to + the error context (controlled by @lines_before and @lines_after). + """ + results = collections.defaultdict(dict) for log in logs: - result = None - thegrep = self.build_grepcmd(errors, ignore_errors, log) + with open(log) as f: + lines = f.readlines() - try: - result = check_output(thegrep, shell=True).decode('utf-8') - except: - pass + for i, line in enumerate(lines): + line = line.strip() + line_lower = line.casefold() - if result is not None: - results[log] = {} - rez = result.splitlines() - - for xrez in rez: - try: - 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][xrez]=grep_output + if any(keyword in line_lower for keyword in self.errors): + if not any(ignore in line_lower for ignore in self.ignore_errors): + results[log][line] = "".join(self.get_context(lines, i, lines_before, lines_after)) return results @@ -371,17 +168,18 @@ class ParseLogsTest(OERuntimeTestCase): def test_parselogs(self): self.write_dmesg() log_list = self.get_local_log_list(self.log_locations) - result = self.parse_logs(self.errors, self.ignore_errors, log_list) - print(self.getHardwareInfo()) + result = self.parse_logs(log_list) + errcount = 0 + self.msg = "" for log in result: self.msg += 'Log: ' + log + '\n' self.msg += '-----------------------\n' for error in result[log]: errcount += 1 - self.msg += 'Central error: ' + str(error) + '\n' + self.msg += 'Central error: ' + error + '\n' self.msg += '***********************\n' - self.msg += result[str(log)][str(error)] + '\n' + self.msg += result[log][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 index 2c6b3b7846..f11b300836 100644 --- a/meta/lib/oeqa/runtime/cases/perl.py +++ b/meta/lib/oeqa/runtime/cases/perl.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/ping.py b/meta/lib/oeqa/runtime/cases/ping.py index 498f80d0a5..f72460e7f3 100644 --- a/meta/lib/oeqa/runtime/cases/ping.py +++ b/meta/lib/oeqa/runtime/cases/ping.py @@ -1,8 +1,11 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # from subprocess import Popen, PIPE +from time import sleep from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.oetimeout import OETimeout @@ -14,6 +17,7 @@ class PingTest(OERuntimeTestCase): def test_ping(self): output = '' count = 0 + self.assertNotEqual(len(self.target.ip), 0, msg="No target IP address set") try: while count < 5: cmd = 'ping -c 1 %s' % self.target.ip @@ -23,6 +27,7 @@ class PingTest(OERuntimeTestCase): count += 1 else: count = 0 + sleep(1) except OEQATimeoutError: self.fail("Ping timeout error for address %s, count %s, output: %s" % (self.target.ip, count, output)) msg = ('Expected 5 consecutive, got %d.\n' diff --git a/meta/lib/oeqa/runtime/cases/ptest.py b/meta/lib/oeqa/runtime/cases/ptest.py index 00742da2b5..fbaeb84d00 100644 --- a/meta/lib/oeqa/runtime/cases/ptest.py +++ b/meta/lib/oeqa/runtime/cases/ptest.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -81,17 +83,20 @@ class PtestRunnerTest(OERuntimeTestCase): extras['ptestresult.sections'] = sections + zerolength = [] 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} + if not results[section]: + zerolength.append(section) failed_tests = {} for section in sections: - if 'exitcode' in sections[section].keys(): + if 'exitcode' in sections[section].keys() or 'timeout' in sections[section].keys(): failed_tests[section] = sections[section]["log"] for section in results: @@ -105,7 +110,10 @@ class PtestRunnerTest(OERuntimeTestCase): 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) + failmsg = failmsg + "\nFailed ptests:\n%s\n" % pprint.pformat(failed_tests) + + if zerolength: + failmsg = failmsg + "\nptests which had no test results:\n%s" % pprint.pformat(zerolength) if failmsg: self.logger.warning("There were failing ptests.") diff --git a/meta/lib/oeqa/runtime/cases/python.py b/meta/lib/oeqa/runtime/cases/python.py index ec54f1e1db..5d6d133480 100644 --- a/meta/lib/oeqa/runtime/cases/python.py +++ b/meta/lib/oeqa/runtime/cases/python.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py index a4339116bf..ea5619ffea 100644 --- a/meta/lib/oeqa/runtime/cases/rpm.py +++ b/meta/lib/oeqa/runtime/cases/rpm.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -49,21 +51,20 @@ class RpmBasicTest(OERuntimeTestCase): 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 wait_for_no_process_for_user(u, timeout = 120): + timeout_at = time.time() + timeout + while time.time() < timeout_at: + _, output = self.target.run(self.tc.target_cmds['ps']) + if u + ' ' not in output: + return + time.sleep(1) + user_pss = [ps for ps in output.split("\n") if u + ' ' in ps] + msg = "User %s has processes still running: %s" % (u, "\n".join(user_pss)) + self.fail(msg=msg) 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) + wait_for_no_process_for_user(u) status, output = self.target.run('userdel -r %s' % u) msg = 'Failed to erase user: %s' % output self.assertTrue(status == 0, msg=msg) @@ -79,21 +80,24 @@ class RpmBasicTest(OERuntimeTestCase): class RpmInstallRemoveTest(OERuntimeTestCase): - @classmethod - def setUpClass(cls): - pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_') - rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch) + def _find_test_file(self): + pkgarch = self.td['TUNE_PKGARCH'].replace('-', '_') + rpmdir = os.path.join(self.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 + self.fail("Rpm directory {} does not exist".format(rpmdir)) 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' + self.test_file = os.path.join(rpmdir, f) + break + else: + self.fail("Couldn't find the test rpm file {} in {}".format(rpm_doc, rpmdir)) + self.dst = '/tmp/base-passwd-doc.rpm' @OETestDepends(['rpm.RpmBasicTest.test_rpm_query']) def test_rpm_install(self): + self._find_test_file() 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 @@ -116,6 +120,7 @@ class RpmInstallRemoveTest(OERuntimeTestCase): Author: Alexander Kanavin <alex.kanavin@gmail.com> AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> """ + self._find_test_file() db_files_cmd = 'ls /var/lib/rpm/rpmdb.sqlite*' check_log_cmd = "grep RPM /var/log/messages | wc -l" diff --git a/meta/lib/oeqa/runtime/cases/rt.py b/meta/lib/oeqa/runtime/cases/rt.py index 849ac1914e..15ab4dbbbb 100644 --- a/meta/lib/oeqa/runtime/cases/rt.py +++ b/meta/lib/oeqa/runtime/cases/rt.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/rtc.py b/meta/lib/oeqa/runtime/cases/rtc.py index c4e6681324..6e45c5db4f 100644 --- a/meta/lib/oeqa/runtime/cases/rtc.py +++ b/meta/lib/oeqa/runtime/cases/rtc.py @@ -1,5 +1,11 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.data import skipIfFeature from oeqa.runtime.decorator.package import OEHasPackage import re @@ -16,12 +22,14 @@ class RTCTest(OERuntimeTestCase): self.logger.debug('Starting systemd-timesyncd daemon') self.target.run('systemctl enable --now --runtime systemd-timesyncd') + @skipIfFeature('read-only-rootfs', + 'Test does not work with read-only-rootfs in IMAGE_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) @OEHasPackage(['coreutils', 'busybox']) def test_rtc(self): (status, output) = self.target.run('hwclock -r') self.assertEqual(status, 0, msg='Failed to get RTC time, output: %s' % output) - + (status, current_datetime) = self.target.run('date +"%m%d%H%M%Y"') self.assertEqual(status, 0, msg='Failed to get system current date & time, output: %s' % current_datetime) @@ -32,7 +40,6 @@ class RTCTest(OERuntimeTestCase): (status, output) = self.target.run('date %s' % current_datetime) self.assertEqual(status, 0, msg='Failed to reset system date & time, output: %s' % output) - + (status, output) = self.target.run('hwclock -w') self.assertEqual(status, 0, msg='Failed to reset RTC time, output: %s' % output) - diff --git a/meta/lib/oeqa/runtime/cases/runlevel.py b/meta/lib/oeqa/runtime/cases/runlevel.py index 3a4df8ace1..6734b0f5ed 100644 --- a/meta/lib/oeqa/runtime/cases/runlevel.py +++ b/meta/lib/oeqa/runtime/cases/runlevel.py @@ -1,3 +1,8 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends diff --git a/meta/lib/oeqa/runtime/cases/rust.py b/meta/lib/oeqa/runtime/cases/rust.py index b3d6cf7f37..123c942012 100644 --- a/meta/lib/oeqa/runtime/cases/rust.py +++ b/meta/lib/oeqa/runtime/cases/rust.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -6,14 +8,57 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.runtime.decorator.package import OEHasPackage -class RustHelloworldTest(OERuntimeTestCase): +class RustCompileTest(OERuntimeTestCase): + + @classmethod + def setUp(cls): + dst = '/tmp/' + src = os.path.join(cls.tc.files_dir, 'test.rs') + cls.tc.target.copyTo(src, dst) + + @classmethod + def tearDown(cls): + files = '/tmp/test.rs /tmp/test' + cls.tc.target.run('rm %s' % files) + dirs = '/tmp/hello' + cls.tc.target.run('rm -r %s' % dirs) + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage('rust') + @OEHasPackage('openssh-scp') + def test_rust_compile(self): + status, output = self.target.run('rustc /tmp/test.rs -o /tmp/test') + msg = 'rust 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('cargo') + @OEHasPackage('openssh-scp') + def test_cargo_compile(self): + status, output = self.target.run('cargo new /tmp/hello') + msg = 'cargo new failed, output: %s' % output + self.assertEqual(status, 0, msg=msg) + + status, output = self.target.run('cargo build --manifest-path=/tmp/hello/Cargo.toml') + msg = 'cargo build failed, output: %s' % output + self.assertEqual(status, 0, msg=msg) + + status, output = self.target.run('cargo run --manifest-path=/tmp/hello/Cargo.toml') + msg = 'running compiled file failed, output: %s' % output + self.assertEqual(status, 0, msg=msg) + +class RustCLibExampleTest(OERuntimeTestCase): @OETestDepends(['ssh.SSHTest.test_ssh']) - @OEHasPackage(['rust-hello-world']) - def test_rusthelloworld(self): - cmd = "rust-hello-world" + @OEHasPackage('rust-c-lib-example-bin') + def test_rust_c_lib_example(self): + cmd = "rust-c-lib-example-bin test" 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) + self.assertEqual(output, "Hello world in rust from C!", msg=msg) diff --git a/meta/lib/oeqa/runtime/cases/scons.py b/meta/lib/oeqa/runtime/cases/scons.py index 3c7c7f7270..4a8d4d40ba 100644 --- a/meta/lib/oeqa/runtime/cases/scons.py +++ b/meta/lib/oeqa/runtime/cases/scons.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/scp.py b/meta/lib/oeqa/runtime/cases/scp.py index f2bbc947d6..ee97b8ef66 100644 --- a/meta/lib/oeqa/runtime/cases/scp.py +++ b/meta/lib/oeqa/runtime/cases/scp.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/skeletoninit.py b/meta/lib/oeqa/runtime/cases/skeletoninit.py index a12f1e9aae..d0fdcbded9 100644 --- a/meta/lib/oeqa/runtime/cases/skeletoninit.py +++ b/meta/lib/oeqa/runtime/cases/skeletoninit.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -15,7 +17,7 @@ class SkeletonBasicTest(OERuntimeTestCase): @OETestDepends(['ssh.SSHTest.test_ssh']) @OEHasPackage(['service']) @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd', - 'Not appropiate for systemd image') + 'Not appropriate 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 diff --git a/meta/lib/oeqa/runtime/cases/ssh.py b/meta/lib/oeqa/runtime/cases/ssh.py index e31224b3af..cdbef59500 100644 --- a/meta/lib/oeqa/runtime/cases/ssh.py +++ b/meta/lib/oeqa/runtime/cases/ssh.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -11,6 +13,9 @@ class SSHTest(OERuntimeTestCase): @OETestDepends(['ping.PingTest.test_ping']) @OEHasPackage(['dropbear', 'openssh-sshd']) def test_ssh(self): + (status, output) = self.target.run('sleep 20', timeout=2) + msg='run() timed out but return code was zero.' + self.assertNotEqual(status, 0, msg=msg) (status, output) = self.target.run('uname -a') self.assertEqual(status, 0, msg='SSH Test failed: %s' % output) (status, output) = self.target.run('cat /etc/controllerimage') diff --git a/meta/lib/oeqa/runtime/cases/stap.py b/meta/lib/oeqa/runtime/cases/stap.py index 480eaabf2d..3be4162108 100644 --- a/meta/lib/oeqa/runtime/cases/stap.py +++ b/meta/lib/oeqa/runtime/cases/stap.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/storage.py b/meta/lib/oeqa/runtime/cases/storage.py index 972ef8210c..b05622fea8 100644 --- a/meta/lib/oeqa/runtime/cases/storage.py +++ b/meta/lib/oeqa/runtime/cases/storage.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/suspend.py b/meta/lib/oeqa/runtime/cases/suspend.py index 0382d48f45..a625cc5901 100644 --- a/meta/lib/oeqa/runtime/cases/suspend.py +++ b/meta/lib/oeqa/runtime/cases/suspend.py @@ -1,3 +1,8 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.data import skipIfQemu diff --git a/meta/lib/oeqa/runtime/cases/systemd.py b/meta/lib/oeqa/runtime/cases/systemd.py index 7c44abe8ed..5481e1d840 100644 --- a/meta/lib/oeqa/runtime/cases/systemd.py +++ b/meta/lib/oeqa/runtime/cases/systemd.py @@ -1,8 +1,11 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # import re +import threading import time from oeqa.runtime.case import OERuntimeTestCase @@ -66,8 +69,8 @@ class SystemdBasicTests(SystemdTest): """ 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: + status, output = self.target.run('SYSTEMD_BUS_TIMEOUT=240s systemctl is-system-running') + if "running" in output or "degraded" in output: return (True, '') if time.time() >= endtime: return (False, output) @@ -134,6 +137,27 @@ class SystemdServiceTests(SystemdTest): status = self.target.run('mount -oro,remount /')[0] self.assertTrue(status == 0, msg='Remounting / as r/o failed') + @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic']) + @skipIfNotFeature('minidebuginfo', 'Test requires minidebuginfo to be in DISTRO_FEATURES') + @OEHasPackage(['busybox']) + def test_systemd_coredump_minidebuginfo(self): + """ + Verify that call-stacks generated by systemd-coredump contain symbolicated call-stacks, + extracted from the minidebuginfo metadata (.gnu_debugdata elf section). + """ + t_thread = threading.Thread(target=self.target.run, args=("ulimit -c unlimited && sleep 1000",)) + t_thread.start() + time.sleep(1) + + status, output = self.target.run('pidof sleep') + # cause segfault on purpose + self.target.run('kill -SEGV %s' % output) + self.assertEqual(status, 0, msg = 'Not able to find process that runs sleep, output : %s' % output) + + (status, output) = self.target.run('coredumpctl info') + self.assertEqual(status, 0, msg='MiniDebugInfo Test failed: %s' % output) + self.assertEqual('sleep_for_duration (busybox.nosuid' in output, True, msg='Call stack is missing minidebuginfo symbols (functions shown as "n/a"): %s' % output) + class SystemdJournalTests(SystemdTest): @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic']) @@ -152,7 +176,7 @@ class SystemdJournalTests(SystemdTest): """ # The expression chain that uniquely identifies the time boot message. - expr_items=['Startup finished', 'kernel', 'userspace','\.$'] + expr_items=['Startup finished', 'kernel', 'userspace', r'\.$'] try: output = self.journalctl(args='-o cat --reverse') except AssertionError: diff --git a/meta/lib/oeqa/runtime/cases/terminal.py b/meta/lib/oeqa/runtime/cases/terminal.py index 8fcca99f47..96ba3c3195 100644 --- a/meta/lib/oeqa/runtime/cases/terminal.py +++ b/meta/lib/oeqa/runtime/cases/terminal.py @@ -1,3 +1,8 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.runtime.decorator.package import OEHasPackage diff --git a/meta/lib/oeqa/runtime/cases/usb_hid.py b/meta/lib/oeqa/runtime/cases/usb_hid.py index 8743174370..6f23d2ff51 100644 --- a/meta/lib/oeqa/runtime/cases/usb_hid.py +++ b/meta/lib/oeqa/runtime/cases/usb_hid.py @@ -1,3 +1,8 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.data import skipIfQemu diff --git a/meta/lib/oeqa/runtime/cases/weston.py b/meta/lib/oeqa/runtime/cases/weston.py index 1fd471e611..ee4d336482 100644 --- a/meta/lib/oeqa/runtime/cases/weston.py +++ b/meta/lib/oeqa/runtime/cases/weston.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/x32lib.py b/meta/lib/oeqa/runtime/cases/x32lib.py index f419c8f181..014da4b386 100644 --- a/meta/lib/oeqa/runtime/cases/x32lib.py +++ b/meta/lib/oeqa/runtime/cases/x32lib.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/runtime/cases/xorg.py b/meta/lib/oeqa/runtime/cases/xorg.py index d6845587c2..09afb1e3d1 100644 --- a/meta/lib/oeqa/runtime/cases/xorg.py +++ b/meta/lib/oeqa/runtime/cases/xorg.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # |