blob: 90a2249b081707ad273cd64e60b9a00f1ab73338 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001import os
2import re
3
4import oeqa.utils.ftools as ftools
5from oeqa.utils.commands import runCmd, get_bb_var
6
7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.core.decorator.oeid import OETestID
9
10class BitbakeLayers(OESelftestTestCase):
11
12 @OETestID(756)
13 def test_bitbakelayers_showcrossdepends(self):
14 result = runCmd('bitbake-layers show-cross-depends')
15 self.assertTrue('aspell' in result.output, msg = "No dependencies were shown. bitbake-layers show-cross-depends output: %s" % result.output)
16
17 @OETestID(83)
18 def test_bitbakelayers_showlayers(self):
19 result = runCmd('bitbake-layers show-layers')
20 self.assertTrue('meta-selftest' in result.output, msg = "No layers were shown. bitbake-layers show-layers output: %s" % result.output)
21
22 @OETestID(93)
23 def test_bitbakelayers_showappends(self):
24 recipe = "xcursor-transparent-theme"
25 bb_file = self.get_recipe_basename(recipe)
26 result = runCmd('bitbake-layers show-appends')
27 self.assertTrue(bb_file in result.output, msg="%s file was not recognised. bitbake-layers show-appends output: %s" % (bb_file, result.output))
28
29 @OETestID(90)
30 def test_bitbakelayers_showoverlayed(self):
31 result = runCmd('bitbake-layers show-overlayed')
32 self.assertTrue('aspell' in result.output, msg="aspell overlayed recipe was not recognised bitbake-layers show-overlayed %s" % result.output)
33
34 @OETestID(95)
35 def test_bitbakelayers_flatten(self):
36 recipe = "xcursor-transparent-theme"
37 recipe_path = "recipes-graphics/xcursor-transparent-theme"
38 recipe_file = self.get_recipe_basename(recipe)
39 testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten')
40 self.assertFalse(os.path.isdir(testoutdir), msg = "test_bitbakelayers_flatten should not exist at this point in time")
41 self.track_for_cleanup(testoutdir)
42 result = runCmd('bitbake-layers flatten %s' % testoutdir)
43 bb_file = os.path.join(testoutdir, recipe_path, recipe_file)
44 self.assertTrue(os.path.isfile(bb_file), msg = "Cannot find xcursor-transparent-theme_0.1.1.bb in the test_bitbakelayers_flatten local dir.")
45 contents = ftools.read_file(bb_file)
46 find_in_contents = re.search("##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents)
47 self.assertTrue(find_in_contents, msg = "Flattening layers did not work. bitbake-layers flatten output: %s" % result.output)
48
49 @OETestID(1195)
50 def test_bitbakelayers_add_remove(self):
51 test_layer = os.path.join(get_bb_var('COREBASE'), 'meta-skeleton')
52 result = runCmd('bitbake-layers show-layers')
53 self.assertNotIn('meta-skeleton', result.output, "This test cannot run with meta-skeleton in bblayers.conf. bitbake-layers show-layers output: %s" % result.output)
54 result = runCmd('bitbake-layers add-layer %s' % test_layer)
55 result = runCmd('bitbake-layers show-layers')
56 self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf. bitbake-layers show-layers output: %s" % result.output)
57 result = runCmd('bitbake-layers remove-layer %s' % test_layer)
58 result = runCmd('bitbake-layers show-layers')
59 self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step. bitbake-layers show-layers output: %s" % result.output)
60 result = runCmd('bitbake-layers add-layer %s' % test_layer)
61 result = runCmd('bitbake-layers show-layers')
62 self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf. bitbake-layers show-layers output: %s" % result.output)
63 result = runCmd('bitbake-layers remove-layer */meta-skeleton')
64 result = runCmd('bitbake-layers show-layers')
65 self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step. bitbake-layers show-layers output: %s" % result.output)
66
67 @OETestID(1384)
68 def test_bitbakelayers_showrecipes(self):
69 result = runCmd('bitbake-layers show-recipes')
70 self.assertIn('aspell:', result.output)
71 self.assertIn('mtd-utils:', result.output)
72 self.assertIn('core-image-minimal:', result.output)
73 result = runCmd('bitbake-layers show-recipes mtd-utils')
74 self.assertIn('mtd-utils:', result.output)
75 self.assertNotIn('aspell:', result.output)
76 result = runCmd('bitbake-layers show-recipes -i image')
77 self.assertIn('core-image-minimal', result.output)
78 self.assertNotIn('mtd-utils:', result.output)
79 result = runCmd('bitbake-layers show-recipes -i cmake,pkgconfig')
80 self.assertIn('libproxy:', result.output)
81 self.assertNotIn('mtd-utils:', result.output) # doesn't inherit either
82 self.assertNotIn('wget:', result.output) # doesn't inherit cmake
83 self.assertNotIn('waffle:', result.output) # doesn't inherit pkgconfig
84 result = runCmd('bitbake-layers show-recipes -i nonexistentclass', ignore_status=True)
85 self.assertNotEqual(result.status, 0, 'bitbake-layers show-recipes -i nonexistentclass should have failed')
86 self.assertIn('ERROR:', result.output)
87
88 def get_recipe_basename(self, recipe):
89 recipe_file = ""
90 result = runCmd("bitbake-layers show-recipes -f %s" % recipe)
91 for line in result.output.splitlines():
92 if recipe in line:
93 recipe_file = line
94 break
95
96 self.assertTrue(os.path.isfile(recipe_file), msg = "Can't find recipe file for %s" % recipe)
97 return os.path.basename(recipe_file)