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