distrodata.py 3.8 KB

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