Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | from oeqa.selftest.case import OESelftestTestCase |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 9 | import oe.recipeutils |
| 10 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 11 | class Distrodata(OESelftestTestCase): |
| 12 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 13 | 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 18 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | """ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 20 | feature = 'LICENSE_FLAGS_ACCEPTED += " commercial"\n' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 21 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 27 | msg = "" |
| 28 | if len(regressed_failures) > 0: |
| 29 | msg = msg + """ |
| 30 | The 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 |
| 33 | that the check cannot be performed. |
| 34 | """ + "\n".join(regressed_failures) |
| 35 | if len(regressed_successes) > 0: |
| 36 | msg = msg + """ |
| 37 | The following packages have been checked successfully for upstream versions, |
| 38 | but 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 41 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 42 | 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(""" |
| 70 | The 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(""" |
| 75 | The 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 78 | def test_maintainers(self): |
| 79 | """ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 80 | Summary: Test that oe-core recipes have a maintainer and entries in maintainers list have a recipe |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 81 | Expected: All oe-core recipes (except a few special static/testing ones) should have a maintainer listed in maintainers.inc file. |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 82 | Expected: All entries in maintainers list should have a recipe file that matches them |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 83 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 84 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 85 | """ |
| 86 | def is_exception(pkg): |
Andrew Geissler | 028142b | 2023-05-05 11:29:21 -0500 | [diff] [blame] | 87 | exceptions = ["packagegroup-",] |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 88 | for i in exceptions: |
| 89 | if i in pkg: |
| 90 | return True |
| 91 | return False |
| 92 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 93 | def is_maintainer_exception(entry): |
Andrew Geissler | 028142b | 2023-05-05 11:29:21 -0500 | [diff] [blame] | 94 | exceptions = ["musl", "newlib", "linux-yocto", "linux-dummy", "mesa-gl", "libgfortran", "libx11-compose-data", |
Andrew Geissler | 8f84068 | 2023-07-21 09:09:43 -0500 | [diff] [blame^] | 95 | "cve-update-nvd2-native",] |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 96 | for i in exceptions: |
| 97 | if i in entry: |
| 98 | return True |
| 99 | return False |
| 100 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 101 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 102 | self.write_config(feature) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 103 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 104 | with bb.tinfoil.Tinfoil() as tinfoil: |
| 105 | tinfoil.prepare(config_only=False) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 106 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 107 | with_maintainer_list = [] |
| 108 | no_maintainer_list = [] |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 109 | |
| 110 | missing_recipes = [] |
| 111 | recipes = [] |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 112 | prefix = "RECIPE_MAINTAINER:pn-" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 113 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 114 | # 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 123 | recipes.append(pn) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 124 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 130 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 131 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 140 | if no_maintainer_list: |
| 141 | self.fail(""" |
| 142 | The 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 144 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 145 | if not with_maintainer_list: |
| 146 | self.fail(""" |
| 147 | The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing. |
| 148 | """) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 149 | |
| 150 | if missing_recipes: |
| 151 | self.fail(""" |
| 152 | Unable to find recipes for the following entries in maintainers.inc: |
| 153 | """ + "\n".join(['%s' % i for i in missing_recipes])) |