diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/devtool.py')
-rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 7af82df632..41e1b4bf51 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py | |||
@@ -15,18 +15,43 @@ class DevtoolBase(oeSelfTest): | |||
15 | 15 | ||
16 | def _test_recipe_contents(self, recipefile, checkvars, checkinherits): | 16 | def _test_recipe_contents(self, recipefile, checkvars, checkinherits): |
17 | with open(recipefile, 'r') as f: | 17 | with open(recipefile, 'r') as f: |
18 | invar = None | ||
19 | invalue = None | ||
18 | for line in f: | 20 | for line in f: |
19 | if '=' in line: | 21 | var = None |
22 | if invar: | ||
23 | value = line.strip().strip('"') | ||
24 | if value.endswith('\\'): | ||
25 | invalue += ' ' + value[:-1].strip() | ||
26 | continue | ||
27 | else: | ||
28 | invalue += ' ' + value.strip() | ||
29 | var = invar | ||
30 | value = invalue | ||
31 | invar = None | ||
32 | elif '=' in line: | ||
20 | splitline = line.split('=', 1) | 33 | splitline = line.split('=', 1) |
21 | var = splitline[0].rstrip() | 34 | var = splitline[0].rstrip() |
22 | value = splitline[1].strip().strip('"') | 35 | value = splitline[1].strip().strip('"') |
23 | if var in checkvars: | 36 | if value.endswith('\\'): |
24 | needvalue = checkvars.pop(var) | 37 | invalue = value[:-1].strip() |
25 | self.assertEqual(value, needvalue, 'values for %s do not match' % var) | 38 | invar = var |
26 | if line.startswith('inherit '): | 39 | continue |
40 | elif line.startswith('inherit '): | ||
27 | inherits = line.split()[1:] | 41 | inherits = line.split()[1:] |
28 | 42 | ||
29 | self.assertEqual(checkvars, {}, 'Some variables not found: %s' % checkvars) | 43 | if var and var in checkvars: |
44 | needvalue = checkvars.pop(var) | ||
45 | if needvalue is None: | ||
46 | self.fail('Variable %s should not appear in recipe') | ||
47 | self.assertEqual(value, needvalue, 'values for %s do not match' % var) | ||
48 | |||
49 | |||
50 | missingvars = {} | ||
51 | for var, value in checkvars.iteritems(): | ||
52 | if value is not None: | ||
53 | missingvars[var] = value | ||
54 | self.assertEqual(missingvars, {}, 'Some expected variables not found in recipe: %s' % checkvars) | ||
30 | 55 | ||
31 | for inherit in checkinherits: | 56 | for inherit in checkinherits: |
32 | self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit) | 57 | self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit) |
@@ -304,6 +329,32 @@ class DevtoolTests(DevtoolBase): | |||
304 | checkvars['SRCREV'] = checkrev | 329 | checkvars['SRCREV'] = checkrev |
305 | self._test_recipe_contents(recipefile, checkvars, []) | 330 | self._test_recipe_contents(recipefile, checkvars, []) |
306 | 331 | ||
332 | def test_devtool_add_fetch_simple(self): | ||
333 | # Fetch source from a remote URL, auto-detecting name | ||
334 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
335 | self.track_for_cleanup(tempdir) | ||
336 | testver = '1.6.0' | ||
337 | url = 'http://www.ivarch.com/programs/sources/pv-%s.tar.bz2' % testver | ||
338 | testrecipe = 'pv' | ||
339 | srcdir = os.path.join(self.workspacedir, 'sources', testrecipe) | ||
340 | # Test devtool add | ||
341 | self.track_for_cleanup(self.workspacedir) | ||
342 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
343 | result = runCmd('devtool add %s' % url) | ||
344 | self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created. %s' % result.output) | ||
345 | self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure')), 'Unable to find configure script in source directory') | ||
346 | # Test devtool status | ||
347 | result = runCmd('devtool status') | ||
348 | self.assertIn(testrecipe, result.output) | ||
349 | self.assertIn(srcdir, result.output) | ||
350 | # Check recipe | ||
351 | recipefile = get_bb_var('FILE', testrecipe) | ||
352 | self.assertIn('%s_%s.bb' % (testrecipe, testver), recipefile, 'Recipe file incorrectly named') | ||
353 | checkvars = {} | ||
354 | checkvars['S'] = None | ||
355 | checkvars['SRC_URI'] = url.replace(testver, '${PV}') | ||
356 | self._test_recipe_contents(recipefile, checkvars, []) | ||
357 | |||
307 | @testcase(1164) | 358 | @testcase(1164) |
308 | def test_devtool_modify(self): | 359 | def test_devtool_modify(self): |
309 | # Clean up anything in the workdir/sysroot/sstate cache | 360 | # Clean up anything in the workdir/sysroot/sstate cache |