diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/dnf.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/dnf.py | 102 |
1 files changed, 56 insertions, 46 deletions
diff --git a/meta/lib/oeqa/runtime/cases/dnf.py b/meta/lib/oeqa/runtime/cases/dnf.py index 7da31cbf88..3ccb18ce83 100644 --- a/meta/lib/oeqa/runtime/cases/dnf.py +++ b/meta/lib/oeqa/runtime/cases/dnf.py @@ -1,3 +1,9 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + import os import re import subprocess @@ -5,8 +11,7 @@ from oeqa.utils.httpserver import HTTPService from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends -from oeqa.core.decorator.oeid import OETestID -from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature +from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature, skipIfInDataVar, skipIfNotInDataVar from oeqa.runtime.decorator.package import OEHasPackage class DnfTest(OERuntimeTestCase): @@ -26,27 +31,22 @@ class DnfBasicTest(DnfTest): 'RPM is not the primary package manager') @OEHasPackage(['dnf']) @OETestDepends(['ssh.SSHTest.test_ssh']) - @OETestID(1735) def test_dnf_help(self): self.dnf('--help') @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) - @OETestID(1739) def test_dnf_version(self): self.dnf('--version') @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) - @OETestID(1737) def test_dnf_info(self): self.dnf('info dnf') @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) - @OETestID(1738) def test_dnf_search(self): self.dnf('search dnf') @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) - @OETestID(1736) def test_dnf_history(self): self.dnf('history') @@ -55,7 +55,8 @@ class DnfRepoTest(DnfTest): @classmethod def setUpClass(cls): cls.repo_server = HTTPService(os.path.join(cls.tc.td['WORKDIR'], 'oe-testimage-repo'), - cls.tc.target.server_ip) + '0.0.0.0', port=cls.tc.target.server_port, + logger=cls.tc.logger) cls.repo_server.start() @classmethod @@ -67,61 +68,54 @@ class DnfRepoTest(DnfTest): 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] - self.dnf(" ".join(cmdlinerepoopts) + " --nogpgcheck " + command) + output = self.dnf(" ".join(cmdlinerepoopts) + " --nogpgcheck " + command) + return output @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) - @OETestID(1744) 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']) - @OETestID(1746) def test_dnf_repoinfo(self): self.dnf_with_repo('repoinfo') @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache']) - @OETestID(1740) def test_dnf_install(self): - 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']) - @OETestID(1741) 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']) - @OETestID(1742) 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']) - @OETestID(1743) 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']) - @OETestID(1745) 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']) - @OETestID(1771) + @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 @@ -140,24 +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']) - @OETestID(1772) + @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) + 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("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) + 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 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) |