summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-04-28 17:49:55 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-01 17:08:50 +0100
commit1643a7f3bce713e2ab2f00aa493fdc33b0cddcf5 (patch)
tree068227f431317c5da6c65700fb6a07b333455744 /meta
parentfa61a9468b816c597b4a3e2f3855717c284ffa80 (diff)
downloadpoky-1643a7f3bce713e2ab2f00aa493fdc33b0cddcf5.tar.gz
oe-selftest: devtool: add some tests for devtool add -f
Tests the following aspects of "devtool add" with the -f option: * Works for a git and https URI * Extracts to the appropriate directory * Uses the correct recipe file name with and without -V * Sets SRC_URI and S appropriately with and without -V * Sets SRCREV if rev= is specified in the URI A lot of this functionality relies on "recipetool create" which "devtool add" wraps around, so the associated behaviour of that is also being tested here. Refactor out the code to check a recipe for variable values / inherits at the same time so we can use it to check the generated recipe. (From OE-Core rev: 0e626639ee75d42cb44d357efe2d9c4d2ff65294) 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.py148
1 files changed, 118 insertions, 30 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index 68818359bc..1a506d97ce 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -35,6 +35,24 @@ class DevtoolTests(oeSelfTest):
35 self.assertNotIn(tempdir, result.output) 35 self.assertNotIn(tempdir, result.output)
36 self.assertIn(workspacedir, result.output) 36 self.assertIn(workspacedir, result.output)
37 37
38 def _test_recipe_contents(self, recipefile, checkvars, checkinherits):
39 with open(recipefile, 'r') as f:
40 for line in f:
41 if '=' in line:
42 splitline = line.split('=', 1)
43 var = splitline[0].rstrip()
44 value = splitline[1].strip().strip('"')
45 if var in checkvars:
46 needvalue = checkvars.pop(var)
47 self.assertEqual(value, needvalue, 'values for %s do not match' % var)
48 if line.startswith('inherit '):
49 inherits = line.split()[1:]
50
51 self.assertEqual(checkvars, {}, 'Some variables not found: %s' % checkvars)
52
53 for inherit in checkinherits:
54 self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit)
55
38 def test_recipetool_create(self): 56 def test_recipetool_create(self):
39 # Try adding a recipe 57 # Try adding a recipe
40 tempdir = tempfile.mkdtemp(prefix='devtoolqa') 58 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
@@ -51,19 +69,7 @@ class DevtoolTests(oeSelfTest):
51 checkvars['SRC_URI'] = 'https://fedorahosted.org/releases/l/o/logrotate/logrotate-${PV}.tar.gz' 69 checkvars['SRC_URI'] = 'https://fedorahosted.org/releases/l/o/logrotate/logrotate-${PV}.tar.gz'
52 checkvars['SRC_URI[md5sum]'] = '99e08503ef24c3e2e3ff74cc5f3be213' 70 checkvars['SRC_URI[md5sum]'] = '99e08503ef24c3e2e3ff74cc5f3be213'
53 checkvars['SRC_URI[sha256sum]'] = 'f6ba691f40e30e640efa2752c1f9499a3f9738257660994de70a45fe00d12b64' 71 checkvars['SRC_URI[sha256sum]'] = 'f6ba691f40e30e640efa2752c1f9499a3f9738257660994de70a45fe00d12b64'
54 with open(recipefile, 'r') as f: 72 self._test_recipe_contents(recipefile, checkvars, [])
55 for line in f:
56 if '=' in line:
57 splitline = line.split('=', 1)
58 var = splitline[0].rstrip()
59 value = splitline[1].strip().strip('"')
60 if var in checkvars:
61 needvalue = checkvars.pop(var)
62 self.assertEqual(value, needvalue)
63 if line.startswith('inherit '):
64 inherits = line.split()[1:]
65
66 self.assertEqual(checkvars, {}, 'Some variables not found')
67 73
68 def test_recipetool_create_git(self): 74 def test_recipetool_create_git(self):
69 # Ensure we have the right data in shlibs/pkgdata 75 # Ensure we have the right data in shlibs/pkgdata
@@ -84,23 +90,8 @@ class DevtoolTests(oeSelfTest):
84 checkvars['PV'] = '1.0+git${SRCPV}' 90 checkvars['PV'] = '1.0+git${SRCPV}'
85 checkvars['SRC_URI'] = srcuri 91 checkvars['SRC_URI'] = srcuri
86 checkvars['DEPENDS'] = 'libpng pango libx11 libxext jpeg' 92 checkvars['DEPENDS'] = 'libpng pango libx11 libxext jpeg'
87 inherits = [] 93 inherits = ['autotools', 'pkgconfig']
88 with open(recipefile, 'r') as f: 94 self._test_recipe_contents(recipefile, checkvars, inherits)
89 for line in f:
90 if '=' in line:
91 splitline = line.split('=', 1)
92 var = splitline[0].rstrip()
93 value = splitline[1].strip().strip('"')
94 if var in checkvars:
95 needvalue = checkvars.pop(var)
96 self.assertEqual(value, needvalue)
97 if line.startswith('inherit '):
98 inherits = line.split()[1:]
99
100 self.assertEqual(checkvars, {}, 'Some variables not found')
101
102 self.assertIn('autotools', inherits, 'Missing inherit of autotools')
103 self.assertIn('pkgconfig', inherits, 'Missing inherit of pkgconfig')
104 95
105 def test_devtool_add(self): 96 def test_devtool_add(self):
106 # Check preconditions 97 # Check preconditions
@@ -176,6 +167,103 @@ class DevtoolTests(oeSelfTest):
176 self.assertFalse(matches, 'Stamp files exist for recipe libftdi that should have been cleaned') 167 self.assertFalse(matches, 'Stamp files exist for recipe libftdi that should have been cleaned')
177 self.assertFalse(os.path.isfile(os.path.join(staging_libdir, 'libftdi1.so.2.1.0')), 'libftdi binary still found in STAGING_LIBDIR after cleaning') 168 self.assertFalse(os.path.isfile(os.path.join(staging_libdir, 'libftdi1.so.2.1.0')), 'libftdi binary still found in STAGING_LIBDIR after cleaning')
178 169
170 def test_devtool_add_fetch(self):
171 # Check preconditions
172 workspacedir = os.path.join(self.builddir, 'workspace')
173 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
174 # Fetch source
175 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
176 self.track_for_cleanup(tempdir)
177 testver = '0.23'
178 url = 'https://pypi.python.org/packages/source/J/MarkupSafe/MarkupSafe-%s.tar.gz' % testver
179 testrecipe = 'python-markupsafe'
180 srcdir = os.path.join(tempdir, testrecipe)
181 # Test devtool add
182 self.track_for_cleanup(workspacedir)
183 self.add_command_to_tearDown('bitbake -c cleansstate %s' % testrecipe)
184 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
185 result = runCmd('devtool add %s %s -f %s' % (testrecipe, srcdir, url))
186 self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created')
187 self.assertTrue(os.path.isfile(os.path.join(srcdir, 'setup.py')), 'Unable to find setup.py in source directory')
188 # Test devtool status
189 result = runCmd('devtool status')
190 self.assertIn(testrecipe, result.output)
191 self.assertIn(srcdir, result.output)
192 # Check recipe
193 recipefile = get_bb_var('FILE', testrecipe)
194 self.assertIn('%s.bb' % testrecipe, recipefile, 'Recipe file incorrectly named')
195 checkvars = {}
196 checkvars['S'] = '${WORKDIR}/MarkupSafe-%s' % testver
197 checkvars['SRC_URI'] = url
198 self._test_recipe_contents(recipefile, checkvars, [])
199 # Try with version specified
200 result = runCmd('devtool reset -n %s' % testrecipe)
201 shutil.rmtree(srcdir)
202 result = runCmd('devtool add %s %s -f %s -V %s' % (testrecipe, srcdir, url, testver))
203 self.assertTrue(os.path.isfile(os.path.join(srcdir, 'setup.py')), 'Unable to find setup.py in source directory')
204 # Test devtool status
205 result = runCmd('devtool status')
206 self.assertIn(testrecipe, result.output)
207 self.assertIn(srcdir, result.output)
208 # Check recipe
209 recipefile = get_bb_var('FILE', testrecipe)
210 self.assertIn('%s_%s.bb' % (testrecipe, testver), recipefile, 'Recipe file incorrectly named')
211 checkvars = {}
212 checkvars['S'] = '${WORKDIR}/MarkupSafe-${PV}'
213 checkvars['SRC_URI'] = url.replace(testver, '${PV}')
214 self._test_recipe_contents(recipefile, checkvars, [])
215
216 def test_devtool_add_fetch_git(self):
217 # Check preconditions
218 workspacedir = os.path.join(self.builddir, 'workspace')
219 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
220 # Fetch source
221 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
222 self.track_for_cleanup(tempdir)
223 url = 'git://git.yoctoproject.org/libmatchbox'
224 checkrev = '462f0652055d89c648ddd54fd7b03f175c2c6973'
225 testrecipe = 'libmatchbox2'
226 srcdir = os.path.join(tempdir, testrecipe)
227 # Test devtool add
228 self.track_for_cleanup(workspacedir)
229 self.add_command_to_tearDown('bitbake -c cleansstate %s' % testrecipe)
230 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
231 result = runCmd('devtool add %s %s -f %s' % (testrecipe, srcdir, url))
232 self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created')
233 self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure.ac in source directory')
234 # Test devtool status
235 result = runCmd('devtool status')
236 self.assertIn(testrecipe, result.output)
237 self.assertIn(srcdir, result.output)
238 # Check recipe
239 recipefile = get_bb_var('FILE', testrecipe)
240 self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named')
241 checkvars = {}
242 checkvars['S'] = '${WORKDIR}/git'
243 checkvars['PV'] = '1.0+git${SRCPV}'
244 checkvars['SRC_URI'] = url
245 checkvars['SRCREV'] = '${AUTOREV}'
246 self._test_recipe_contents(recipefile, checkvars, [])
247 # Try with revision and version specified
248 result = runCmd('devtool reset -n %s' % testrecipe)
249 shutil.rmtree(srcdir)
250 url_rev = '%s;rev=%s' % (url, checkrev)
251 result = runCmd('devtool add %s %s -f "%s" -V 1.5' % (testrecipe, srcdir, url_rev))
252 self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure.ac in source directory')
253 # Test devtool status
254 result = runCmd('devtool status')
255 self.assertIn(testrecipe, result.output)
256 self.assertIn(srcdir, result.output)
257 # Check recipe
258 recipefile = get_bb_var('FILE', testrecipe)
259 self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named')
260 checkvars = {}
261 checkvars['S'] = '${WORKDIR}/git'
262 checkvars['PV'] = '1.5+git${SRCPV}'
263 checkvars['SRC_URI'] = url
264 checkvars['SRCREV'] = checkrev
265 self._test_recipe_contents(recipefile, checkvars, [])
266
179 def test_devtool_modify(self): 267 def test_devtool_modify(self):
180 # Check preconditions 268 # Check preconditions
181 workspacedir = os.path.join(self.builddir, 'workspace') 269 workspacedir = os.path.join(self.builddir, 'workspace')