diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/dnf.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/dnf.py | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/dnf.py b/meta/lib/oeqa/runtime/cases/dnf.py new file mode 100644 index 0000000000..77e7eb9450 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/dnf.py | |||
@@ -0,0 +1,111 @@ | |||
1 | import os | ||
2 | import re | ||
3 | import subprocess | ||
4 | from oeqa.utils.httpserver import HTTPService | ||
5 | |||
6 | from oeqa.runtime.case import OERuntimeTestCase | ||
7 | from oeqa.core.decorator.depends import OETestDepends | ||
8 | from oeqa.core.decorator.oeid import OETestID | ||
9 | from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature | ||
10 | from oeqa.runtime.decorator.package import OEHasPackage | ||
11 | |||
12 | class DnfTest(OERuntimeTestCase): | ||
13 | |||
14 | def dnf(self, command, expected = 0): | ||
15 | command = 'dnf-2 %s' % command | ||
16 | status, output = self.target.run(command, 1500) | ||
17 | message = os.linesep.join([command, output]) | ||
18 | self.assertEqual(status, expected, message) | ||
19 | return output | ||
20 | |||
21 | class DnfBasicTest(DnfTest): | ||
22 | |||
23 | @skipIfNotFeature('package-management', | ||
24 | 'Test requires package-management to be in IMAGE_FEATURES') | ||
25 | @skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm', | ||
26 | 'RPM is not the primary package manager') | ||
27 | @OEHasPackage(['dnf']) | ||
28 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
29 | def test_dnf_help(self): | ||
30 | self.dnf('--help') | ||
31 | |||
32 | @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) | ||
33 | def test_dnf_version(self): | ||
34 | self.dnf('--version') | ||
35 | |||
36 | @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) | ||
37 | def test_dnf_info(self): | ||
38 | self.dnf('info dnf') | ||
39 | |||
40 | @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) | ||
41 | def test_dnf_search(self): | ||
42 | self.dnf('search dnf') | ||
43 | |||
44 | @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) | ||
45 | def test_dnf_history(self): | ||
46 | self.dnf('history') | ||
47 | |||
48 | class DnfRepoTest(DnfTest): | ||
49 | |||
50 | @classmethod | ||
51 | def setUpClass(cls): | ||
52 | cls.repo_server = HTTPService(os.path.join(cls.tc.td['WORKDIR'], 'oe-testimage-repo'), | ||
53 | cls.tc.target.server_ip) | ||
54 | cls.repo_server.start() | ||
55 | |||
56 | @classmethod | ||
57 | def tearDownClass(cls): | ||
58 | cls.repo_server.stop() | ||
59 | |||
60 | def dnf_with_repo(self, command): | ||
61 | pkgarchs = os.listdir(os.path.join(self.tc.td['WORKDIR'], 'oe-testimage-repo')) | ||
62 | deploy_url = 'http://%s:%s/' %(self.target.server_ip, self.repo_server.port) | ||
63 | cmdlinerepoopts = ["--repofrompath=oe-testimage-repo-%s,%s%s" %(arch, deploy_url, arch) for arch in pkgarchs] | ||
64 | |||
65 | self.dnf(" ".join(cmdlinerepoopts) + " --nogpgcheck " + command) | ||
66 | |||
67 | @OETestDepends(['dnf.DnfBasicTest.test_dnf_help']) | ||
68 | def test_dnf_makecache(self): | ||
69 | self.dnf_with_repo('makecache') | ||
70 | |||
71 | |||
72 | # Does not work when repo is specified on the command line | ||
73 | # @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache']) | ||
74 | # def test_dnf_repolist(self): | ||
75 | # self.dnf_with_repo('repolist') | ||
76 | |||
77 | @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache']) | ||
78 | def test_dnf_repoinfo(self): | ||
79 | self.dnf_with_repo('repoinfo') | ||
80 | |||
81 | @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache']) | ||
82 | def test_dnf_install(self): | ||
83 | self.dnf_with_repo('install -y run-postinsts-dev') | ||
84 | |||
85 | @OETestDepends(['dnf.DnfRepoTest.test_dnf_install']) | ||
86 | def test_dnf_install_dependency(self): | ||
87 | self.dnf_with_repo('remove -y run-postinsts') | ||
88 | self.dnf_with_repo('install -y run-postinsts-dev') | ||
89 | |||
90 | @OETestDepends(['dnf.DnfRepoTest.test_dnf_install_dependency']) | ||
91 | def test_dnf_install_from_disk(self): | ||
92 | self.dnf_with_repo('remove -y run-postinsts-dev') | ||
93 | self.dnf_with_repo('install -y --downloadonly run-postinsts-dev') | ||
94 | status, output = self.target.run('find /var/cache/dnf -name run-postinsts-dev*rpm', 1500) | ||
95 | self.assertEqual(status, 0, output) | ||
96 | self.dnf_with_repo('install -y %s' % output) | ||
97 | |||
98 | @OETestDepends(['dnf.DnfRepoTest.test_dnf_install_from_disk']) | ||
99 | def test_dnf_install_from_http(self): | ||
100 | output = subprocess.check_output('%s %s -name run-postinsts-dev*' % (bb.utils.which(os.getenv('PATH'), "find"), | ||
101 | self.tc.td['DEPLOY_DIR_RPM']), shell=True).decode("utf-8") | ||
102 | rpm_path = output.split("/")[-2] + "/" + output.split("/")[-1] | ||
103 | url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, rpm_path) | ||
104 | self.dnf_with_repo('remove -y run-postinsts-dev') | ||
105 | self.dnf_with_repo('install -y %s' % url) | ||
106 | |||
107 | @OETestDepends(['dnf.DnfRepoTest.test_dnf_install']) | ||
108 | def test_dnf_reinstall(self): | ||
109 | self.dnf_with_repo('reinstall -y run-postinsts-dev') | ||
110 | |||
111 | |||