diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/rpm.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/rpm.py | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py index 8e18b426f8..ea5619ffea 100644 --- a/meta/lib/oeqa/runtime/cases/rpm.py +++ b/meta/lib/oeqa/runtime/cases/rpm.py | |||
@@ -1,4 +1,6 @@ | |||
1 | # | 1 | # |
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
2 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
3 | # | 5 | # |
4 | 6 | ||
@@ -49,21 +51,20 @@ class RpmBasicTest(OERuntimeTestCase): | |||
49 | msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output) | 51 | msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output) |
50 | self.assertEqual(status, 0, msg=msg) | 52 | self.assertEqual(status, 0, msg=msg) |
51 | 53 | ||
52 | def check_no_process_for_user(u): | 54 | def wait_for_no_process_for_user(u, timeout = 120): |
53 | _, output = self.target.run(self.tc.target_cmds['ps']) | 55 | timeout_at = time.time() + timeout |
54 | if u + ' ' in output: | 56 | while time.time() < timeout_at: |
55 | return False | 57 | _, output = self.target.run(self.tc.target_cmds['ps']) |
56 | else: | 58 | if u + ' ' not in output: |
57 | return True | 59 | return |
60 | time.sleep(1) | ||
61 | user_pss = [ps for ps in output.split("\n") if u + ' ' in ps] | ||
62 | msg = "User %s has processes still running: %s" % (u, "\n".join(user_pss)) | ||
63 | self.fail(msg=msg) | ||
58 | 64 | ||
59 | def unset_up_test_user(u): | 65 | def unset_up_test_user(u): |
60 | # ensure no test1 process in running | 66 | # ensure no test1 process in running |
61 | timeout = time.time() + 30 | 67 | wait_for_no_process_for_user(u) |
62 | while time.time() < timeout: | ||
63 | if check_no_process_for_user(u): | ||
64 | break | ||
65 | else: | ||
66 | time.sleep(1) | ||
67 | status, output = self.target.run('userdel -r %s' % u) | 68 | status, output = self.target.run('userdel -r %s' % u) |
68 | msg = 'Failed to erase user: %s' % output | 69 | msg = 'Failed to erase user: %s' % output |
69 | self.assertTrue(status == 0, msg=msg) | 70 | self.assertTrue(status == 0, msg=msg) |
@@ -79,21 +80,24 @@ class RpmBasicTest(OERuntimeTestCase): | |||
79 | 80 | ||
80 | class RpmInstallRemoveTest(OERuntimeTestCase): | 81 | class RpmInstallRemoveTest(OERuntimeTestCase): |
81 | 82 | ||
82 | @classmethod | 83 | def _find_test_file(self): |
83 | def setUpClass(cls): | 84 | pkgarch = self.td['TUNE_PKGARCH'].replace('-', '_') |
84 | pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_') | 85 | rpmdir = os.path.join(self.tc.td['DEPLOY_DIR'], 'rpm', pkgarch) |
85 | rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch) | ||
86 | # Pick base-passwd-doc as a test file to get installed, because it's small | 86 | # Pick base-passwd-doc as a test file to get installed, because it's small |
87 | # and it will always be built for standard targets | 87 | # and it will always be built for standard targets |
88 | rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch | 88 | rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch |
89 | if not os.path.exists(rpmdir): | 89 | if not os.path.exists(rpmdir): |
90 | return | 90 | self.fail("Rpm directory {} does not exist".format(rpmdir)) |
91 | for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc): | 91 | for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc): |
92 | cls.test_file = os.path.join(rpmdir, f) | 92 | self.test_file = os.path.join(rpmdir, f) |
93 | cls.dst = '/tmp/base-passwd-doc.rpm' | 93 | break |
94 | else: | ||
95 | self.fail("Couldn't find the test rpm file {} in {}".format(rpm_doc, rpmdir)) | ||
96 | self.dst = '/tmp/base-passwd-doc.rpm' | ||
94 | 97 | ||
95 | @OETestDepends(['rpm.RpmBasicTest.test_rpm_query']) | 98 | @OETestDepends(['rpm.RpmBasicTest.test_rpm_query']) |
96 | def test_rpm_install(self): | 99 | def test_rpm_install(self): |
100 | self._find_test_file() | ||
97 | self.tc.target.copyTo(self.test_file, self.dst) | 101 | self.tc.target.copyTo(self.test_file, self.dst) |
98 | status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm') | 102 | status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm') |
99 | msg = 'Failed to install base-passwd-doc package: %s' % output | 103 | msg = 'Failed to install base-passwd-doc package: %s' % output |
@@ -116,12 +120,13 @@ class RpmInstallRemoveTest(OERuntimeTestCase): | |||
116 | Author: Alexander Kanavin <alex.kanavin@gmail.com> | 120 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
117 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> | 121 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> |
118 | """ | 122 | """ |
119 | db_files_cmd = 'ls /var/lib/rpm/__db.*' | 123 | self._find_test_file() |
124 | db_files_cmd = 'ls /var/lib/rpm/rpmdb.sqlite*' | ||
120 | check_log_cmd = "grep RPM /var/log/messages | wc -l" | 125 | check_log_cmd = "grep RPM /var/log/messages | wc -l" |
121 | 126 | ||
122 | # Make sure that some database files are under /var/lib/rpm as '__db.xxx' | 127 | # Make sure that some database files are under /var/lib/rpm as 'rpmdb.sqlite' |
123 | status, output = self.target.run(db_files_cmd) | 128 | status, output = self.target.run(db_files_cmd) |
124 | msg = 'Failed to find database files under /var/lib/rpm/ as __db.xxx' | 129 | msg = 'Failed to find database files under /var/lib/rpm/ as rpmdb.sqlite' |
125 | self.assertEqual(0, status, msg=msg) | 130 | self.assertEqual(0, status, msg=msg) |
126 | 131 | ||
127 | self.tc.target.copyTo(self.test_file, self.dst) | 132 | self.tc.target.copyTo(self.test_file, self.dst) |
@@ -141,13 +146,4 @@ class RpmInstallRemoveTest(OERuntimeTestCase): | |||
141 | 146 | ||
142 | self.tc.target.run('rm -f %s' % self.dst) | 147 | self.tc.target.run('rm -f %s' % self.dst) |
143 | 148 | ||
144 | # if using systemd this should ensure all entries are flushed to /var | ||
145 | status, output = self.target.run("journalctl --sync") | ||
146 | # Get the amount of entries in the log file | ||
147 | status, output = self.target.run(check_log_cmd) | ||
148 | msg = 'Failed to get the final size of the log file.' | ||
149 | self.assertEqual(0, status, msg=msg) | ||
150 | 149 | ||
151 | # Check that there's enough of them | ||
152 | self.assertGreaterEqual(int(output), 80, | ||
153 | 'Cound not find sufficient amount of rpm entries in /var/log/messages, found {} entries'.format(output)) | ||