blob: 7b2800464cbd062d77da3341ce414d9db54cb7b1 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001from oeqa.selftest.case import OESelftestTestCase
2from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
3from oeqa.utils.decorators import testcase
4from oeqa.utils.ftools import write_file
5from oeqa.core.decorator.oeid import OETestID
6
7class Distrodata(OESelftestTestCase):
8
9 @classmethod
10 def setUpClass(cls):
11 super(Distrodata, cls).setUpClass()
Brad Bishop316dfdd2018-06-25 12:45:53 -040012 feature = 'INHERIT += "distrodata"\n'
13 feature += 'LICENSE_FLAGS_WHITELIST += " commercial"\n'
14
15 cls.write_config(cls, feature)
16 bitbake('-c checkpkg world')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050017
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
24 Author: Alexander Kanavin <alexander.kanavin@intel.com>
25 """
Brad Bishopd7bf8c12018-02-25 22:55:05 -050026 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 + """
32The 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
35that the check cannot be performed.
36""" + "\n".join(regressed_failures)
37 if len(regressed_successes) > 0:
38 msg = msg + """
39The following packages have been checked successfully for upstream versions,
40but 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 Bishop316dfdd2018-06-25 12:45:53 -040043
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
49 Author: Alexander Kanavin <alexander.kanavin@intel.com>
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 = """
90The 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 = """
97The 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)