summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/cases/rpm.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-08 19:55:17 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-14 11:14:40 +0000
commit633bd85270922d71ab4b1f94cd166da51fbe1458 (patch)
tree65decddaa53d8f7415a6078fe82cf052f2f5c417 /meta/lib/oeqa/runtime/cases/rpm.py
parent4c034810e5ca6d8be5af9afc9172ac53cf12bf08 (diff)
downloadpoky-633bd85270922d71ab4b1f94cd166da51fbe1458.tar.gz
oeqa/runtime/cases: Improve test dependency information
Add the OEHasPackage decorator to a variety of tests so they determine automatically if they should run against a given image. To ensure tests can do this we need to move target operations such as scp commands into the tests and out of the class startup/teardown. (From OE-Core rev: 60d6580b85714b8960a964e775d76a7f937f5e5a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/rpm.py')
-rw-r--r--meta/lib/oeqa/runtime/cases/rpm.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py
index 1e5e4631d3..de92157c52 100644
--- a/meta/lib/oeqa/runtime/cases/rpm.py
+++ b/meta/lib/oeqa/runtime/cases/rpm.py
@@ -10,11 +10,6 @@ from oeqa.core.utils.path import findFile
10 10
11class RpmBasicTest(OERuntimeTestCase): 11class RpmBasicTest(OERuntimeTestCase):
12 12
13 @classmethod
14 def setUpClass(cls):
15 if cls.tc.td['PACKAGE_CLASSES'].split()[0] != 'package_rpm':
16 cls.skipTest('Tests require image to be build from rpm')
17
18 @OETestID(960) 13 @OETestID(960)
19 @OEHasPackage(['rpm']) 14 @OEHasPackage(['rpm'])
20 @OETestDepends(['ssh.SSHTest.test_ssh']) 15 @OETestDepends(['ssh.SSHTest.test_ssh'])
@@ -26,6 +21,9 @@ class RpmBasicTest(OERuntimeTestCase):
26 @OETestID(191) 21 @OETestID(191)
27 @OETestDepends(['rpm.RpmBasicTest.test_rpm_help']) 22 @OETestDepends(['rpm.RpmBasicTest.test_rpm_help'])
28 def test_rpm_query(self): 23 def test_rpm_query(self):
24 status, output = self.target.run('ls /var/lib/rpm/')
25 if status != 0:
26 self.skipTest('No /var/lib/rpm on target')
29 status, output = self.target.run('rpm -q rpm') 27 status, output = self.target.run('rpm -q rpm')
30 msg = 'status and output: %s and %s' % (status, output) 28 msg = 'status and output: %s and %s' % (status, output)
31 self.assertEqual(status, 0, msg=msg) 29 self.assertEqual(status, 0, msg=msg)
@@ -34,30 +32,25 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
34 32
35 @classmethod 33 @classmethod
36 def setUpClass(cls): 34 def setUpClass(cls):
37 if cls.tc.td['PACKAGE_CLASSES'].split()[0] != 'package_rpm':
38 cls.skipTest('Tests require image to be build from rpm')
39
40 pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_') 35 pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_')
41 rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch) 36 rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch)
42 # Pick base-passwd-doc as a test file to get installed, because it's small 37 # Pick base-passwd-doc as a test file to get installed, because it's small
43 # and it will always be built for standard targets 38 # and it will always be built for standard targets
44 rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch 39 rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch
40 if not os.path.exists(rpmdir):
41 return
45 for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc): 42 for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc):
46 test_file = os.path.join(rpmdir, f) 43 cls.test_file = os.path.join(rpmdir, f)
47 dst = '/tmp/base-passwd-doc.rpm' 44 cls.dst = '/tmp/base-passwd-doc.rpm'
48 cls.tc.target.copyTo(test_file, dst)
49
50 @classmethod
51 def tearDownClass(cls):
52 dst = '/tmp/base-passwd-doc.rpm'
53 cls.tc.target.run('rm -f %s' % dst)
54 45
55 @OETestID(192) 46 @OETestID(192)
56 @OETestDepends(['rpm.RpmBasicTest.test_rpm_help']) 47 @OETestDepends(['rpm.RpmBasicTest.test_rpm_query'])
57 def test_rpm_install(self): 48 def test_rpm_install(self):
49 self.tc.target.copyTo(self.test_file, self.dst)
58 status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm') 50 status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm')
59 msg = 'Failed to install base-passwd-doc package: %s' % output 51 msg = 'Failed to install base-passwd-doc package: %s' % output
60 self.assertEqual(status, 0, msg=msg) 52 self.assertEqual(status, 0, msg=msg)
53 self.tc.target.run('rm -f %s' % self.dst)
61 54
62 @OETestID(194) 55 @OETestID(194)
63 @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install']) 56 @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install'])
@@ -118,6 +111,8 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
118 msg = 'Failed to find database files under /var/lib/rpm/ as __db.xxx' 111 msg = 'Failed to find database files under /var/lib/rpm/ as __db.xxx'
119 self.assertEqual(0, status, msg=msg) 112 self.assertEqual(0, status, msg=msg)
120 113
114 self.tc.target.copyTo(self.test_file, self.dst)
115
121 # Remove the package just in case 116 # Remove the package just in case
122 self.target.run('rpm -e base-passwd-doc') 117 self.target.run('rpm -e base-passwd-doc')
123 118
@@ -131,6 +126,8 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
131 msg = 'Failed to remove base-passwd-doc package. Reason: {}'.format(output) 126 msg = 'Failed to remove base-passwd-doc package. Reason: {}'.format(output)
132 self.assertEqual(0, status, msg=msg) 127 self.assertEqual(0, status, msg=msg)
133 128
129 self.tc.target.run('rm -f %s' % self.dst)
130
134 # if using systemd this should ensure all entries are flushed to /var 131 # if using systemd this should ensure all entries are flushed to /var
135 status, output = self.target.run("journalctl --sync") 132 status, output = self.target.run("journalctl --sync")
136 # Get the amount of entries in the log file 133 # Get the amount of entries in the log file