Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5 | from oeqa.selftest.case import OESelftestTestCase |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 7 | import oe.recipeutils |
| 8 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9 | class Distrodata(OESelftestTestCase): |
| 10 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 11 | def test_checkpkg(self): |
| 12 | """ |
| 13 | Summary: Test that upstream version checks do not regress |
| 14 | Expected: Upstream version checks should succeed except for the recipes listed in the exception list. |
| 15 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 16 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 17 | """ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 18 | feature = 'LICENSE_FLAGS_ACCEPTED += " commercial"\n' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 19 | self.write_config(feature) |
| 20 | |
| 21 | pkgs = oe.recipeutils.get_recipe_upgrade_status() |
| 22 | |
| 23 | regressed_failures = [pkg[0] for pkg in pkgs if pkg[1] == 'UNKNOWN_BROKEN'] |
| 24 | 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] | 25 | msg = "" |
| 26 | if len(regressed_failures) > 0: |
| 27 | msg = msg + """ |
| 28 | The following packages failed upstream version checks. Please fix them using UPSTREAM_CHECK_URI/UPSTREAM_CHECK_REGEX |
| 29 | (when using tarballs) or UPSTREAM_CHECK_GITTAGREGEX (when using git). If an upstream version check cannot be performed |
| 30 | (for example, if upstream does not use git tags), you can set UPSTREAM_VERSION_UNKNOWN to '1' in the recipe to acknowledge |
| 31 | that the check cannot be performed. |
| 32 | """ + "\n".join(regressed_failures) |
| 33 | if len(regressed_successes) > 0: |
| 34 | msg = msg + """ |
| 35 | The following packages have been checked successfully for upstream versions, |
| 36 | but their recipes claim otherwise by setting UPSTREAM_VERSION_UNKNOWN. Please remove that line from the recipes. |
| 37 | """ + "\n".join(regressed_successes) |
| 38 | self.assertTrue(len(regressed_failures) == 0 and len(regressed_successes) == 0, msg) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 39 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 40 | def test_missing_homepg(self): |
| 41 | """ |
| 42 | Summary: Test for oe-core recipes that don't have a HOMEPAGE or DESCRIPTION |
| 43 | Expected: All oe-core recipes should have a DESCRIPTION entry |
| 44 | Expected: All oe-core recipes should have a HOMEPAGE entry except for recipes that are not fetched from external sources. |
| 45 | Product: oe-core |
| 46 | """ |
| 47 | with bb.tinfoil.Tinfoil() as tinfoil: |
| 48 | tinfoil.prepare(config_only=False) |
| 49 | no_description = [] |
| 50 | no_homepage = [] |
| 51 | for fn in tinfoil.all_recipe_files(variants=False): |
| 52 | if not '/meta/recipes-' in fn: |
| 53 | # We are only interested in OE-Core |
| 54 | continue |
| 55 | rd = tinfoil.parse_recipe_file(fn, appends=False) |
| 56 | pn = rd.getVar('BPN') |
| 57 | srcfile = rd.getVar('SRC_URI').split() |
| 58 | #Since DESCRIPTION defaults to SUMMARY if not set, we are only interested in recipes without DESCRIPTION or SUMMARY |
| 59 | if not (rd.getVar('SUMMARY') or rd.getVar('DESCRIPTION')): |
| 60 | no_description.append((pn, fn)) |
| 61 | if not rd.getVar('HOMEPAGE'): |
| 62 | if srcfile and srcfile[0].startswith('file') or not rd.getVar('SRC_URI'): |
| 63 | # We are only interested in recipes SRC_URI fetched from external sources |
| 64 | continue |
| 65 | no_homepage.append((pn, fn)) |
| 66 | if no_homepage: |
| 67 | self.fail(""" |
| 68 | The following recipes do not have a HOMEPAGE. Please add an entry for HOMEPAGE in the recipe. |
| 69 | """ + "\n".join(['%s (%s)' % i for i in no_homepage])) |
| 70 | |
| 71 | if no_description: |
| 72 | self.fail(""" |
| 73 | The following recipes do not have a DESCRIPTION. Please add an entry for DESCRIPTION in the recipe. |
| 74 | """ + "\n".join(['%s (%s)' % i for i in no_description])) |
| 75 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 76 | def test_maintainers(self): |
| 77 | """ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 78 | 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] | 79 | 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] | 80 | 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] | 81 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 82 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 83 | """ |
| 84 | def is_exception(pkg): |
| 85 | exceptions = ["packagegroup-", "initramfs-", "systemd-machine-units", "target-sdk-provides-dummy"] |
| 86 | for i in exceptions: |
| 87 | if i in pkg: |
| 88 | return True |
| 89 | return False |
| 90 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 91 | def is_maintainer_exception(entry): |
| 92 | exceptions = ["musl", "newlib", "linux-yocto", "linux-dummy", "mesa-gl", "libgfortran", |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 93 | "cve-update-db-native", "rust"] |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 94 | for i in exceptions: |
| 95 | if i in entry: |
| 96 | return True |
| 97 | return False |
| 98 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 99 | 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] | 100 | self.write_config(feature) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 101 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 102 | with bb.tinfoil.Tinfoil() as tinfoil: |
| 103 | tinfoil.prepare(config_only=False) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 104 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 105 | with_maintainer_list = [] |
| 106 | no_maintainer_list = [] |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 107 | |
| 108 | missing_recipes = [] |
| 109 | recipes = [] |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 110 | prefix = "RECIPE_MAINTAINER:pn-" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 111 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 112 | # We could have used all_recipes() here, but this method will find |
| 113 | # every recipe if we ever move to setting RECIPE_MAINTAINER in recipe files |
| 114 | # instead of maintainers.inc |
| 115 | for fn in tinfoil.all_recipe_files(variants=False): |
| 116 | if not '/meta/recipes-' in fn: |
| 117 | # We are only interested in OE-Core |
| 118 | continue |
| 119 | rd = tinfoil.parse_recipe_file(fn, appends=False) |
| 120 | pn = rd.getVar('PN') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 121 | recipes.append(pn) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 122 | if is_exception(pn): |
| 123 | continue |
| 124 | if rd.getVar('RECIPE_MAINTAINER'): |
| 125 | with_maintainer_list.append((pn, fn)) |
| 126 | else: |
| 127 | no_maintainer_list.append((pn, fn)) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 128 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 129 | maintainers = tinfoil.config_data.keys() |
| 130 | for key in maintainers: |
| 131 | if key.startswith(prefix): |
| 132 | recipe = tinfoil.config_data.expand(key[len(prefix):]) |
| 133 | if is_maintainer_exception(recipe): |
| 134 | continue |
| 135 | if recipe not in recipes: |
| 136 | missing_recipes.append(recipe) |
| 137 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 138 | if no_maintainer_list: |
| 139 | self.fail(""" |
| 140 | The following recipes do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file. |
| 141 | """ + "\n".join(['%s (%s)' % i for i in no_maintainer_list])) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 142 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 143 | if not with_maintainer_list: |
| 144 | self.fail(""" |
| 145 | The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing. |
| 146 | """) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 147 | |
| 148 | if missing_recipes: |
| 149 | self.fail(""" |
| 150 | Unable to find recipes for the following entries in maintainers.inc: |
| 151 | """ + "\n".join(['%s' % i for i in missing_recipes])) |