diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-05-18 16:15:06 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-20 21:41:04 +0100 |
commit | c63adf5c5b4b5984c315e914a7d3cb4b51040602 (patch) | |
tree | baaaf2636032f12b03b0f7acc004459161761641 /meta | |
parent | 2298b4a03e03586d61309300e975421baca1537c (diff) | |
download | poky-c63adf5c5b4b5984c315e914a7d3cb4b51040602.tar.gz |
oe-selftest: move recipetool tests to their own module
These tests really belong in their own module; if we refactor
out a base class from DevtoolTests with shared functions then we can
move them out easily. Also create temp directory in setupLocal() so we
don't have to do that in individual tests anymore.
(From OE-Core rev: 2f88f6e7b2e54b13376338354aae1d61c0c0db60)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 81 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/recipetool.py | 55 |
2 files changed, 77 insertions, 59 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 1d16113343..f4571c4ef1 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py | |||
@@ -11,29 +11,7 @@ from oeqa.selftest.base import oeSelfTest | |||
11 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | 11 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var |
12 | from oeqa.utils.decorators import testcase | 12 | from oeqa.utils.decorators import testcase |
13 | 13 | ||
14 | class DevtoolTests(oeSelfTest): | 14 | class DevtoolBase(oeSelfTest): |
15 | |||
16 | def test_create_workspace(self): | ||
17 | # Check preconditions | ||
18 | workspacedir = os.path.join(self.builddir, 'workspace') | ||
19 | self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory') | ||
20 | result = runCmd('bitbake-layers show-layers') | ||
21 | self.assertTrue('/workspace' not in result.output, 'This test cannot be run with a workspace layer in bblayers.conf') | ||
22 | # Try creating a workspace layer with a specific path | ||
23 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
24 | self.track_for_cleanup(tempdir) | ||
25 | result = runCmd('devtool create-workspace %s' % tempdir) | ||
26 | self.assertTrue(os.path.isfile(os.path.join(tempdir, 'conf', 'layer.conf'))) | ||
27 | result = runCmd('bitbake-layers show-layers') | ||
28 | self.assertIn(tempdir, result.output) | ||
29 | # Try creating a workspace layer with the default path | ||
30 | self.track_for_cleanup(workspacedir) | ||
31 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
32 | result = runCmd('devtool create-workspace') | ||
33 | self.assertTrue(os.path.isfile(os.path.join(workspacedir, 'conf', 'layer.conf'))) | ||
34 | result = runCmd('bitbake-layers show-layers') | ||
35 | self.assertNotIn(tempdir, result.output) | ||
36 | self.assertIn(workspacedir, result.output) | ||
37 | 15 | ||
38 | def _test_recipe_contents(self, recipefile, checkvars, checkinherits): | 16 | def _test_recipe_contents(self, recipefile, checkvars, checkinherits): |
39 | with open(recipefile, 'r') as f: | 17 | with open(recipefile, 'r') as f: |
@@ -53,45 +31,30 @@ class DevtoolTests(oeSelfTest): | |||
53 | for inherit in checkinherits: | 31 | for inherit in checkinherits: |
54 | self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit) | 32 | self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit) |
55 | 33 | ||
56 | def test_recipetool_create(self): | ||
57 | # Try adding a recipe | ||
58 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
59 | self.track_for_cleanup(tempdir) | ||
60 | tempsrc = os.path.join(tempdir, 'srctree') | ||
61 | os.makedirs(tempsrc) | ||
62 | recipefile = os.path.join(tempdir, 'logrotate_3.8.7.bb') | ||
63 | srcuri = 'https://fedorahosted.org/releases/l/o/logrotate/logrotate-3.8.7.tar.gz' | ||
64 | result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc)) | ||
65 | self.assertTrue(os.path.isfile(recipefile)) | ||
66 | checkvars = {} | ||
67 | checkvars['LICENSE'] = 'GPLv2' | ||
68 | checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=18810669f13b87348459e611d31ab760' | ||
69 | checkvars['SRC_URI'] = 'https://fedorahosted.org/releases/l/o/logrotate/logrotate-${PV}.tar.gz' | ||
70 | checkvars['SRC_URI[md5sum]'] = '99e08503ef24c3e2e3ff74cc5f3be213' | ||
71 | checkvars['SRC_URI[sha256sum]'] = 'f6ba691f40e30e640efa2752c1f9499a3f9738257660994de70a45fe00d12b64' | ||
72 | self._test_recipe_contents(recipefile, checkvars, []) | ||
73 | 34 | ||
74 | def test_recipetool_create_git(self): | 35 | class DevtoolTests(DevtoolBase): |
75 | # Ensure we have the right data in shlibs/pkgdata | 36 | |
76 | bitbake('libpng pango libx11 libxext jpeg') | 37 | def test_create_workspace(self): |
77 | # Try adding a recipe | 38 | # Check preconditions |
39 | workspacedir = os.path.join(self.builddir, 'workspace') | ||
40 | self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory') | ||
41 | result = runCmd('bitbake-layers show-layers') | ||
42 | self.assertTrue('/workspace' not in result.output, 'This test cannot be run with a workspace layer in bblayers.conf') | ||
43 | # Try creating a workspace layer with a specific path | ||
78 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | 44 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') |
79 | self.track_for_cleanup(tempdir) | 45 | self.track_for_cleanup(tempdir) |
80 | tempsrc = os.path.join(tempdir, 'srctree') | 46 | result = runCmd('devtool create-workspace %s' % tempdir) |
81 | os.makedirs(tempsrc) | 47 | self.assertTrue(os.path.isfile(os.path.join(tempdir, 'conf', 'layer.conf'))) |
82 | recipefile = os.path.join(tempdir, 'libmatchbox.bb') | 48 | result = runCmd('bitbake-layers show-layers') |
83 | srcuri = 'git://git.yoctoproject.org/libmatchbox' | 49 | self.assertIn(tempdir, result.output) |
84 | result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc)) | 50 | # Try creating a workspace layer with the default path |
85 | self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output) | 51 | self.track_for_cleanup(workspacedir) |
86 | checkvars = {} | 52 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') |
87 | checkvars['LICENSE'] = 'LGPLv2.1' | 53 | result = runCmd('devtool create-workspace') |
88 | checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34' | 54 | self.assertTrue(os.path.isfile(os.path.join(workspacedir, 'conf', 'layer.conf'))) |
89 | checkvars['S'] = '${WORKDIR}/git' | 55 | result = runCmd('bitbake-layers show-layers') |
90 | checkvars['PV'] = '1.0+git${SRCPV}' | 56 | self.assertNotIn(tempdir, result.output) |
91 | checkvars['SRC_URI'] = srcuri | 57 | self.assertIn(workspacedir, result.output) |
92 | checkvars['DEPENDS'] = 'libpng pango libx11 libxext jpeg' | ||
93 | inherits = ['autotools', 'pkgconfig'] | ||
94 | self._test_recipe_contents(recipefile, checkvars, inherits) | ||
95 | 58 | ||
96 | def test_devtool_add(self): | 59 | def test_devtool_add(self): |
97 | # Check preconditions | 60 | # Check preconditions |
diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py new file mode 100644 index 0000000000..832fb7b16a --- /dev/null +++ b/meta/lib/oeqa/selftest/recipetool.py | |||
@@ -0,0 +1,55 @@ | |||
1 | import unittest | ||
2 | import os | ||
3 | import logging | ||
4 | import re | ||
5 | import tempfile | ||
6 | |||
7 | import oeqa.utils.ftools as ftools | ||
8 | from oeqa.selftest.base import oeSelfTest | ||
9 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | ||
10 | from oeqa.utils.decorators import testcase | ||
11 | from oeqa.selftest.devtool import DevtoolBase | ||
12 | |||
13 | |||
14 | class RecipetoolTests(DevtoolBase): | ||
15 | |||
16 | def setUpLocal(self): | ||
17 | self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa') | ||
18 | self.track_for_cleanup(self.tempdir) | ||
19 | |||
20 | def test_recipetool_create(self): | ||
21 | # Try adding a recipe | ||
22 | tempsrc = os.path.join(self.tempdir, 'srctree') | ||
23 | os.makedirs(tempsrc) | ||
24 | recipefile = os.path.join(self.tempdir, 'logrotate_3.8.7.bb') | ||
25 | srcuri = 'https://fedorahosted.org/releases/l/o/logrotate/logrotate-3.8.7.tar.gz' | ||
26 | result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc)) | ||
27 | self.assertTrue(os.path.isfile(recipefile)) | ||
28 | checkvars = {} | ||
29 | checkvars['LICENSE'] = 'GPLv2' | ||
30 | checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=18810669f13b87348459e611d31ab760' | ||
31 | checkvars['SRC_URI'] = 'https://fedorahosted.org/releases/l/o/logrotate/logrotate-${PV}.tar.gz' | ||
32 | checkvars['SRC_URI[md5sum]'] = '99e08503ef24c3e2e3ff74cc5f3be213' | ||
33 | checkvars['SRC_URI[sha256sum]'] = 'f6ba691f40e30e640efa2752c1f9499a3f9738257660994de70a45fe00d12b64' | ||
34 | self._test_recipe_contents(recipefile, checkvars, []) | ||
35 | |||
36 | def test_recipetool_create_git(self): | ||
37 | # Ensure we have the right data in shlibs/pkgdata | ||
38 | bitbake('libpng pango libx11 libxext jpeg') | ||
39 | # Try adding a recipe | ||
40 | tempsrc = os.path.join(self.tempdir, 'srctree') | ||
41 | os.makedirs(tempsrc) | ||
42 | recipefile = os.path.join(self.tempdir, 'libmatchbox.bb') | ||
43 | srcuri = 'git://git.yoctoproject.org/libmatchbox' | ||
44 | result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc)) | ||
45 | self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output) | ||
46 | checkvars = {} | ||
47 | checkvars['LICENSE'] = 'LGPLv2.1' | ||
48 | checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34' | ||
49 | checkvars['S'] = '${WORKDIR}/git' | ||
50 | checkvars['PV'] = '1.0+git${SRCPV}' | ||
51 | checkvars['SRC_URI'] = srcuri | ||
52 | checkvars['DEPENDS'] = 'libpng pango libx11 libxext jpeg' | ||
53 | inherits = ['autotools', 'pkgconfig'] | ||
54 | self._test_recipe_contents(recipefile, checkvars, inherits) | ||
55 | |||