blob: 0b454714e956edcd718e796f6ae72b61c6d35265 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001from oeqa.selftest.case import OESelftestTestCase
2from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
3from oeqa.utils.decorators import testcase
4from oeqa.utils.ftools import write_file
5from oeqa.core.decorator.oeid import OETestID
6
Brad Bishop19323692019-04-05 15:28:33 -04007import oe.recipeutils
8
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009class Distrodata(OESelftestTestCase):
10
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011 @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 Bishop1a4b7ee2018-12-16 17:11:34 -080017 Author: Alexander Kanavin <alex.kanavin@gmail.com>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018 """
Brad Bishop19323692019-04-05 15:28:33 -040019 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 Bishopd7bf8c12018-02-25 22:55:05 -050026 msg = ""
27 if len(regressed_failures) > 0:
28 msg = msg + """
29The 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
32that the check cannot be performed.
33""" + "\n".join(regressed_failures)
34 if len(regressed_successes) > 0:
35 msg = msg + """
36The following packages have been checked successfully for upstream versions,
37but 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 Bishop316dfdd2018-06-25 12:45:53 -040040
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 Bishop1a4b7ee2018-12-16 17:11:34 -080046 Author: Alexander Kanavin <alex.kanavin@gmail.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040047 """
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 Bishop19323692019-04-05 15:28:33 -040055 feature = 'require conf/distro/include/maintainers.inc\n'
56 self.write_config(feature)
Brad Bishop316dfdd2018-06-25 12:45:53 -040057
Brad Bishop19323692019-04-05 15:28:33 -040058 with bb.tinfoil.Tinfoil() as tinfoil:
59 tinfoil.prepare(config_only=False)
Brad Bishop316dfdd2018-06-25 12:45:53 -040060
Brad Bishop19323692019-04-05 15:28:33 -040061 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 Bishop316dfdd2018-06-25 12:45:53 -040078
Brad Bishop19323692019-04-05 15:28:33 -040079 if no_maintainer_list:
80 self.fail("""
81The 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 Bishop316dfdd2018-06-25 12:45:53 -040083
Brad Bishop19323692019-04-05 15:28:33 -040084 if not with_maintainer_list:
85 self.fail("""
86The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing.
87""")