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