summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/recipetool.py
diff options
context:
space:
mode:
authorJulien Stephan <jstephan@baylibre.com>2023-12-05 15:56:35 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-06 22:55:50 +0000
commit7ff486d556e691f06590d5047c0d0080c9049d52 (patch)
tree25c44b2c7fc0348924c11cbc3fc848a22d02730d /meta/lib/oeqa/selftest/cases/recipetool.py
parentbc9291c5fd2514adbb598da425ab82b80838f8b6 (diff)
downloadpoky-7ff486d556e691f06590d5047c0d0080c9049d52.tar.gz
oeqa/selftest/recipetool: appendsrfile: add test for machine
Add a new test for machine specific bbappend override (From OE-Core rev: 1c510a21487fa71e88eb46e9a0de00a82a7ba4e4) Signed-off-by: Julien Stephan <jstephan@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/recipetool.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/recipetool.py44
1 files changed, 38 insertions, 6 deletions
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index fa3bfa4625..a55d7dea15 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -1110,7 +1110,7 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
1110 if p.scheme == 'file': 1110 if p.scheme == 'file':
1111 return p.netloc + p.path, uri 1111 return p.netloc + p.path, uri
1112 1112
1113 def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, options=''): 1113 def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, machine=None , options=''):
1114 if newfile is None: 1114 if newfile is None:
1115 newfile = self.testfile 1115 newfile = self.testfile
1116 1116
@@ -1138,17 +1138,39 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
1138 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', 1138 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
1139 '\n'] 1139 '\n']
1140 1140
1141 override = ""
1142 if machine:
1143 options += ' -m %s' % machine
1144 override = ':append:%s' % machine
1145 expectedlines.extend(['PACKAGE_ARCH = "${MACHINE_ARCH}"\n',
1146 '\n'])
1147
1141 if remove: 1148 if remove:
1142 for entry in remove: 1149 for entry in remove:
1143 expectedlines.extend(['SRC_URI:remove = "%s"\n' % entry, 1150 if machine:
1151 entry_remove_line = 'SRC_URI:remove:%s = " %s"\n' % (machine, entry)
1152 else:
1153 entry_remove_line = 'SRC_URI:remove = "%s"\n' % entry
1154
1155 expectedlines.extend([entry_remove_line,
1144 '\n']) 1156 '\n'])
1145 1157
1146 if has_src_uri: 1158 if has_src_uri:
1147 uri = 'file://%s' % filename 1159 uri = 'file://%s' % filename
1148 if expected_subdir: 1160 if expected_subdir:
1149 uri += ';subdir=%s' % expected_subdir 1161 uri += ';subdir=%s' % expected_subdir
1150 expectedlines.extend(['SRC_URI += "%s"\n' % uri, 1162 if machine:
1151 '\n']) 1163 src_uri_line = 'SRC_URI%s = " %s"\n' % (override, uri)
1164 else:
1165 src_uri_line = 'SRC_URI += "%s"\n' % uri
1166
1167 expectedlines.extend([src_uri_line, '\n'])
1168
1169 with open("/tmp/tmp.txt", "w") as file:
1170 print(expectedlines, file=file)
1171
1172 if machine:
1173 filename = '%s/%s' % (machine, filename)
1152 1174
1153 return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename]) 1175 return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename])
1154 1176
@@ -1207,13 +1229,23 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase):
1207 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe) 1229 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
1208 self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False) 1230 self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False)
1209 1231
1210 def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self): 1232 def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self, machine=None):
1211 testrecipe = 'base-files' 1233 testrecipe = 'base-files'
1212 subdir = 'tmp' 1234 subdir = 'tmp'
1213 filepath, srcuri_entry = self._get_first_file_uri(testrecipe) 1235 filepath, srcuri_entry = self._get_first_file_uri(testrecipe)
1214 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe) 1236 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
1215 1237
1216 self._test_appendsrcfile(testrecipe, filepath, subdir, remove=[srcuri_entry]) 1238 self._test_appendsrcfile(testrecipe, filepath, subdir, machine=machine, remove=[srcuri_entry])
1239
1240 def test_recipetool_appendsrcfile_machine(self):
1241 # A very basic test
1242 self._test_appendsrcfile('base-files', 'a-file', machine='mymachine')
1243
1244 # Force cleaning the output of previous test
1245 self.tearDownLocal()
1246
1247 # A more complex test: existing entry in src_uri with different param
1248 self.test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(machine='mymachine')
1217 1249
1218 def test_recipetool_appendsrcfile_replace_file_srcdir(self): 1250 def test_recipetool_appendsrcfile_replace_file_srcdir(self):
1219 testrecipe = 'bash' 1251 testrecipe = 'bash'