blob: b5554a6c3c34eeaa2955ad0d787bd243ed96485b [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
Andrew Geissler95ac1b82021-03-31 14:34:31 -050042 def test_missing_homepg(self):
43 """
44 Summary: Test for oe-core recipes that don't have a HOMEPAGE or DESCRIPTION
45 Expected: All oe-core recipes should have a DESCRIPTION entry
46 Expected: All oe-core recipes should have a HOMEPAGE entry except for recipes that are not fetched from external sources.
47 Product: oe-core
48 """
49 with bb.tinfoil.Tinfoil() as tinfoil:
50 tinfoil.prepare(config_only=False)
51 no_description = []
52 no_homepage = []
53 for fn in tinfoil.all_recipe_files(variants=False):
54 if not '/meta/recipes-' in fn:
55 # We are only interested in OE-Core
56 continue
57 rd = tinfoil.parse_recipe_file(fn, appends=False)
58 pn = rd.getVar('BPN')
59 srcfile = rd.getVar('SRC_URI').split()
60 #Since DESCRIPTION defaults to SUMMARY if not set, we are only interested in recipes without DESCRIPTION or SUMMARY
61 if not (rd.getVar('SUMMARY') or rd.getVar('DESCRIPTION')):
62 no_description.append((pn, fn))
63 if not rd.getVar('HOMEPAGE'):
64 if srcfile and srcfile[0].startswith('file') or not rd.getVar('SRC_URI'):
65 # We are only interested in recipes SRC_URI fetched from external sources
66 continue
67 no_homepage.append((pn, fn))
68 if no_homepage:
69 self.fail("""
70The following recipes do not have a HOMEPAGE. Please add an entry for HOMEPAGE in the recipe.
71""" + "\n".join(['%s (%s)' % i for i in no_homepage]))
72
73 if no_description:
74 self.fail("""
75The following recipes do not have a DESCRIPTION. Please add an entry for DESCRIPTION in the recipe.
76""" + "\n".join(['%s (%s)' % i for i in no_description]))
77
Brad Bishop316dfdd2018-06-25 12:45:53 -040078 def test_maintainers(self):
79 """
Andrew Geissler82c905d2020-04-13 13:39:40 -050080 Summary: Test that oe-core recipes have a maintainer and entries in maintainers list have a recipe
Brad Bishop316dfdd2018-06-25 12:45:53 -040081 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 -050082 Expected: All entries in maintainers list should have a recipe file that matches them
Brad Bishop316dfdd2018-06-25 12:45:53 -040083 Product: oe-core
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080084 Author: Alexander Kanavin <alex.kanavin@gmail.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040085 """
86 def is_exception(pkg):
87 exceptions = ["packagegroup-", "initramfs-", "systemd-machine-units", "target-sdk-provides-dummy"]
88 for i in exceptions:
89 if i in pkg:
90 return True
91 return False
92
Andrew Geissler82c905d2020-04-13 13:39:40 -050093 def is_maintainer_exception(entry):
94 exceptions = ["musl", "newlib", "linux-yocto", "linux-dummy", "mesa-gl", "libgfortran",
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050095 "cve-update-db-native", "rust"]
Andrew Geissler82c905d2020-04-13 13:39:40 -050096 for i in exceptions:
97 if i in entry:
98 return True
99 return False
100
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000101 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 -0400102 self.write_config(feature)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400103
Brad Bishop19323692019-04-05 15:28:33 -0400104 with bb.tinfoil.Tinfoil() as tinfoil:
105 tinfoil.prepare(config_only=False)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400106
Brad Bishop19323692019-04-05 15:28:33 -0400107 with_maintainer_list = []
108 no_maintainer_list = []
Andrew Geissler82c905d2020-04-13 13:39:40 -0500109
110 missing_recipes = []
111 recipes = []
Patrick Williams213cb262021-08-07 19:21:33 -0500112 prefix = "RECIPE_MAINTAINER:pn-"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500113
Brad Bishop19323692019-04-05 15:28:33 -0400114 # We could have used all_recipes() here, but this method will find
115 # every recipe if we ever move to setting RECIPE_MAINTAINER in recipe files
116 # instead of maintainers.inc
117 for fn in tinfoil.all_recipe_files(variants=False):
118 if not '/meta/recipes-' in fn:
119 # We are only interested in OE-Core
120 continue
121 rd = tinfoil.parse_recipe_file(fn, appends=False)
122 pn = rd.getVar('PN')
Andrew Geissler82c905d2020-04-13 13:39:40 -0500123 recipes.append(pn)
Brad Bishop19323692019-04-05 15:28:33 -0400124 if is_exception(pn):
125 continue
126 if rd.getVar('RECIPE_MAINTAINER'):
127 with_maintainer_list.append((pn, fn))
128 else:
129 no_maintainer_list.append((pn, fn))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400130
Andrew Geissler82c905d2020-04-13 13:39:40 -0500131 maintainers = tinfoil.config_data.keys()
132 for key in maintainers:
133 if key.startswith(prefix):
134 recipe = tinfoil.config_data.expand(key[len(prefix):])
135 if is_maintainer_exception(recipe):
136 continue
137 if recipe not in recipes:
138 missing_recipes.append(recipe)
139
Brad Bishop19323692019-04-05 15:28:33 -0400140 if no_maintainer_list:
141 self.fail("""
142The following recipes do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file.
143""" + "\n".join(['%s (%s)' % i for i in no_maintainer_list]))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400144
Brad Bishop19323692019-04-05 15:28:33 -0400145 if not with_maintainer_list:
146 self.fail("""
147The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing.
148""")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500149
150 if missing_recipes:
151 self.fail("""
152Unable to find recipes for the following entries in maintainers.inc:
153""" + "\n".join(['%s' % i for i in missing_recipes]))