archiver.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import os
  2. import glob
  3. from oeqa.utils.commands import bitbake, get_bb_vars
  4. from oeqa.selftest.case import OESelftestTestCase
  5. class Archiver(OESelftestTestCase):
  6. def test_archiver_allows_to_filter_on_recipe_name(self):
  7. """
  8. Summary: The archiver should offer the possibility to filter on the recipe. (#6929)
  9. Expected: 1. Included recipe (busybox) should be included
  10. 2. Excluded recipe (zlib) should be excluded
  11. Product: oe-core
  12. Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
  13. AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
  14. """
  15. include_recipe = 'busybox'
  16. exclude_recipe = 'zlib'
  17. features = 'INHERIT += "archiver"\n'
  18. features += 'ARCHIVER_MODE[src] = "original"\n'
  19. features += 'COPYLEFT_PN_INCLUDE = "%s"\n' % include_recipe
  20. features += 'COPYLEFT_PN_EXCLUDE = "%s"\n' % exclude_recipe
  21. self.write_config(features)
  22. bitbake('-c clean %s %s' % (include_recipe, exclude_recipe))
  23. bitbake("-c deploy_archives %s %s" % (include_recipe, exclude_recipe))
  24. bb_vars = get_bb_vars(['DEPLOY_DIR_SRC', 'TARGET_SYS'])
  25. src_path = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['TARGET_SYS'])
  26. # Check that include_recipe was included
  27. included_present = len(glob.glob(src_path + '/%s-*' % include_recipe))
  28. self.assertTrue(included_present, 'Recipe %s was not included.' % include_recipe)
  29. # Check that exclude_recipe was excluded
  30. excluded_present = len(glob.glob(src_path + '/%s-*' % exclude_recipe))
  31. self.assertFalse(excluded_present, 'Recipe %s was not excluded.' % exclude_recipe)
  32. def test_archiver_filters_by_type(self):
  33. """
  34. Summary: The archiver is documented to filter on the recipe type.
  35. Expected: 1. included recipe type (target) should be included
  36. 2. other types should be excluded
  37. Product: oe-core
  38. Author: André Draszik <adraszik@tycoint.com>
  39. """
  40. target_recipe = 'initscripts'
  41. native_recipe = 'zlib-native'
  42. features = 'INHERIT += "archiver"\n'
  43. features += 'ARCHIVER_MODE[src] = "original"\n'
  44. features += 'COPYLEFT_RECIPE_TYPES = "target"\n'
  45. self.write_config(features)
  46. bitbake('-c clean %s %s' % (target_recipe, native_recipe))
  47. bitbake("%s -c deploy_archives %s" % (target_recipe, native_recipe))
  48. bb_vars = get_bb_vars(['DEPLOY_DIR_SRC', 'TARGET_SYS', 'BUILD_SYS'])
  49. src_path_target = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['TARGET_SYS'])
  50. src_path_native = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['BUILD_SYS'])
  51. # Check that target_recipe was included
  52. included_present = len(glob.glob(src_path_target + '/%s-*' % target_recipe))
  53. self.assertTrue(included_present, 'Recipe %s was not included.' % target_recipe)
  54. # Check that native_recipe was excluded
  55. excluded_present = len(glob.glob(src_path_native + '/%s-*' % native_recipe))
  56. self.assertFalse(excluded_present, 'Recipe %s was not excluded.' % native_recipe)
  57. def test_archiver_filters_by_type_and_name(self):
  58. """
  59. Summary: Test that the archiver archives by recipe type, taking the
  60. recipe name into account.
  61. Expected: 1. included recipe type (target) should be included
  62. 2. other types should be excluded
  63. 3. recipe by name should be included / excluded,
  64. overriding previous decision by type
  65. Product: oe-core
  66. Author: André Draszik <adraszik@tycoint.com>
  67. """
  68. target_recipes = [ 'initscripts', 'zlib' ]
  69. native_recipes = [ 'update-rc.d-native', 'zlib-native' ]
  70. features = 'INHERIT += "archiver"\n'
  71. features += 'ARCHIVER_MODE[src] = "original"\n'
  72. features += 'COPYLEFT_RECIPE_TYPES = "target"\n'
  73. features += 'COPYLEFT_PN_INCLUDE = "%s"\n' % native_recipes[1]
  74. features += 'COPYLEFT_PN_EXCLUDE = "%s"\n' % target_recipes[1]
  75. self.write_config(features)
  76. bitbake('-c clean %s %s' % (' '.join(target_recipes), ' '.join(native_recipes)))
  77. bitbake('-c deploy_archives %s %s' % (' '.join(target_recipes), ' '.join(native_recipes)))
  78. bb_vars = get_bb_vars(['DEPLOY_DIR_SRC', 'TARGET_SYS', 'BUILD_SYS'])
  79. src_path_target = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['TARGET_SYS'])
  80. src_path_native = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['BUILD_SYS'])
  81. # Check that target_recipe[0] and native_recipes[1] were included
  82. included_present = len(glob.glob(src_path_target + '/%s-*' % target_recipes[0]))
  83. self.assertTrue(included_present, 'Recipe %s was not included.' % target_recipes[0])
  84. included_present = len(glob.glob(src_path_native + '/%s-*' % native_recipes[1]))
  85. self.assertTrue(included_present, 'Recipe %s was not included.' % native_recipes[1])
  86. # Check that native_recipes[0] and target_recipes[1] were excluded
  87. excluded_present = len(glob.glob(src_path_native + '/%s-*' % native_recipes[0]))
  88. self.assertFalse(excluded_present, 'Recipe %s was not excluded.' % native_recipes[0])
  89. excluded_present = len(glob.glob(src_path_target + '/%s-*' % target_recipes[1]))
  90. self.assertFalse(excluded_present, 'Recipe %s was not excluded.' % target_recipes[1])
  91. def test_archiver_srpm_mode(self):
  92. """
  93. Test that in srpm mode, the added recipe dependencies at least exist/work [YOCTO #11121]
  94. """
  95. features = 'INHERIT += "archiver"\n'
  96. features += 'ARCHIVER_MODE[srpm] = "1"\n'
  97. self.write_config(features)
  98. bitbake('-n core-image-sato')