blob: f8672f8abbab95e05533746fcb7bab498134c208 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005import os
6import glob
7from oeqa.utils.commands import bitbake, get_bb_vars
8from oeqa.selftest.case import OESelftestTestCase
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009
10class Archiver(OESelftestTestCase):
11
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012 def test_archiver_allows_to_filter_on_recipe_name(self):
13 """
14 Summary: The archiver should offer the possibility to filter on the recipe. (#6929)
15 Expected: 1. Included recipe (busybox) should be included
16 2. Excluded recipe (zlib) should be excluded
17 Product: oe-core
18 Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
19 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
20 """
21
22 include_recipe = 'busybox'
23 exclude_recipe = 'zlib'
24
25 features = 'INHERIT += "archiver"\n'
26 features += 'ARCHIVER_MODE[src] = "original"\n'
27 features += 'COPYLEFT_PN_INCLUDE = "%s"\n' % include_recipe
28 features += 'COPYLEFT_PN_EXCLUDE = "%s"\n' % exclude_recipe
29 self.write_config(features)
30
31 bitbake('-c clean %s %s' % (include_recipe, exclude_recipe))
32 bitbake("-c deploy_archives %s %s" % (include_recipe, exclude_recipe))
33
34 bb_vars = get_bb_vars(['DEPLOY_DIR_SRC', 'TARGET_SYS'])
35 src_path = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['TARGET_SYS'])
36
37 # Check that include_recipe was included
38 included_present = len(glob.glob(src_path + '/%s-*' % include_recipe))
39 self.assertTrue(included_present, 'Recipe %s was not included.' % include_recipe)
40
41 # Check that exclude_recipe was excluded
42 excluded_present = len(glob.glob(src_path + '/%s-*' % exclude_recipe))
43 self.assertFalse(excluded_present, 'Recipe %s was not excluded.' % exclude_recipe)
44
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045 def test_archiver_filters_by_type(self):
46 """
47 Summary: The archiver is documented to filter on the recipe type.
48 Expected: 1. included recipe type (target) should be included
49 2. other types should be excluded
50 Product: oe-core
51 Author: André Draszik <adraszik@tycoint.com>
52 """
53
54 target_recipe = 'initscripts'
55 native_recipe = 'zlib-native'
56
57 features = 'INHERIT += "archiver"\n'
58 features += 'ARCHIVER_MODE[src] = "original"\n'
59 features += 'COPYLEFT_RECIPE_TYPES = "target"\n'
60 self.write_config(features)
61
62 bitbake('-c clean %s %s' % (target_recipe, native_recipe))
63 bitbake("%s -c deploy_archives %s" % (target_recipe, native_recipe))
64
65 bb_vars = get_bb_vars(['DEPLOY_DIR_SRC', 'TARGET_SYS', 'BUILD_SYS'])
66 src_path_target = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['TARGET_SYS'])
67 src_path_native = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['BUILD_SYS'])
68
69 # Check that target_recipe was included
70 included_present = len(glob.glob(src_path_target + '/%s-*' % target_recipe))
71 self.assertTrue(included_present, 'Recipe %s was not included.' % target_recipe)
72
73 # Check that native_recipe was excluded
74 excluded_present = len(glob.glob(src_path_native + '/%s-*' % native_recipe))
75 self.assertFalse(excluded_present, 'Recipe %s was not excluded.' % native_recipe)
76
Brad Bishopd7bf8c12018-02-25 22:55:05 -050077 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])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400119
120
121
122 def test_archiver_srpm_mode(self):
123 """
124 Test that in srpm mode, the added recipe dependencies at least exist/work [YOCTO #11121]
125 """
126
127 features = 'INHERIT += "archiver"\n'
128 features += 'ARCHIVER_MODE[srpm] = "1"\n'
129 self.write_config(features)
130
131 bitbake('-n core-image-sato')