From 633bd85270922d71ab4b1f94cd166da51fbe1458 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 8 Nov 2018 19:55:17 +0000 Subject: 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 --- meta/lib/oeqa/runtime/cases/rpm.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'meta/lib/oeqa/runtime/cases/rpm.py') 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 class RpmBasicTest(OERuntimeTestCase): - @classmethod - def setUpClass(cls): - if cls.tc.td['PACKAGE_CLASSES'].split()[0] != 'package_rpm': - cls.skipTest('Tests require image to be build from rpm') - @OETestID(960) @OEHasPackage(['rpm']) @OETestDepends(['ssh.SSHTest.test_ssh']) @@ -26,6 +21,9 @@ class RpmBasicTest(OERuntimeTestCase): @OETestID(191) @OETestDepends(['rpm.RpmBasicTest.test_rpm_help']) def test_rpm_query(self): + status, output = self.target.run('ls /var/lib/rpm/') + if status != 0: + self.skipTest('No /var/lib/rpm on target') status, output = self.target.run('rpm -q rpm') msg = 'status and output: %s and %s' % (status, output) self.assertEqual(status, 0, msg=msg) @@ -34,30 +32,25 @@ class RpmInstallRemoveTest(OERuntimeTestCase): @classmethod def setUpClass(cls): - if cls.tc.td['PACKAGE_CLASSES'].split()[0] != 'package_rpm': - cls.skipTest('Tests require image to be build from rpm') - pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_') rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch) # Pick base-passwd-doc as a test file to get installed, because it's small # and it will always be built for standard targets rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch + if not os.path.exists(rpmdir): + return for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc): - test_file = os.path.join(rpmdir, f) - dst = '/tmp/base-passwd-doc.rpm' - cls.tc.target.copyTo(test_file, dst) - - @classmethod - def tearDownClass(cls): - dst = '/tmp/base-passwd-doc.rpm' - cls.tc.target.run('rm -f %s' % dst) + cls.test_file = os.path.join(rpmdir, f) + cls.dst = '/tmp/base-passwd-doc.rpm' @OETestID(192) - @OETestDepends(['rpm.RpmBasicTest.test_rpm_help']) + @OETestDepends(['rpm.RpmBasicTest.test_rpm_query']) def test_rpm_install(self): + self.tc.target.copyTo(self.test_file, self.dst) status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm') msg = 'Failed to install base-passwd-doc package: %s' % output self.assertEqual(status, 0, msg=msg) + self.tc.target.run('rm -f %s' % self.dst) @OETestID(194) @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install']) @@ -118,6 +111,8 @@ class RpmInstallRemoveTest(OERuntimeTestCase): msg = 'Failed to find database files under /var/lib/rpm/ as __db.xxx' self.assertEqual(0, status, msg=msg) + self.tc.target.copyTo(self.test_file, self.dst) + # Remove the package just in case self.target.run('rpm -e base-passwd-doc') @@ -131,6 +126,8 @@ class RpmInstallRemoveTest(OERuntimeTestCase): msg = 'Failed to remove base-passwd-doc package. Reason: {}'.format(output) self.assertEqual(0, status, msg=msg) + self.tc.target.run('rm -f %s' % self.dst) + # if using systemd this should ensure all entries are flushed to /var status, output = self.target.run("journalctl --sync") # Get the amount of entries in the log file -- cgit v1.2.3-54-g00ecf