summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/cases/dnf.py
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2017-01-30 20:03:53 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-14 14:42:17 +0000
commitea4bac7e45188cd35f2c88cd0021fc8cfb8b3642 (patch)
tree93f1a0b32707b98e4bcb12bd69c27d3a2bbb6729 /meta/lib/oeqa/runtime/cases/dnf.py
parentdfa298762350289772ef6841d8660912ad00a245 (diff)
downloadpoky-ea4bac7e45188cd35f2c88cd0021fc8cfb8b3642.tar.gz
testimage.bbclass: fix runtime test for rpm, port smart tests to dnf
(From OE-Core rev: 749a496d273f9fd378588e309cf976294584ca5f) Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/dnf.py')
-rw-r--r--meta/lib/oeqa/runtime/cases/dnf.py111
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 @@
1import os
2import re
3import subprocess
4from oeqa.utils.httpserver import HTTPService
5
6from oeqa.runtime.case import OERuntimeTestCase
7from oeqa.core.decorator.depends import OETestDepends
8from oeqa.core.decorator.oeid import OETestID
9from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
10from oeqa.runtime.decorator.package import OEHasPackage
11
12class 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
21class 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
48class 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