distrodata.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. class Distrodata(OESelftestTestCase):
  7. @classmethod
  8. def setUpClass(cls):
  9. super(Distrodata, cls).setUpClass()
  10. feature = 'INHERIT += "distrodata"\n'
  11. feature += 'LICENSE_FLAGS_WHITELIST += " commercial"\n'
  12. cls.write_config(cls, feature)
  13. bitbake('-c checkpkg world')
  14. @OETestID(1902)
  15. def test_checkpkg(self):
  16. """
  17. Summary: Test that upstream version checks do not regress
  18. Expected: Upstream version checks should succeed except for the recipes listed in the exception list.
  19. Product: oe-core
  20. Author: Alexander Kanavin <alex.kanavin@gmail.com>
  21. """
  22. checkpkg_result = open(os.path.join(get_bb_var("LOG_DIR"), "checkpkg.csv")).readlines()[1:]
  23. regressed_failures = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] if pkg_data[11] == 'UNKNOWN_BROKEN']
  24. regressed_successes = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] if pkg_data[11] == 'KNOWN_BROKEN']
  25. msg = ""
  26. if len(regressed_failures) > 0:
  27. msg = msg + """
  28. The following packages failed upstream version checks. Please fix them using UPSTREAM_CHECK_URI/UPSTREAM_CHECK_REGEX
  29. (when using tarballs) or UPSTREAM_CHECK_GITTAGREGEX (when using git). If an upstream version check cannot be performed
  30. (for example, if upstream does not use git tags), you can set UPSTREAM_VERSION_UNKNOWN to '1' in the recipe to acknowledge
  31. that the check cannot be performed.
  32. """ + "\n".join(regressed_failures)
  33. if len(regressed_successes) > 0:
  34. msg = msg + """
  35. The following packages have been checked successfully for upstream versions,
  36. but their recipes claim otherwise by setting UPSTREAM_VERSION_UNKNOWN. Please remove that line from the recipes.
  37. """ + "\n".join(regressed_successes)
  38. self.assertTrue(len(regressed_failures) == 0 and len(regressed_successes) == 0, msg)
  39. def test_maintainers(self):
  40. """
  41. Summary: Test that oe-core recipes have a maintainer
  42. Expected: All oe-core recipes (except a few special static/testing ones) should have a maintainer listed in maintainers.inc file.
  43. Product: oe-core
  44. Author: Alexander Kanavin <alex.kanavin@gmail.com>
  45. """
  46. def is_exception(pkg):
  47. exceptions = ["packagegroup-", "initramfs-", "systemd-machine-units", "target-sdk-provides-dummy"]
  48. for i in exceptions:
  49. if i in pkg:
  50. return True
  51. return False
  52. def is_in_oe_core(recipe, recipes):
  53. self.assertTrue(recipe in recipes.keys(), "Recipe %s was not in 'bitbake-layers show-recipes' output" %(recipe))
  54. self.assertTrue(len(recipes[recipe]) > 0, "'bitbake-layers show-recipes' could not determine what layer(s) a recipe %s is in" %(recipe))
  55. try:
  56. recipes[recipe].index('meta')
  57. return True
  58. except ValueError:
  59. return False
  60. def get_recipe_layers():
  61. import re
  62. recipes = {}
  63. recipe_regex = re.compile('^(?P<name>.*):$')
  64. layer_regex = re.compile('^ (?P<name>\S*) +')
  65. output = runCmd('bitbake-layers show-recipes').output
  66. for line in output.split('\n'):
  67. recipe_name_obj = recipe_regex.search(line)
  68. if recipe_name_obj:
  69. recipe_name = recipe_name_obj.group('name')
  70. recipes[recipe_name] = []
  71. recipe_layer_obj = layer_regex.search(line)
  72. if recipe_layer_obj:
  73. layer_name = recipe_layer_obj.group('name')
  74. recipes[recipe_name].append(layer_name)
  75. return recipes
  76. checkpkg_result = open(os.path.join(get_bb_var("LOG_DIR"), "checkpkg.csv")).readlines()[1:]
  77. recipes_layers = get_recipe_layers()
  78. no_maintainer_list = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] \
  79. if pkg_data[14] == '' and is_in_oe_core(pkg_data[0], recipes_layers) and not is_exception(pkg_data[0])]
  80. msg = """
  81. The following packages do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file.
  82. """ + "\n".join(no_maintainer_list)
  83. self.assertTrue(len(no_maintainer_list) == 0, msg)
  84. with_maintainer_list = [pkg_data[0] for pkg_data in [pkg_line.split('\t') for pkg_line in checkpkg_result] \
  85. if pkg_data[14] != '' and is_in_oe_core(pkg_data[0], recipes_layers) and not is_exception(pkg_data[0])]
  86. msg = """
  87. The list of oe-core packages with maintainers is empty. This may indicate that the test has regressed and needs fixing.
  88. """
  89. self.assertTrue(len(with_maintainer_list) > 0, msg)