blob: e1cfc3b6214fac66965dfaf145dcd6b61949476a [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005from oeqa.selftest.case import OESelftestTestCase
6from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
7from oeqa.utils.decorators import testcase
8from oeqa.utils.ftools import write_file
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009
Brad Bishop19323692019-04-05 15:28:33 -040010import oe.recipeutils
11
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012class Distrodata(OESelftestTestCase):
13
Brad Bishopd7bf8c12018-02-25 22:55:05 -050014 def test_checkpkg(self):
15 """
16 Summary: Test that upstream version checks do not regress
17 Expected: Upstream version checks should succeed except for the recipes listed in the exception list.
18 Product: oe-core
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019 Author: Alexander Kanavin <alex.kanavin@gmail.com>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020 """
Brad Bishop19323692019-04-05 15:28:33 -040021 feature = 'LICENSE_FLAGS_WHITELIST += " commercial"\n'
22 self.write_config(feature)
23
24 pkgs = oe.recipeutils.get_recipe_upgrade_status()
25
26 regressed_failures = [pkg[0] for pkg in pkgs if pkg[1] == 'UNKNOWN_BROKEN']
27 regressed_successes = [pkg[0] for pkg in pkgs if pkg[1] == 'KNOWN_BROKEN']
Brad Bishopd7bf8c12018-02-25 22:55:05 -050028 msg = ""
29 if len(regressed_failures) > 0:
30 msg = msg + """
31The following packages failed upstream version checks. Please fix them using UPSTREAM_CHECK_URI/UPSTREAM_CHECK_REGEX
32(when using tarballs) or UPSTREAM_CHECK_GITTAGREGEX (when using git). If an upstream version check cannot be performed
33(for example, if upstream does not use git tags), you can set UPSTREAM_VERSION_UNKNOWN to '1' in the recipe to acknowledge
34that the check cannot be performed.
35""" + "\n".join(regressed_failures)
36 if len(regressed_successes) > 0:
37 msg = msg + """
38The following packages have been checked successfully for upstream versions,
39but their recipes claim otherwise by setting UPSTREAM_VERSION_UNKNOWN. Please remove that line from the recipes.
40""" + "\n".join(regressed_successes)
41 self.assertTrue(len(regressed_failures) == 0 and len(regressed_successes) == 0, msg)
Brad Bishop316dfdd2018-06-25 12:45:53 -040042
43 def test_maintainers(self):
44 """
Andrew Geissler82c905d2020-04-13 13:39:40 -050045 Summary: Test that oe-core recipes have a maintainer and entries in maintainers list have a recipe
Brad Bishop316dfdd2018-06-25 12:45:53 -040046 Expected: All oe-core recipes (except a few special static/testing ones) should have a maintainer listed in maintainers.inc file.
Andrew Geissler82c905d2020-04-13 13:39:40 -050047 Expected: All entries in maintainers list should have a recipe file that matches them
Brad Bishop316dfdd2018-06-25 12:45:53 -040048 Product: oe-core
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080049 Author: Alexander Kanavin <alex.kanavin@gmail.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040050 """
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
Andrew Geissler82c905d2020-04-13 13:39:40 -050058 def is_maintainer_exception(entry):
59 exceptions = ["musl", "newlib", "linux-yocto", "linux-dummy", "mesa-gl", "libgfortran",
60 "cve-update-db-native"]
61 for i in exceptions:
62 if i in entry:
63 return True
64 return False
65
66 feature = 'require conf/distro/include/maintainers.inc\nLICENSE_FLAGS_WHITELIST += " commercial"\nPARSE_ALL_RECIPES = "1"\n'
Brad Bishop19323692019-04-05 15:28:33 -040067 self.write_config(feature)
Brad Bishop316dfdd2018-06-25 12:45:53 -040068
Brad Bishop19323692019-04-05 15:28:33 -040069 with bb.tinfoil.Tinfoil() as tinfoil:
70 tinfoil.prepare(config_only=False)
Brad Bishop316dfdd2018-06-25 12:45:53 -040071
Brad Bishop19323692019-04-05 15:28:33 -040072 with_maintainer_list = []
73 no_maintainer_list = []
Andrew Geissler82c905d2020-04-13 13:39:40 -050074
75 missing_recipes = []
76 recipes = []
77 prefix = "RECIPE_MAINTAINER_pn-"
78
Brad Bishop19323692019-04-05 15:28:33 -040079 # We could have used all_recipes() here, but this method will find
80 # every recipe if we ever move to setting RECIPE_MAINTAINER in recipe files
81 # instead of maintainers.inc
82 for fn in tinfoil.all_recipe_files(variants=False):
83 if not '/meta/recipes-' in fn:
84 # We are only interested in OE-Core
85 continue
86 rd = tinfoil.parse_recipe_file(fn, appends=False)
87 pn = rd.getVar('PN')
Andrew Geissler82c905d2020-04-13 13:39:40 -050088 recipes.append(pn)
Brad Bishop19323692019-04-05 15:28:33 -040089 if is_exception(pn):
90 continue
91 if rd.getVar('RECIPE_MAINTAINER'):
92 with_maintainer_list.append((pn, fn))
93 else:
94 no_maintainer_list.append((pn, fn))
Brad Bishop316dfdd2018-06-25 12:45:53 -040095
Andrew Geissler82c905d2020-04-13 13:39:40 -050096 maintainers = tinfoil.config_data.keys()
97 for key in maintainers:
98 if key.startswith(prefix):
99 recipe = tinfoil.config_data.expand(key[len(prefix):])
100 if is_maintainer_exception(recipe):
101 continue
102 if recipe not in recipes:
103 missing_recipes.append(recipe)
104
Brad Bishop19323692019-04-05 15:28:33 -0400105 if no_maintainer_list:
106 self.fail("""
107The following recipes do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file.
108""" + "\n".join(['%s (%s)' % i for i in no_maintainer_list]))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400109
Brad Bishop19323692019-04-05 15:28:33 -0400110 if not with_maintainer_list:
111 self.fail("""
112The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing.
113""")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500114
115 if missing_recipes:
116 self.fail("""
117Unable to find recipes for the following entries in maintainers.inc:
118""" + "\n".join(['%s' % i for i in missing_recipes]))