distrodata.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. from oeqa.selftest.case import OESelftestTestCase
  7. import oe.recipeutils
  8. class Distrodata(OESelftestTestCase):
  9. def test_checkpkg(self):
  10. """
  11. Summary: Test that upstream version checks do not regress
  12. Expected: Upstream version checks should succeed except for the recipes listed in the exception list.
  13. Product: oe-core
  14. Author: Alexander Kanavin <alex.kanavin@gmail.com>
  15. """
  16. feature = 'LICENSE_FLAGS_ACCEPTED += " commercial"\n'
  17. self.write_config(feature)
  18. pkggroups = oe.recipeutils.get_recipe_upgrade_status()
  19. regressed_failures = [pkg['pn'] for pkgs in pkggroups for pkg in pkgs if pkg['status'] == 'UNKNOWN_BROKEN']
  20. regressed_successes = [pkg['pn'] for pkgs in pkggroups for pkg in pkgs if pkg['status'] == 'KNOWN_BROKEN']
  21. msg = ""
  22. if len(regressed_failures) > 0:
  23. msg = msg + """
  24. The following packages failed upstream version checks. Please fix them using UPSTREAM_CHECK_URI/UPSTREAM_CHECK_REGEX
  25. (when using tarballs) or UPSTREAM_CHECK_GITTAGREGEX (when using git). If an upstream version check cannot be performed
  26. (for example, if upstream does not use git tags), you can set UPSTREAM_VERSION_UNKNOWN to '1' in the recipe to acknowledge
  27. that the check cannot be performed.
  28. """ + "\n".join(regressed_failures)
  29. if len(regressed_successes) > 0:
  30. msg = msg + """
  31. The following packages have been checked successfully for upstream versions,
  32. but their recipes claim otherwise by setting UPSTREAM_VERSION_UNKNOWN. Please remove that line from the recipes.
  33. """ + "\n".join(regressed_successes)
  34. self.assertTrue(len(regressed_failures) == 0 and len(regressed_successes) == 0, msg)
  35. def test_maintainers(self):
  36. """
  37. Summary: Test that oe-core recipes have a maintainer and entries in maintainers list have a recipe
  38. Expected: All oe-core recipes (except a few special static/testing ones) should have a maintainer listed in maintainers.inc file.
  39. Expected: All entries in maintainers list should have a recipe file that matches them
  40. Product: oe-core
  41. Author: Alexander Kanavin <alex.kanavin@gmail.com>
  42. """
  43. def is_exception(pkg):
  44. exceptions = ["packagegroup-",]
  45. for i in exceptions:
  46. if i in pkg:
  47. return True
  48. return False
  49. def is_maintainer_exception(entry):
  50. exceptions = ["musl", "newlib", "picolibc", "linux-yocto", "linux-dummy", "mesa-gl", "libgfortran", "libx11-compose-data",
  51. "cve-update-nvd2-native", "barebox"]
  52. for i in exceptions:
  53. if i in entry:
  54. return True
  55. return False
  56. feature = 'require conf/distro/include/maintainers.inc\nLICENSE_FLAGS_ACCEPTED += " commercial"\nPARSE_ALL_RECIPES = "1"\nPACKAGE_CLASSES = "package_ipk package_deb package_rpm"\n'
  57. self.write_config(feature)
  58. with bb.tinfoil.Tinfoil() as tinfoil:
  59. tinfoil.prepare(config_only=False)
  60. with_maintainer_list = []
  61. no_maintainer_list = []
  62. missing_recipes = []
  63. recipes = []
  64. prefix = "RECIPE_MAINTAINER:pn-"
  65. # We could have used all_recipes() here, but this method will find
  66. # every recipe if we ever move to setting RECIPE_MAINTAINER in recipe files
  67. # instead of maintainers.inc
  68. for fn in tinfoil.all_recipe_files(variants=False):
  69. if not '/meta/recipes-' in fn:
  70. # We are only interested in OE-Core
  71. continue
  72. rd = tinfoil.parse_recipe_file(fn, appends=False)
  73. pn = rd.getVar('PN')
  74. recipes.append(pn)
  75. if is_exception(pn):
  76. continue
  77. if rd.getVar('RECIPE_MAINTAINER'):
  78. with_maintainer_list.append((pn, fn))
  79. else:
  80. no_maintainer_list.append((pn, fn))
  81. maintainers = tinfoil.config_data.keys()
  82. for key in maintainers:
  83. if key.startswith(prefix):
  84. recipe = tinfoil.config_data.expand(key[len(prefix):])
  85. if is_maintainer_exception(recipe):
  86. continue
  87. if recipe not in recipes:
  88. missing_recipes.append(recipe)
  89. if no_maintainer_list:
  90. self.fail("""
  91. The following recipes do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file.
  92. """ + "\n".join(['%s (%s)' % i for i in no_maintainer_list]))
  93. if not with_maintainer_list:
  94. self.fail("""
  95. The list of oe-core recipes with maintainers is empty. This may indicate that the test has regressed and needs fixing.
  96. """)
  97. if missing_recipes:
  98. self.fail("""
  99. Unable to find recipes for the following entries in maintainers.inc:
  100. """ + "\n".join(['%s' % i for i in missing_recipes]))
  101. def test_common_include_recipes(self):
  102. """
  103. Summary: Test that obtaining recipes that share includes between them returns a sane result
  104. Expected: At least cmake and qemu entries are present in the output
  105. Product: oe-core
  106. Author: Alexander Kanavin <alex.kanavin@gmail.com>
  107. """
  108. recipes = oe.recipeutils.get_common_include_recipes()
  109. self.assertIn({'qemu-system-native', 'qemu', 'qemu-native'}, recipes)
  110. self.assertIn({'cmake-native', 'cmake'}, recipes)