Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | from oeqa.selftest.case import OESelftestTestCase |
| 2 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars |
| 3 | from oeqa.utils.decorators import testcase |
| 4 | from oeqa.utils.ftools import write_file |
| 5 | from oeqa.core.decorator.oeid import OETestID |
| 6 | |
| 7 | class Distrodata(OESelftestTestCase): |
| 8 | |
| 9 | @classmethod |
| 10 | def setUpClass(cls): |
| 11 | super(Distrodata, cls).setUpClass() |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12 | feature = 'INHERIT += "distrodata"\n' |
| 13 | feature += 'LICENSE_FLAGS_WHITELIST += " commercial"\n' |
| 14 | |
| 15 | cls.write_config(cls, feature) |
| 16 | bitbake('-c checkpkg world') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 17 | |
| 18 | @OETestID(1902) |
| 19 | def test_checkpkg(self): |
| 20 | """ |
| 21 | Summary: Test that upstream version checks do not regress |
| 22 | Expected: Upstream version checks should succeed except for the recipes listed in the exception list. |
| 23 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 25 | """ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 26 | checkpkg_result = open(os.path.join(get_bb_var("LOG_DIR"), "checkpkg.csv")).readlines()[1:] |
| 27 | regressed_failures = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] if pkg_data[11] == 'UNKNOWN_BROKEN'] |
| 28 | regressed_successes = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] if pkg_data[11] == 'KNOWN_BROKEN'] |
| 29 | msg = "" |
| 30 | if len(regressed_failures) > 0: |
| 31 | msg = msg + """ |
| 32 | The following packages failed upstream version checks. Please fix them using UPSTREAM_CHECK_URI/UPSTREAM_CHECK_REGEX |
| 33 | (when using tarballs) or UPSTREAM_CHECK_GITTAGREGEX (when using git). If an upstream version check cannot be performed |
| 34 | (for example, if upstream does not use git tags), you can set UPSTREAM_VERSION_UNKNOWN to '1' in the recipe to acknowledge |
| 35 | that the check cannot be performed. |
| 36 | """ + "\n".join(regressed_failures) |
| 37 | if len(regressed_successes) > 0: |
| 38 | msg = msg + """ |
| 39 | The following packages have been checked successfully for upstream versions, |
| 40 | but their recipes claim otherwise by setting UPSTREAM_VERSION_UNKNOWN. Please remove that line from the recipes. |
| 41 | """ + "\n".join(regressed_successes) |
| 42 | self.assertTrue(len(regressed_failures) == 0 and len(regressed_successes) == 0, msg) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 43 | |
| 44 | def test_maintainers(self): |
| 45 | """ |
| 46 | Summary: Test that oe-core recipes have a maintainer |
| 47 | Expected: All oe-core recipes (except a few special static/testing ones) should have a maintainer listed in maintainers.inc file. |
| 48 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 49 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 50 | """ |
| 51 | def is_exception(pkg): |
| 52 | exceptions = ["packagegroup-", "initramfs-", "systemd-machine-units", "target-sdk-provides-dummy"] |
| 53 | for i in exceptions: |
| 54 | if i in pkg: |
| 55 | return True |
| 56 | return False |
| 57 | |
| 58 | def is_in_oe_core(recipe, recipes): |
| 59 | self.assertTrue(recipe in recipes.keys(), "Recipe %s was not in 'bitbake-layers show-recipes' output" %(recipe)) |
| 60 | self.assertTrue(len(recipes[recipe]) > 0, "'bitbake-layers show-recipes' could not determine what layer(s) a recipe %s is in" %(recipe)) |
| 61 | try: |
| 62 | recipes[recipe].index('meta') |
| 63 | return True |
| 64 | except ValueError: |
| 65 | return False |
| 66 | |
| 67 | def get_recipe_layers(): |
| 68 | import re |
| 69 | |
| 70 | recipes = {} |
| 71 | recipe_regex = re.compile('^(?P<name>.*):$') |
| 72 | layer_regex = re.compile('^ (?P<name>\S*) +') |
| 73 | output = runCmd('bitbake-layers show-recipes').output |
| 74 | for line in output.split('\n'): |
| 75 | recipe_name_obj = recipe_regex.search(line) |
| 76 | if recipe_name_obj: |
| 77 | recipe_name = recipe_name_obj.group('name') |
| 78 | recipes[recipe_name] = [] |
| 79 | recipe_layer_obj = layer_regex.search(line) |
| 80 | if recipe_layer_obj: |
| 81 | layer_name = recipe_layer_obj.group('name') |
| 82 | recipes[recipe_name].append(layer_name) |
| 83 | return recipes |
| 84 | |
| 85 | checkpkg_result = open(os.path.join(get_bb_var("LOG_DIR"), "checkpkg.csv")).readlines()[1:] |
| 86 | recipes_layers = get_recipe_layers() |
| 87 | no_maintainer_list = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] \ |
| 88 | if pkg_data[14] == '' and is_in_oe_core(pkg_data[0], recipes_layers) and not is_exception(pkg_data[0])] |
| 89 | msg = """ |
| 90 | The following packages do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file. |
| 91 | """ + "\n".join(no_maintainer_list) |
| 92 | self.assertTrue(len(no_maintainer_list) == 0, msg) |
| 93 | |
| 94 | with_maintainer_list = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] \ |
| 95 | if pkg_data[14] != '' and is_in_oe_core(pkg_data[0], recipes_layers) and not is_exception(pkg_data[0])] |
| 96 | msg = """ |
| 97 | The list of oe-core packages with maintainers is empty. This may indicate that the test has regressed and needs fixing. |
| 98 | """ |
| 99 | self.assertTrue(len(with_maintainer_list) > 0, msg) |