summaryrefslogtreecommitdiffstats
path: root/meta
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
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')
-rw-r--r--meta/lib/oeqa/runtime/cases/date.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/df.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/opkg.py4
-rw-r--r--meta/lib/oeqa/runtime/cases/ptest.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/python.py8
-rw-r--r--meta/lib/oeqa/runtime/cases/rpm.py31
-rw-r--r--meta/lib/oeqa/runtime/cases/scp.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/ssh.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/stap.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/xorg.py2
10 files changed, 32 insertions, 25 deletions
diff --git a/meta/lib/oeqa/runtime/cases/date.py b/meta/lib/oeqa/runtime/cases/date.py
index ece7338de7..0887b831f4 100644
--- a/meta/lib/oeqa/runtime/cases/date.py
+++ b/meta/lib/oeqa/runtime/cases/date.py
@@ -3,6 +3,7 @@ import re
3from oeqa.runtime.case import OERuntimeTestCase 3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends 4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID 5from oeqa.core.decorator.oeid import OETestID
6from oeqa.runtime.decorator.package import OEHasPackage
6 7
7class DateTest(OERuntimeTestCase): 8class DateTest(OERuntimeTestCase):
8 9
@@ -18,6 +19,7 @@ class DateTest(OERuntimeTestCase):
18 19
19 @OETestID(211) 20 @OETestID(211)
20 @OETestDepends(['ssh.SSHTest.test_ssh']) 21 @OETestDepends(['ssh.SSHTest.test_ssh'])
22 @OEHasPackage(['coreutils', 'busybox'])
21 def test_date(self): 23 def test_date(self):
22 (status, output) = self.target.run('date +"%Y-%m-%d %T"') 24 (status, output) = self.target.run('date +"%Y-%m-%d %T"')
23 msg = 'Failed to get initial date, output: %s' % output 25 msg = 'Failed to get initial date, output: %s' % output
diff --git a/meta/lib/oeqa/runtime/cases/df.py b/meta/lib/oeqa/runtime/cases/df.py
index aecc32d7ce..e0b6bb839d 100644
--- a/meta/lib/oeqa/runtime/cases/df.py
+++ b/meta/lib/oeqa/runtime/cases/df.py
@@ -1,11 +1,13 @@
1from oeqa.runtime.case import OERuntimeTestCase 1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends 2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID 3from oeqa.core.decorator.oeid import OETestID
4from oeqa.runtime.decorator.package import OEHasPackage
4 5
5class DfTest(OERuntimeTestCase): 6class DfTest(OERuntimeTestCase):
6 7
7 @OETestID(234) 8 @OETestID(234)
8 @OETestDepends(['ssh.SSHTest.test_ssh']) 9 @OETestDepends(['ssh.SSHTest.test_ssh'])
10 @OEHasPackage(['coreutils', 'busybox'])
9 def test_df(self): 11 def test_df(self):
10 cmd = "df / | sed -n '2p' | awk '{print $4}'" 12 cmd = "df / | sed -n '2p' | awk '{print $4}'"
11 (status,output) = self.target.run(cmd) 13 (status,output) = self.target.run(cmd)
diff --git a/meta/lib/oeqa/runtime/cases/opkg.py b/meta/lib/oeqa/runtime/cases/opkg.py
index 50de8001c3..3be480a672 100644
--- a/meta/lib/oeqa/runtime/cases/opkg.py
+++ b/meta/lib/oeqa/runtime/cases/opkg.py
@@ -16,7 +16,7 @@ class OpkgTest(OERuntimeTestCase):
16class OpkgRepoTest(OpkgTest): 16class OpkgRepoTest(OpkgTest):
17 17
18 @classmethod 18 @classmethod
19 def setUpClass(cls): 19 def setUp(cls):
20 allarchfeed = 'all' 20 allarchfeed = 'all'
21 if cls.tc.td["MULTILIB_VARIANTS"]: 21 if cls.tc.td["MULTILIB_VARIANTS"]:
22 allarchfeed = cls.tc.td["TUNE_PKGARCH"] 22 allarchfeed = cls.tc.td["TUNE_PKGARCH"]
@@ -25,7 +25,7 @@ class OpkgRepoTest(OpkgTest):
25 cls.repo_server.start() 25 cls.repo_server.start()
26 26
27 @classmethod 27 @classmethod
28 def tearDownClass(cls): 28 def tearDown(cls):
29 cls.repo_server.stop() 29 cls.repo_server.stop()
30 30
31 def setup_source_config_for_package_install(self): 31 def setup_source_config_for_package_install(self):
diff --git a/meta/lib/oeqa/runtime/cases/ptest.py b/meta/lib/oeqa/runtime/cases/ptest.py
index 77ae7b6b86..0972a583ee 100644
--- a/meta/lib/oeqa/runtime/cases/ptest.py
+++ b/meta/lib/oeqa/runtime/cases/ptest.py
@@ -5,6 +5,7 @@ from oeqa.runtime.case import OERuntimeTestCase
5from oeqa.core.decorator.depends import OETestDepends 5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.core.decorator.oeid import OETestID 6from oeqa.core.decorator.oeid import OETestID
7from oeqa.core.decorator.data import skipIfNotFeature 7from oeqa.core.decorator.data import skipIfNotFeature
8from oeqa.runtime.decorator.package import OEHasPackage
8from oeqa.utils.logparser import Lparser, Result 9from oeqa.utils.logparser import Lparser, Result
9 10
10class PtestRunnerTest(OERuntimeTestCase): 11class PtestRunnerTest(OERuntimeTestCase):
@@ -52,6 +53,7 @@ class PtestRunnerTest(OERuntimeTestCase):
52 @OETestID(1600) 53 @OETestID(1600)
53 @skipIfNotFeature('ptest', 'Test requires ptest to be in DISTRO_FEATURES') 54 @skipIfNotFeature('ptest', 'Test requires ptest to be in DISTRO_FEATURES')
54 @OETestDepends(['ssh.SSHTest.test_ssh']) 55 @OETestDepends(['ssh.SSHTest.test_ssh'])
56 @OEHasPackage(['ptest-runner'])
55 @unittest.expectedFailure 57 @unittest.expectedFailure
56 def test_ptestrunner(self): 58 def test_ptestrunner(self):
57 status, output = self.target.run('which ptest-runner', 0) 59 status, output = self.target.run('which ptest-runner', 0)
diff --git a/meta/lib/oeqa/runtime/cases/python.py b/meta/lib/oeqa/runtime/cases/python.py
index 4419a9f639..66ab4d25f3 100644
--- a/meta/lib/oeqa/runtime/cases/python.py
+++ b/meta/lib/oeqa/runtime/cases/python.py
@@ -1,16 +1,12 @@
1from oeqa.runtime.case import OERuntimeTestCase 1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends 2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID 3from oeqa.core.decorator.oeid import OETestID
4from oeqa.runtime.decorator.package import OEHasPackage
4 5
5class PythonTest(OERuntimeTestCase): 6class PythonTest(OERuntimeTestCase):
6 @classmethod
7 def setUpClass(cls):
8 import unittest
9 if "python3-core" not in cls.tc.image_packages:
10 raise unittest.SkipTest("Python3 not on target")
11
12 @OETestID(965) 7 @OETestID(965)
13 @OETestDepends(['ssh.SSHTest.test_ssh']) 8 @OETestDepends(['ssh.SSHTest.test_ssh'])
9 @OEHasPackage(['python3-core'])
14 def test_python3(self): 10 def test_python3(self):
15 cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" 11 cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\""
16 status, output = self.target.run(cmd) 12 status, output = self.target.run(cmd)
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
diff --git a/meta/lib/oeqa/runtime/cases/scp.py b/meta/lib/oeqa/runtime/cases/scp.py
index f488a6175b..8f895da95a 100644
--- a/meta/lib/oeqa/runtime/cases/scp.py
+++ b/meta/lib/oeqa/runtime/cases/scp.py
@@ -4,6 +4,7 @@ from tempfile import mkstemp
4from oeqa.runtime.case import OERuntimeTestCase 4from oeqa.runtime.case import OERuntimeTestCase
5from oeqa.core.decorator.depends import OETestDepends 5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.core.decorator.oeid import OETestID 6from oeqa.core.decorator.oeid import OETestID
7from oeqa.runtime.decorator.package import OEHasPackage
7 8
8class ScpTest(OERuntimeTestCase): 9class ScpTest(OERuntimeTestCase):
9 10
@@ -20,6 +21,7 @@ class ScpTest(OERuntimeTestCase):
20 21
21 @OETestID(220) 22 @OETestID(220)
22 @OETestDepends(['ssh.SSHTest.test_ssh']) 23 @OETestDepends(['ssh.SSHTest.test_ssh'])
24 @OEHasPackage(['openssh-scp', 'dropbear'])
23 def test_scp_file(self): 25 def test_scp_file(self):
24 dst = '/tmp/test_scp_file' 26 dst = '/tmp/test_scp_file'
25 27
diff --git a/meta/lib/oeqa/runtime/cases/ssh.py b/meta/lib/oeqa/runtime/cases/ssh.py
index eca167969a..0b1ea7bcc2 100644
--- a/meta/lib/oeqa/runtime/cases/ssh.py
+++ b/meta/lib/oeqa/runtime/cases/ssh.py
@@ -1,11 +1,13 @@
1from oeqa.runtime.case import OERuntimeTestCase 1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends 2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID 3from oeqa.core.decorator.oeid import OETestID
4from oeqa.runtime.decorator.package import OEHasPackage
4 5
5class SSHTest(OERuntimeTestCase): 6class SSHTest(OERuntimeTestCase):
6 7
7 @OETestID(224) 8 @OETestID(224)
8 @OETestDepends(['ping.PingTest.test_ping']) 9 @OETestDepends(['ping.PingTest.test_ping'])
10 @OEHasPackage(['dropbear', 'openssh-sshd'])
9 def test_ssh(self): 11 def test_ssh(self):
10 (status, output) = self.target.run('uname -a') 12 (status, output) = self.target.run('uname -a')
11 self.assertEqual(status, 0, msg='SSH Test failed: %s' % output) 13 self.assertEqual(status, 0, msg='SSH Test failed: %s' % output)
diff --git a/meta/lib/oeqa/runtime/cases/stap.py b/meta/lib/oeqa/runtime/cases/stap.py
index 96e197a2d6..747c1d9517 100644
--- a/meta/lib/oeqa/runtime/cases/stap.py
+++ b/meta/lib/oeqa/runtime/cases/stap.py
@@ -4,6 +4,7 @@ from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends 4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID 5from oeqa.core.decorator.oeid import OETestID
6from oeqa.core.decorator.data import skipIfNotFeature 6from oeqa.core.decorator.data import skipIfNotFeature
7from oeqa.runtime.decorator.package import OEHasPackage
7 8
8class StapTest(OERuntimeTestCase): 9class StapTest(OERuntimeTestCase):
9 10
@@ -22,6 +23,7 @@ class StapTest(OERuntimeTestCase):
22 @skipIfNotFeature('tools-profile', 23 @skipIfNotFeature('tools-profile',
23 'Test requires tools-profile to be in IMAGE_FEATURES') 24 'Test requires tools-profile to be in IMAGE_FEATURES')
24 @OETestDepends(['kernelmodule.KernelModuleTest.test_kernel_module']) 25 @OETestDepends(['kernelmodule.KernelModuleTest.test_kernel_module'])
26 @OEHasPackage(['systemtap'])
25 def test_stap(self): 27 def test_stap(self):
26 cmds = [ 28 cmds = [
27 'cd /usr/src/kernel && make scripts prepare', 29 'cd /usr/src/kernel && make scripts prepare',
diff --git a/meta/lib/oeqa/runtime/cases/xorg.py b/meta/lib/oeqa/runtime/cases/xorg.py
index 2124813e3c..82521c69ac 100644
--- a/meta/lib/oeqa/runtime/cases/xorg.py
+++ b/meta/lib/oeqa/runtime/cases/xorg.py
@@ -2,6 +2,7 @@ from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends 2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID 3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfNotFeature 4from oeqa.core.decorator.data import skipIfNotFeature
5from oeqa.runtime.decorator.package import OEHasPackage
5 6
6class XorgTest(OERuntimeTestCase): 7class XorgTest(OERuntimeTestCase):
7 8
@@ -9,6 +10,7 @@ class XorgTest(OERuntimeTestCase):
9 @skipIfNotFeature('x11-base', 10 @skipIfNotFeature('x11-base',
10 'Test requires x11 to be in IMAGE_FEATURES') 11 'Test requires x11 to be in IMAGE_FEATURES')
11 @OETestDepends(['ssh.SSHTest.test_ssh']) 12 @OETestDepends(['ssh.SSHTest.test_ssh'])
13 @OEHasPackage(['xserver-nodm-init'])
12 def test_xorg_running(self): 14 def test_xorg_running(self):
13 cmd ='%s | grep -v xinit | grep [X]org' % self.tc.target_cmds['ps'] 15 cmd ='%s | grep -v xinit | grep [X]org' % self.tc.target_cmds['ps']
14 status, output = self.target.run(cmd) 16 status, output = self.target.run(cmd)