Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | from oeqa.selftest.case import OESelftestTestCase |
| 2 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars |
| 3 | from oeqa.utils.decorators import testcase |
| 4 | from oeqa.utils.ftools import write_file |
| 5 | from oeqa.core.decorator.oeid import OETestID |
| 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 | @OETestID(1902) |
| 12 | def test_checkpkg(self): |
| 13 | """ |
| 14 | Summary: Test that upstream version checks do not regress |
| 15 | Expected: Upstream version checks should succeed except for the recipes listed in the exception list. |
| 16 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 17 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 18 | """ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 19 | feature = 'LICENSE_FLAGS_WHITELIST += " commercial"\n' |
| 20 | self.write_config(feature) |
| 21 | |
| 22 | pkgs = oe.recipeutils.get_recipe_upgrade_status() |
| 23 | |
| 24 | regressed_failures = [pkg[0] for pkg in pkgs if pkg[1] == 'UNKNOWN_BROKEN'] |
| 25 | 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] | 26 | msg = "" |
| 27 | if len(regressed_failures) > 0: |
| 28 | msg = msg + """ |
| 29 | The following packages failed upstream version checks. Please fix them using UPSTREAM_CHECK_URI/UPSTREAM_CHECK_REGEX |
| 30 | (when using tarballs) or UPSTREAM_CHECK_GITTAGREGEX (when using git). If an upstream version check cannot be performed |
| 31 | (for example, if upstream does not use git tags), you can set UPSTREAM_VERSION_UNKNOWN to '1' in the recipe to acknowledge |
| 32 | that the check cannot be performed. |
| 33 | """ + "\n".join(regressed_failures) |
| 34 | if len(regressed_successes) > 0: |
| 35 | msg = msg + """ |
| 36 | The following packages have been checked successfully for upstream versions, |
| 37 | but their recipes claim otherwise by setting UPSTREAM_VERSION_UNKNOWN. Please remove that line from the recipes. |
| 38 | """ + "\n".join(regressed_successes) |
| 39 | self.assertTrue(len(regressed_failures) == 0 and len(regressed_successes) == 0, msg) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | |
| 41 | def test_maintainers(self): |
| 42 | """ |
| 43 | Summary: Test that oe-core recipes have a maintainer |
| 44 | Expected: All oe-core recipes (except a few special static/testing ones) should have a maintainer listed in maintainers.inc file. |
| 45 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 46 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 47 | """ |
| 48 | def is_exception(pkg): |
| 49 | exceptions = ["packagegroup-", "initramfs-", "systemd-machine-units", "target-sdk-provides-dummy"] |
| 50 | for i in exceptions: |
| 51 | if i in pkg: |
| 52 | return True |
| 53 | return False |
| 54 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 55 | feature = 'require conf/distro/include/maintainers.inc\n' |
| 56 | self.write_config(feature) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 57 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | with bb.tinfoil.Tinfoil() as tinfoil: |
| 59 | tinfoil.prepare(config_only=False) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 60 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 61 | with_maintainer_list = [] |
| 62 | no_maintainer_list = [] |
| 63 | # We could have used all_recipes() here, but this method will find |
| 64 | # every recipe if we ever move to setting RECIPE_MAINTAINER in recipe files |
| 65 | # instead of maintainers.inc |
| 66 | for fn in tinfoil.all_recipe_files(variants=False): |
| 67 | if not '/meta/recipes-' in fn: |
| 68 | # We are only interested in OE-Core |
| 69 | continue |
| 70 | rd = tinfoil.parse_recipe_file(fn, appends=False) |
| 71 | pn = rd.getVar('PN') |
| 72 | if is_exception(pn): |
| 73 | continue |
| 74 | if rd.getVar('RECIPE_MAINTAINER'): |
| 75 | with_maintainer_list.append((pn, fn)) |
| 76 | else: |
| 77 | no_maintainer_list.append((pn, fn)) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 78 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 79 | if no_maintainer_list: |
| 80 | self.fail(""" |
| 81 | The following recipes do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file. |
| 82 | """ + "\n".join(['%s (%s)' % i for i in no_maintainer_list])) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 83 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 84 | if not with_maintainer_list: |
| 85 | self.fail(""" |
| 86 | The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing. |
| 87 | """) |