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