diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2024-01-26 14:34:54 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-27 08:20:02 +0000 |
commit | 482ed7cd8035233dbe5aa6db1e606fa4b3f03948 (patch) | |
tree | f4a27833394a55c4c32b84758764b9c97faf8c89 /meta/lib/oeqa/runtime | |
parent | 683c839c457673a0c455bd224181f3a3953ef617 (diff) | |
download | poky-482ed7cd8035233dbe5aa6db1e606fa4b3f03948.tar.gz |
oeqa/runtime/rpm: fail tests if test rpm file cannot be found
Discovery of the test file was happening in a class initializer.
That block of code cannot fail (it's not a test), and so it
falls through to completion even if the needed file could not be found.
Then the tests themselves fail later due to class variables not
being set, but all information as to why is already lost at that point.
This converts the discovery to a helper function called from
the tests, so that the function can fail the tests precisely when the
problems occur.
(From OE-Core rev: 5d7a6ede105ea1efc9c324c7029f9d08dadf7255)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/rpm.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py index a4ba4e6769..ea5619ffea 100644 --- a/meta/lib/oeqa/runtime/cases/rpm.py +++ b/meta/lib/oeqa/runtime/cases/rpm.py | |||
@@ -80,21 +80,24 @@ class RpmBasicTest(OERuntimeTestCase): | |||
80 | 80 | ||
81 | class RpmInstallRemoveTest(OERuntimeTestCase): | 81 | class RpmInstallRemoveTest(OERuntimeTestCase): |
82 | 82 | ||
83 | @classmethod | 83 | def _find_test_file(self): |
84 | def setUpClass(cls): | 84 | pkgarch = self.td['TUNE_PKGARCH'].replace('-', '_') |
85 | pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_') | 85 | rpmdir = os.path.join(self.tc.td['DEPLOY_DIR'], 'rpm', pkgarch) |
86 | rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch) | ||
87 | # 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 |
88 | # and it will always be built for standard targets | 87 | # and it will always be built for standard targets |
89 | rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch | 88 | rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch |
90 | if not os.path.exists(rpmdir): | 89 | if not os.path.exists(rpmdir): |
91 | return | 90 | self.fail("Rpm directory {} does not exist".format(rpmdir)) |
92 | for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc): | 91 | for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc): |
93 | cls.test_file = os.path.join(rpmdir, f) | 92 | self.test_file = os.path.join(rpmdir, f) |
94 | 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' | ||
95 | 97 | ||
96 | @OETestDepends(['rpm.RpmBasicTest.test_rpm_query']) | 98 | @OETestDepends(['rpm.RpmBasicTest.test_rpm_query']) |
97 | def test_rpm_install(self): | 99 | def test_rpm_install(self): |
100 | self._find_test_file() | ||
98 | self.tc.target.copyTo(self.test_file, self.dst) | 101 | self.tc.target.copyTo(self.test_file, self.dst) |
99 | 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') |
100 | msg = 'Failed to install base-passwd-doc package: %s' % output | 103 | msg = 'Failed to install base-passwd-doc package: %s' % output |
@@ -117,6 +120,7 @@ class RpmInstallRemoveTest(OERuntimeTestCase): | |||
117 | Author: Alexander Kanavin <alex.kanavin@gmail.com> | 120 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
118 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> | 121 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> |
119 | """ | 122 | """ |
123 | self._find_test_file() | ||
120 | db_files_cmd = 'ls /var/lib/rpm/rpmdb.sqlite*' | 124 | db_files_cmd = 'ls /var/lib/rpm/rpmdb.sqlite*' |
121 | check_log_cmd = "grep RPM /var/log/messages | wc -l" | 125 | check_log_cmd = "grep RPM /var/log/messages | wc -l" |
122 | 126 | ||