blob: ad952c004b5a2621bcf78933168208d06ceceb42 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007from oeqa.selftest.case import OESelftestTestCase
Brad Bishopd7bf8c12018-02-25 22:55:05 -05008
Brad Bishop19323692019-04-05 15:28:33 -04009import oe.recipeutils
10
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011class Distrodata(OESelftestTestCase):
12
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013 def test_checkpkg(self):
14 """
15 Summary: Test that upstream version checks do not regress
16 Expected: Upstream version checks should succeed except for the recipes listed in the exception list.
17 Product: oe-core
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080018 Author: Alexander Kanavin <alex.kanavin@gmail.com>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019 """
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000020 feature = 'LICENSE_FLAGS_ACCEPTED += " commercial"\n'
Brad Bishop19323692019-04-05 15:28:33 -040021 self.write_config(feature)
22
23 pkgs = oe.recipeutils.get_recipe_upgrade_status()
24
25 regressed_failures = [pkg[0] for pkg in pkgs if pkg[1] == 'UNKNOWN_BROKEN']
26 regressed_successes = [pkg[0] for pkg in pkgs if pkg[1] == 'KNOWN_BROKEN']
Brad Bishopd7bf8c12018-02-25 22:55:05 -050027 msg = ""
28 if len(regressed_failures) > 0:
29 msg = msg + """
30The following packages failed upstream version checks. Please fix them using UPSTREAM_CHECK_URI/UPSTREAM_CHECK_REGEX
31(when using tarballs) or UPSTREAM_CHECK_GITTAGREGEX (when using git). If an upstream version check cannot be performed
32(for example, if upstream does not use git tags), you can set UPSTREAM_VERSION_UNKNOWN to '1' in the recipe to acknowledge
33that the check cannot be performed.
34""" + "\n".join(regressed_failures)
35 if len(regressed_successes) > 0:
36 msg = msg + """
37The following packages have been checked successfully for upstream versions,
38but their recipes claim otherwise by setting UPSTREAM_VERSION_UNKNOWN. Please remove that line from the recipes.
39""" + "\n".join(regressed_successes)
40 self.assertTrue(len(regressed_failures) == 0 and len(regressed_successes) == 0, msg)
Brad Bishop316dfdd2018-06-25 12:45:53 -040041
42 def test_maintainers(self):
43 """
Andrew Geissler82c905d2020-04-13 13:39:40 -050044 Summary: Test that oe-core recipes have a maintainer and entries in maintainers list have a recipe
Brad Bishop316dfdd2018-06-25 12:45:53 -040045 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 -050046 Expected: All entries in maintainers list should have a recipe file that matches them
Brad Bishop316dfdd2018-06-25 12:45:53 -040047 Product: oe-core
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080048 Author: Alexander Kanavin <alex.kanavin@gmail.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040049 """
50 def is_exception(pkg):
Andrew Geissler028142b2023-05-05 11:29:21 -050051 exceptions = ["packagegroup-",]
Brad Bishop316dfdd2018-06-25 12:45:53 -040052 for i in exceptions:
53 if i in pkg:
54 return True
55 return False
56
Andrew Geissler82c905d2020-04-13 13:39:40 -050057 def is_maintainer_exception(entry):
Andrew Geissler028142b2023-05-05 11:29:21 -050058 exceptions = ["musl", "newlib", "linux-yocto", "linux-dummy", "mesa-gl", "libgfortran", "libx11-compose-data",
Andrew Geissler8f840682023-07-21 09:09:43 -050059 "cve-update-nvd2-native",]
Andrew Geissler82c905d2020-04-13 13:39:40 -050060 for i in exceptions:
61 if i in entry:
62 return True
63 return False
64
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000065 feature = 'require conf/distro/include/maintainers.inc\nLICENSE_FLAGS_ACCEPTED += " commercial"\nPARSE_ALL_RECIPES = "1"\nPACKAGE_CLASSES = "package_ipk package_deb package_rpm"\n'
Brad Bishop19323692019-04-05 15:28:33 -040066 self.write_config(feature)
Brad Bishop316dfdd2018-06-25 12:45:53 -040067
Brad Bishop19323692019-04-05 15:28:33 -040068 with bb.tinfoil.Tinfoil() as tinfoil:
69 tinfoil.prepare(config_only=False)
Brad Bishop316dfdd2018-06-25 12:45:53 -040070
Brad Bishop19323692019-04-05 15:28:33 -040071 with_maintainer_list = []
72 no_maintainer_list = []
Andrew Geissler82c905d2020-04-13 13:39:40 -050073
74 missing_recipes = []
75 recipes = []
Patrick Williams213cb262021-08-07 19:21:33 -050076 prefix = "RECIPE_MAINTAINER:pn-"
Andrew Geissler82c905d2020-04-13 13:39:40 -050077
Brad Bishop19323692019-04-05 15:28:33 -040078 # We could have used all_recipes() here, but this method will find
79 # every recipe if we ever move to setting RECIPE_MAINTAINER in recipe files
80 # instead of maintainers.inc
81 for fn in tinfoil.all_recipe_files(variants=False):
82 if not '/meta/recipes-' in fn:
83 # We are only interested in OE-Core
84 continue
85 rd = tinfoil.parse_recipe_file(fn, appends=False)
86 pn = rd.getVar('PN')
Andrew Geissler82c905d2020-04-13 13:39:40 -050087 recipes.append(pn)
Brad Bishop19323692019-04-05 15:28:33 -040088 if is_exception(pn):
89 continue
90 if rd.getVar('RECIPE_MAINTAINER'):
91 with_maintainer_list.append((pn, fn))
92 else:
93 no_maintainer_list.append((pn, fn))
Brad Bishop316dfdd2018-06-25 12:45:53 -040094
Andrew Geissler82c905d2020-04-13 13:39:40 -050095 maintainers = tinfoil.config_data.keys()
96 for key in maintainers:
97 if key.startswith(prefix):
98 recipe = tinfoil.config_data.expand(key[len(prefix):])
99 if is_maintainer_exception(recipe):
100 continue
101 if recipe not in recipes:
102 missing_recipes.append(recipe)
103
Brad Bishop19323692019-04-05 15:28:33 -0400104 if no_maintainer_list:
105 self.fail("""
106The following recipes do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file.
107""" + "\n".join(['%s (%s)' % i for i in no_maintainer_list]))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400108
Brad Bishop19323692019-04-05 15:28:33 -0400109 if not with_maintainer_list:
110 self.fail("""
111The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing.
112""")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500113
114 if missing_recipes:
115 self.fail("""
116Unable to find recipes for the following entries in maintainers.inc:
117""" + "\n".join(['%s' % i for i in missing_recipes]))