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 | |
| 42 | def test_maintainers(self): |
| 43 | """ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 44 | 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] | 45 | 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] | 46 | 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] | 47 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 49 | """ |
| 50 | def is_exception(pkg): |
Andrew Geissler | 028142b | 2023-05-05 11:29:21 -0500 | [diff] [blame] | 51 | exceptions = ["packagegroup-",] |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 52 | for i in exceptions: |
| 53 | if i in pkg: |
| 54 | return True |
| 55 | return False |
| 56 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 57 | def is_maintainer_exception(entry): |
Andrew Geissler | 028142b | 2023-05-05 11:29:21 -0500 | [diff] [blame] | 58 | 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] | 59 | "cve-update-nvd2-native",] |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 60 | for i in exceptions: |
| 61 | if i in entry: |
| 62 | return True |
| 63 | return False |
| 64 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 65 | 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] | 66 | self.write_config(feature) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 67 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 68 | with bb.tinfoil.Tinfoil() as tinfoil: |
| 69 | tinfoil.prepare(config_only=False) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 70 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 71 | with_maintainer_list = [] |
| 72 | no_maintainer_list = [] |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 73 | |
| 74 | missing_recipes = [] |
| 75 | recipes = [] |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 76 | prefix = "RECIPE_MAINTAINER:pn-" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 77 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 78 | # 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 87 | recipes.append(pn) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 88 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 94 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 95 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 104 | if no_maintainer_list: |
| 105 | self.fail(""" |
| 106 | The 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 108 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 109 | if not with_maintainer_list: |
| 110 | self.fail(""" |
| 111 | The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing. |
| 112 | """) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 113 | |
| 114 | if missing_recipes: |
| 115 | self.fail(""" |
| 116 | Unable to find recipes for the following entries in maintainers.inc: |
| 117 | """ + "\n".join(['%s' % i for i in missing_recipes])) |