blob: c2a53815d0ea85207c9fe1e292a1bc3f0c5049dd [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 shutil
7import tempfile
8import urllib.parse
9
10from oeqa.utils.commands import runCmd, bitbake, get_bb_var
11from oeqa.utils.commands import get_bb_vars, create_temp_layer
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012from oeqa.selftest.cases import devtool
13
14templayerdir = None
15
16def setUpModule():
17 global templayerdir
18 templayerdir = tempfile.mkdtemp(prefix='recipetoolqa')
19 create_temp_layer(templayerdir, 'selftestrecipetool')
20 runCmd('bitbake-layers add-layer %s' % templayerdir)
21
22
23def tearDownModule():
24 runCmd('bitbake-layers remove-layer %s' % templayerdir, ignore_status=True)
25 runCmd('rm -rf %s' % templayerdir)
26
27
28class RecipetoolBase(devtool.DevtoolBase):
29
30 def setUpLocal(self):
31 super(RecipetoolBase, self).setUpLocal()
32 self.templayerdir = templayerdir
33 self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa')
34 self.track_for_cleanup(self.tempdir)
35 self.testfile = os.path.join(self.tempdir, 'testfile')
36 with open(self.testfile, 'w') as f:
37 f.write('Test file\n')
38
39 def tearDownLocal(self):
40 runCmd('rm -rf %s/recipes-*' % self.templayerdir)
41 super(RecipetoolBase, self).tearDownLocal()
42
43 def _try_recipetool_appendcmd(self, cmd, testrecipe, expectedfiles, expectedlines=None):
44 result = runCmd(cmd)
45 self.assertNotIn('Traceback', result.output)
46
47 # Check the bbappend was created and applies properly
48 recipefile = get_bb_var('FILE', testrecipe)
49 bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir)
50
51 # Check the bbappend contents
52 if expectedlines is not None:
53 with open(bbappendfile, 'r') as f:
54 self.assertEqual(expectedlines, f.readlines(), "Expected lines are not present in %s" % bbappendfile)
55
56 # Check file was copied
57 filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe)
58 for expectedfile in expectedfiles:
59 self.assertTrue(os.path.isfile(os.path.join(filesdir, expectedfile)), 'Expected file %s to be copied next to bbappend, but it wasn\'t' % expectedfile)
60
61 # Check no other files created
62 createdfiles = []
63 for root, _, files in os.walk(filesdir):
64 for f in files:
65 createdfiles.append(os.path.relpath(os.path.join(root, f), filesdir))
66 self.assertTrue(sorted(createdfiles), sorted(expectedfiles))
67
68 return bbappendfile, result.output
69
70
71class RecipetoolTests(RecipetoolBase):
72
73 @classmethod
74 def setUpClass(cls):
75 super(RecipetoolTests, cls).setUpClass()
76 # Ensure we have the right data in shlibs/pkgdata
77 cls.logger.info('Running bitbake to generate pkgdata')
78 bitbake('-c packagedata base-files coreutils busybox selftest-recipetool-appendfile')
79 bb_vars = get_bb_vars(['COREBASE', 'BBPATH'])
80 cls.corebase = bb_vars['COREBASE']
81 cls.bbpath = bb_vars['BBPATH']
82
83 def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles):
84 cmd = 'recipetool appendfile %s %s %s %s' % (self.templayerdir, destfile, newfile, options)
85 return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines)
86
87 def _try_recipetool_appendfile_fail(self, destfile, newfile, checkerror):
88 cmd = 'recipetool appendfile %s %s %s' % (self.templayerdir, destfile, newfile)
89 result = runCmd(cmd, ignore_status=True)
90 self.assertNotEqual(result.status, 0, 'Command "%s" should have failed but didn\'t' % cmd)
91 self.assertNotIn('Traceback', result.output)
92 for errorstr in checkerror:
93 self.assertIn(errorstr, result.output)
94
Brad Bishopd7bf8c12018-02-25 22:55:05 -050095 def test_recipetool_appendfile_basic(self):
96 # Basic test
Patrick Williams213cb262021-08-07 19:21:33 -050097 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -050098 '\n']
99 _, output = self._try_recipetool_appendfile('base-files', '/etc/motd', self.testfile, '', expectedlines, ['motd'])
100 self.assertNotIn('WARNING: ', output)
101
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500102 def test_recipetool_appendfile_invalid(self):
103 # Test some commands that should error
104 self._try_recipetool_appendfile_fail('/etc/passwd', self.testfile, ['ERROR: /etc/passwd cannot be handled by this tool', 'useradd', 'extrausers'])
105 self._try_recipetool_appendfile_fail('/etc/timestamp', self.testfile, ['ERROR: /etc/timestamp cannot be handled by this tool'])
106 self._try_recipetool_appendfile_fail('/dev/console', self.testfile, ['ERROR: /dev/console cannot be handled by this tool'])
107
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500108 def test_recipetool_appendfile_alternatives(self):
109 # Now try with a file we know should be an alternative
110 # (this is very much a fake example, but one we know is reliably an alternative)
111 self._try_recipetool_appendfile_fail('/bin/ls', self.testfile, ['ERROR: File /bin/ls is an alternative possibly provided by the following recipes:', 'coreutils', 'busybox'])
112 # Need a test file - should be executable
113 testfile2 = os.path.join(self.corebase, 'oe-init-build-env')
114 testfile2name = os.path.basename(testfile2)
Patrick Williams213cb262021-08-07 19:21:33 -0500115 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500116 '\n',
117 'SRC_URI += "file://%s"\n' % testfile2name,
118 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500119 'do_install:append() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500120 ' install -d ${D}${base_bindir}\n',
121 ' install -m 0755 ${WORKDIR}/%s ${D}${base_bindir}/ls\n' % testfile2name,
122 '}\n']
123 self._try_recipetool_appendfile('coreutils', '/bin/ls', testfile2, '-r coreutils', expectedlines, [testfile2name])
124 # Now try bbappending the same file again, contents should not change
125 bbappendfile, _ = self._try_recipetool_appendfile('coreutils', '/bin/ls', self.testfile, '-r coreutils', expectedlines, [testfile2name])
126 # But file should have
127 copiedfile = os.path.join(os.path.dirname(bbappendfile), 'coreutils', testfile2name)
128 result = runCmd('diff -q %s %s' % (testfile2, copiedfile), ignore_status=True)
129 self.assertNotEqual(result.status, 0, 'New file should have been copied but was not %s' % result.output)
130
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500131 def test_recipetool_appendfile_binary(self):
132 # Try appending a binary file
133 # /bin/ls can be a symlink to /usr/bin/ls
134 ls = os.path.realpath("/bin/ls")
135 result = runCmd('recipetool appendfile %s /bin/ls %s -r coreutils' % (self.templayerdir, ls))
136 self.assertIn('WARNING: ', result.output)
137 self.assertIn('is a binary', result.output)
138
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500139 def test_recipetool_appendfile_add(self):
140 # Try arbitrary file add to a recipe
Patrick Williams213cb262021-08-07 19:21:33 -0500141 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500142 '\n',
143 'SRC_URI += "file://testfile"\n',
144 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500145 'do_install:append() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500146 ' install -d ${D}${datadir}\n',
147 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n',
148 '}\n']
149 self._try_recipetool_appendfile('netbase', '/usr/share/something', self.testfile, '-r netbase', expectedlines, ['testfile'])
150 # Try adding another file, this time where the source file is executable
151 # (so we're testing that, plus modifying an existing bbappend)
152 testfile2 = os.path.join(self.corebase, 'oe-init-build-env')
153 testfile2name = os.path.basename(testfile2)
Patrick Williams213cb262021-08-07 19:21:33 -0500154 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500155 '\n',
156 'SRC_URI += "file://testfile \\\n',
157 ' file://%s \\\n' % testfile2name,
158 ' "\n',
159 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500160 'do_install:append() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500161 ' install -d ${D}${datadir}\n',
162 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n',
163 ' install -m 0755 ${WORKDIR}/%s ${D}${datadir}/scriptname\n' % testfile2name,
164 '}\n']
165 self._try_recipetool_appendfile('netbase', '/usr/share/scriptname', testfile2, '-r netbase', expectedlines, ['testfile', testfile2name])
166
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500167 def test_recipetool_appendfile_add_bindir(self):
168 # Try arbitrary file add to a recipe, this time to a location such that should be installed as executable
Patrick Williams213cb262021-08-07 19:21:33 -0500169 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500170 '\n',
171 'SRC_URI += "file://testfile"\n',
172 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500173 'do_install:append() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500174 ' install -d ${D}${bindir}\n',
175 ' install -m 0755 ${WORKDIR}/testfile ${D}${bindir}/selftest-recipetool-testbin\n',
176 '}\n']
177 _, output = self._try_recipetool_appendfile('netbase', '/usr/bin/selftest-recipetool-testbin', self.testfile, '-r netbase', expectedlines, ['testfile'])
178 self.assertNotIn('WARNING: ', output)
179
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500180 def test_recipetool_appendfile_add_machine(self):
181 # Try arbitrary file add to a recipe, this time to a location such that should be installed as executable
Patrick Williams213cb262021-08-07 19:21:33 -0500182 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500183 '\n',
184 'PACKAGE_ARCH = "${MACHINE_ARCH}"\n',
185 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500186 'SRC_URI:append:mymachine = " file://testfile"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500187 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500188 'do_install:append:mymachine() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500189 ' install -d ${D}${datadir}\n',
190 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n',
191 '}\n']
192 _, output = self._try_recipetool_appendfile('netbase', '/usr/share/something', self.testfile, '-r netbase -m mymachine', expectedlines, ['mymachine/testfile'])
193 self.assertNotIn('WARNING: ', output)
194
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500195 def test_recipetool_appendfile_orig(self):
196 # A file that's in SRC_URI and in do_install with the same name
Patrick Williams213cb262021-08-07 19:21:33 -0500197 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500198 '\n']
199 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-orig', self.testfile, '', expectedlines, ['selftest-replaceme-orig'])
200 self.assertNotIn('WARNING: ', output)
201
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500202 def test_recipetool_appendfile_todir(self):
203 # A file that's in SRC_URI and in do_install with destination directory rather than file
Patrick Williams213cb262021-08-07 19:21:33 -0500204 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500205 '\n']
206 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-todir', self.testfile, '', expectedlines, ['selftest-replaceme-todir'])
207 self.assertNotIn('WARNING: ', output)
208
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500209 def test_recipetool_appendfile_renamed(self):
210 # A file that's in SRC_URI with a different name to the destination file
Patrick Williams213cb262021-08-07 19:21:33 -0500211 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500212 '\n']
213 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-renamed', self.testfile, '', expectedlines, ['file1'])
214 self.assertNotIn('WARNING: ', output)
215
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500216 def test_recipetool_appendfile_subdir(self):
217 # A file that's in SRC_URI in a subdir
Patrick Williams213cb262021-08-07 19:21:33 -0500218 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500219 '\n',
220 'SRC_URI += "file://testfile"\n',
221 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500222 'do_install:append() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500223 ' install -d ${D}${datadir}\n',
224 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-subdir\n',
225 '}\n']
226 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-subdir', self.testfile, '', expectedlines, ['testfile'])
227 self.assertNotIn('WARNING: ', output)
228
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500229 def test_recipetool_appendfile_inst_glob(self):
230 # A file that's in do_install as a glob
Patrick Williams213cb262021-08-07 19:21:33 -0500231 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500232 '\n']
233 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-globfile', self.testfile, '', expectedlines, ['selftest-replaceme-inst-globfile'])
234 self.assertNotIn('WARNING: ', output)
235
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500236 def test_recipetool_appendfile_inst_todir_glob(self):
237 # A file that's in do_install as a glob with destination as a directory
Patrick Williams213cb262021-08-07 19:21:33 -0500238 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500239 '\n']
240 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-todir-globfile', self.testfile, '', expectedlines, ['selftest-replaceme-inst-todir-globfile'])
241 self.assertNotIn('WARNING: ', output)
242
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500243 def test_recipetool_appendfile_patch(self):
244 # A file that's added by a patch in SRC_URI
Patrick Williams213cb262021-08-07 19:21:33 -0500245 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500246 '\n',
247 'SRC_URI += "file://testfile"\n',
248 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500249 'do_install:append() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500250 ' install -d ${D}${sysconfdir}\n',
251 ' install -m 0644 ${WORKDIR}/testfile ${D}${sysconfdir}/selftest-replaceme-patched\n',
252 '}\n']
253 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/etc/selftest-replaceme-patched', self.testfile, '', expectedlines, ['testfile'])
254 for line in output.splitlines():
255 if 'WARNING: ' in line:
256 self.assertIn('add-file.patch', line, 'Unexpected warning found in output:\n%s' % line)
257 break
258 else:
259 self.fail('Patch warning not found in output:\n%s' % output)
260
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500261 def test_recipetool_appendfile_script(self):
262 # Now, a file that's in SRC_URI but installed by a script (so no mention in do_install)
Patrick Williams213cb262021-08-07 19:21:33 -0500263 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500264 '\n',
265 'SRC_URI += "file://testfile"\n',
266 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500267 'do_install:append() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500268 ' install -d ${D}${datadir}\n',
269 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-scripted\n',
270 '}\n']
271 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-scripted', self.testfile, '', expectedlines, ['testfile'])
272 self.assertNotIn('WARNING: ', output)
273
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500274 def test_recipetool_appendfile_inst_func(self):
275 # A file that's installed from a function called by do_install
Patrick Williams213cb262021-08-07 19:21:33 -0500276 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500277 '\n']
278 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-func', self.testfile, '', expectedlines, ['selftest-replaceme-inst-func'])
279 self.assertNotIn('WARNING: ', output)
280
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500281 def test_recipetool_appendfile_postinstall(self):
282 # A file that's created by a postinstall script (and explicitly mentioned in it)
283 # First try without specifying recipe
284 self._try_recipetool_appendfile_fail('/usr/share/selftest-replaceme-postinst', self.testfile, ['File /usr/share/selftest-replaceme-postinst may be written out in a pre/postinstall script of the following recipes:', 'selftest-recipetool-appendfile'])
285 # Now specify recipe
Patrick Williams213cb262021-08-07 19:21:33 -0500286 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500287 '\n',
288 'SRC_URI += "file://testfile"\n',
289 '\n',
Patrick Williams213cb262021-08-07 19:21:33 -0500290 'do_install:append() {\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500291 ' install -d ${D}${datadir}\n',
292 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-postinst\n',
293 '}\n']
294 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-postinst', self.testfile, '-r selftest-recipetool-appendfile', expectedlines, ['testfile'])
295
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500296 def test_recipetool_appendfile_extlayer(self):
297 # Try creating a bbappend in a layer that's not in bblayers.conf and has a different structure
298 exttemplayerdir = os.path.join(self.tempdir, 'extlayer')
299 self._create_temp_layer(exttemplayerdir, False, 'oeselftestextlayer', recipepathspec='metadata/recipes/recipes-*/*')
300 result = runCmd('recipetool appendfile %s /usr/share/selftest-replaceme-orig %s' % (exttemplayerdir, self.testfile))
301 self.assertNotIn('Traceback', result.output)
302 createdfiles = []
303 for root, _, files in os.walk(exttemplayerdir):
304 for f in files:
305 createdfiles.append(os.path.relpath(os.path.join(root, f), exttemplayerdir))
306 createdfiles.remove('conf/layer.conf')
307 expectedfiles = ['metadata/recipes/recipes-test/selftest-recipetool-appendfile/selftest-recipetool-appendfile.bbappend',
308 'metadata/recipes/recipes-test/selftest-recipetool-appendfile/selftest-recipetool-appendfile/selftest-replaceme-orig']
309 self.assertEqual(sorted(createdfiles), sorted(expectedfiles))
310
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500311 def test_recipetool_appendfile_wildcard(self):
312
313 def try_appendfile_wc(options):
314 result = runCmd('recipetool appendfile %s /etc/profile %s %s' % (self.templayerdir, self.testfile, options))
315 self.assertNotIn('Traceback', result.output)
316 bbappendfile = None
317 for root, _, files in os.walk(self.templayerdir):
318 for f in files:
319 if f.endswith('.bbappend'):
320 bbappendfile = f
321 break
322 if not bbappendfile:
323 self.fail('No bbappend file created')
324 runCmd('rm -rf %s/recipes-*' % self.templayerdir)
325 return bbappendfile
326
327 # Check without wildcard option
328 recipefn = os.path.basename(get_bb_var('FILE', 'base-files'))
329 filename = try_appendfile_wc('')
330 self.assertEqual(filename, recipefn.replace('.bb', '.bbappend'))
331 # Now check with wildcard option
332 filename = try_appendfile_wc('-w')
333 self.assertEqual(filename, recipefn.split('_')[0] + '_%.bbappend')
334
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500335 def test_recipetool_create(self):
336 # Try adding a recipe
337 tempsrc = os.path.join(self.tempdir, 'srctree')
338 os.makedirs(tempsrc)
339 recipefile = os.path.join(self.tempdir, 'logrotate_3.12.3.bb')
340 srcuri = 'https://github.com/logrotate/logrotate/releases/download/3.12.3/logrotate-3.12.3.tar.xz'
341 result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc))
342 self.assertTrue(os.path.isfile(recipefile))
343 checkvars = {}
344 checkvars['LICENSE'] = 'GPLv2'
345 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263'
346 checkvars['SRC_URI'] = 'https://github.com/logrotate/logrotate/releases/download/${PV}/logrotate-${PV}.tar.xz'
347 checkvars['SRC_URI[md5sum]'] = 'a560c57fac87c45b2fc17406cdf79288'
348 checkvars['SRC_URI[sha256sum]'] = '2e6a401cac9024db2288297e3be1a8ab60e7401ba8e91225218aaf4a27e82a07'
349 self._test_recipe_contents(recipefile, checkvars, [])
350
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500351 def test_recipetool_create_git(self):
352 if 'x11' not in get_bb_var('DISTRO_FEATURES'):
353 self.skipTest('Test requires x11 as distro feature')
354 # Ensure we have the right data in shlibs/pkgdata
355 bitbake('libpng pango libx11 libxext jpeg libcheck')
356 # Try adding a recipe
357 tempsrc = os.path.join(self.tempdir, 'srctree')
358 os.makedirs(tempsrc)
359 recipefile = os.path.join(self.tempdir, 'libmatchbox.bb')
360 srcuri = 'git://git.yoctoproject.org/libmatchbox'
361 result = runCmd(['recipetool', 'create', '-o', recipefile, srcuri + ";rev=9f7cf8895ae2d39c465c04cc78e918c157420269", '-x', tempsrc])
362 self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output)
363 checkvars = {}
364 checkvars['LICENSE'] = 'LGPLv2.1'
365 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34'
366 checkvars['S'] = '${WORKDIR}/git'
367 checkvars['PV'] = '1.11+git${SRCPV}'
368 checkvars['SRC_URI'] = srcuri
369 checkvars['DEPENDS'] = set(['libcheck', 'libjpeg-turbo', 'libpng', 'libx11', 'libxext', 'pango'])
370 inherits = ['autotools', 'pkgconfig']
371 self._test_recipe_contents(recipefile, checkvars, inherits)
372
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500373 def test_recipetool_create_simple(self):
374 # Try adding a recipe
375 temprecipe = os.path.join(self.tempdir, 'recipe')
376 os.makedirs(temprecipe)
Andrew Geissler5f350902021-07-23 13:09:54 -0400377 pv = '1.7.4.1'
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500378 srcuri = 'http://www.dest-unreach.org/socat/download/socat-%s.tar.bz2' % pv
379 result = runCmd('recipetool create %s -o %s' % (srcuri, temprecipe))
380 dirlist = os.listdir(temprecipe)
381 if len(dirlist) > 1:
382 self.fail('recipetool created more than just one file; output:\n%s\ndirlist:\n%s' % (result.output, str(dirlist)))
383 if len(dirlist) < 1 or not os.path.isfile(os.path.join(temprecipe, dirlist[0])):
384 self.fail('recipetool did not create recipe file; output:\n%s\ndirlist:\n%s' % (result.output, str(dirlist)))
385 self.assertEqual(dirlist[0], 'socat_%s.bb' % pv, 'Recipe file incorrectly named')
386 checkvars = {}
387 checkvars['LICENSE'] = set(['Unknown', 'GPLv2'])
388 checkvars['LIC_FILES_CHKSUM'] = set(['file://COPYING.OpenSSL;md5=5c9bccc77f67a8328ef4ebaf468116f4', 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263'])
389 # We don't check DEPENDS since they are variable for this recipe depending on what's in the sysroot
390 checkvars['S'] = None
391 checkvars['SRC_URI'] = srcuri.replace(pv, '${PV}')
392 inherits = ['autotools']
393 self._test_recipe_contents(os.path.join(temprecipe, dirlist[0]), checkvars, inherits)
394
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500395 def test_recipetool_create_cmake(self):
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500396 temprecipe = os.path.join(self.tempdir, 'recipe')
397 os.makedirs(temprecipe)
Brad Bishop96ff1982019-08-19 13:50:42 -0400398 recipefile = os.path.join(temprecipe, 'taglib_1.11.1.bb')
399 srcuri = 'http://taglib.github.io/releases/taglib-1.11.1.tar.gz'
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500400 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
401 self.assertTrue(os.path.isfile(recipefile))
402 checkvars = {}
Brad Bishop96ff1982019-08-19 13:50:42 -0400403 checkvars['LICENSE'] = set(['LGPLv2.1', 'MPL-1.1'])
404 checkvars['SRC_URI'] = 'http://taglib.github.io/releases/taglib-${PV}.tar.gz'
405 checkvars['SRC_URI[md5sum]'] = 'cee7be0ccfc892fa433d6c837df9522a'
406 checkvars['SRC_URI[sha256sum]'] = 'b6d1a5a610aae6ff39d93de5efd0fdc787aa9e9dc1e7026fa4c961b26563526b'
407 checkvars['DEPENDS'] = set(['boost', 'zlib'])
408 inherits = ['cmake']
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500409 self._test_recipe_contents(recipefile, checkvars, inherits)
410
Andrew Geissler82c905d2020-04-13 13:39:40 -0500411 def test_recipetool_create_npm(self):
Andrew Geisslerf0343792020-11-18 10:42:21 -0600412 collections = get_bb_var('BBFILE_COLLECTIONS').split()
413 if "openembedded-layer" not in collections:
414 self.skipTest("Test needs meta-oe for nodejs")
415
Andrew Geissler82c905d2020-04-13 13:39:40 -0500416 temprecipe = os.path.join(self.tempdir, 'recipe')
417 os.makedirs(temprecipe)
418 recipefile = os.path.join(temprecipe, 'savoirfairelinux-node-server-example_1.0.0.bb')
419 shrinkwrap = os.path.join(temprecipe, 'savoirfairelinux-node-server-example', 'npm-shrinkwrap.json')
420 srcuri = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'
421 result = runCmd('recipetool create -o %s \'%s\'' % (temprecipe, srcuri))
422 self.assertTrue(os.path.isfile(recipefile))
423 self.assertTrue(os.path.isfile(shrinkwrap))
424 checkvars = {}
425 checkvars['SUMMARY'] = 'Node Server Example'
426 checkvars['HOMEPAGE'] = 'https://github.com/savoirfairelinux/node-server-example#readme'
427 checkvars['LICENSE'] = set(['MIT', 'ISC', 'Unknown'])
428 urls = []
429 urls.append('npm://registry.npmjs.org/;package=@savoirfairelinux/node-server-example;version=${PV}')
430 urls.append('npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json')
431 checkvars['SRC_URI'] = set(urls)
432 checkvars['S'] = '${WORKDIR}/npm'
Patrick Williams213cb262021-08-07 19:21:33 -0500433 checkvars['LICENSE:${PN}'] = 'MIT'
434 checkvars['LICENSE:${PN}-base64'] = 'Unknown'
435 checkvars['LICENSE:${PN}-accepts'] = 'MIT'
436 checkvars['LICENSE:${PN}-inherits'] = 'ISC'
Andrew Geissler82c905d2020-04-13 13:39:40 -0500437 inherits = ['npm']
438 self._test_recipe_contents(recipefile, checkvars, inherits)
439
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500440 def test_recipetool_create_github(self):
441 # Basic test to see if github URL mangling works
442 temprecipe = os.path.join(self.tempdir, 'recipe')
443 os.makedirs(temprecipe)
444 recipefile = os.path.join(temprecipe, 'meson_git.bb')
445 srcuri = 'https://github.com/mesonbuild/meson;rev=0.32.0'
446 result = runCmd(['recipetool', 'create', '-o', temprecipe, srcuri])
447 self.assertTrue(os.path.isfile(recipefile))
448 checkvars = {}
449 checkvars['LICENSE'] = set(['Apache-2.0'])
450 checkvars['SRC_URI'] = 'git://github.com/mesonbuild/meson;protocol=https'
Brad Bishop15ae2502019-06-18 21:44:24 -0400451 inherits = ['setuptools3']
452 self._test_recipe_contents(recipefile, checkvars, inherits)
453
454 def test_recipetool_create_python3_setuptools(self):
455 # Test creating python3 package from tarball (using setuptools3 class)
456 temprecipe = os.path.join(self.tempdir, 'recipe')
457 os.makedirs(temprecipe)
458 pn = 'python-magic'
459 pv = '0.4.15'
460 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
461 srcuri = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-%s.tar.gz' % pv
462 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
463 self.assertTrue(os.path.isfile(recipefile))
464 checkvars = {}
465 checkvars['LICENSE'] = set(['MIT'])
466 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=16a934f165e8c3245f241e77d401bb88'
467 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-${PV}.tar.gz'
468 checkvars['SRC_URI[md5sum]'] = 'e384c95a47218f66c6501cd6dd45ff59'
469 checkvars['SRC_URI[sha256sum]'] = 'f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5'
470 inherits = ['setuptools3']
471 self._test_recipe_contents(recipefile, checkvars, inherits)
472
473 def test_recipetool_create_python3_distutils(self):
474 # Test creating python3 package from tarball (using distutils3 class)
475 temprecipe = os.path.join(self.tempdir, 'recipe')
476 os.makedirs(temprecipe)
477 pn = 'docutils'
478 pv = '0.14'
479 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
480 srcuri = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-%s.tar.gz' % pv
481 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
482 self.assertTrue(os.path.isfile(recipefile))
483 checkvars = {}
Andrew Geissler5199d832021-09-24 16:47:35 -0500484 checkvars['LICENSE'] = set(['PSF', '&', 'BSD-3-Clause', 'GPL'])
Brad Bishop15ae2502019-06-18 21:44:24 -0400485 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.txt;md5=35a23d42b615470583563132872c97d6'
486 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-${PV}.tar.gz'
487 checkvars['SRC_URI[md5sum]'] = 'c53768d63db3873b7d452833553469de'
488 checkvars['SRC_URI[sha256sum]'] = '51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274'
489 inherits = ['distutils3']
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500490 self._test_recipe_contents(recipefile, checkvars, inherits)
491
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500492 def test_recipetool_create_github_tarball(self):
493 # Basic test to ensure github URL mangling doesn't apply to release tarballs
494 temprecipe = os.path.join(self.tempdir, 'recipe')
495 os.makedirs(temprecipe)
496 pv = '0.32.0'
497 recipefile = os.path.join(temprecipe, 'meson_%s.bb' % pv)
498 srcuri = 'https://github.com/mesonbuild/meson/releases/download/%s/meson-%s.tar.gz' % (pv, pv)
499 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
500 self.assertTrue(os.path.isfile(recipefile))
501 checkvars = {}
502 checkvars['LICENSE'] = set(['Apache-2.0'])
503 checkvars['SRC_URI'] = 'https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz'
Brad Bishop15ae2502019-06-18 21:44:24 -0400504 inherits = ['setuptools3']
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500505 self._test_recipe_contents(recipefile, checkvars, inherits)
506
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500507 def test_recipetool_create_git_http(self):
508 # Basic test to check http git URL mangling works
509 temprecipe = os.path.join(self.tempdir, 'recipe')
510 os.makedirs(temprecipe)
511 recipefile = os.path.join(temprecipe, 'matchbox-terminal_git.bb')
512 srcuri = 'http://git.yoctoproject.org/git/matchbox-terminal'
513 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
514 self.assertTrue(os.path.isfile(recipefile))
515 checkvars = {}
516 checkvars['LICENSE'] = set(['GPLv2'])
517 checkvars['SRC_URI'] = 'git://git.yoctoproject.org/git/matchbox-terminal;protocol=http'
518 inherits = ['pkgconfig', 'autotools']
519 self._test_recipe_contents(recipefile, checkvars, inherits)
520
521 def _copy_file_with_cleanup(self, srcfile, basedstdir, *paths):
522 dstdir = basedstdir
523 self.assertTrue(os.path.exists(dstdir))
524 for p in paths:
525 dstdir = os.path.join(dstdir, p)
526 if not os.path.exists(dstdir):
527 os.makedirs(dstdir)
Andrew Geissler475cb722020-07-10 16:00:51 -0500528 if p == "lib":
529 # Can race with other tests
530 self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir)
531 else:
532 self.track_for_cleanup(dstdir)
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500533 dstfile = os.path.join(dstdir, os.path.basename(srcfile))
534 if srcfile != dstfile:
535 shutil.copy(srcfile, dstfile)
536 self.track_for_cleanup(dstfile)
537
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500538 def test_recipetool_load_plugin(self):
539 """Test that recipetool loads only the first found plugin in BBPATH."""
540
541 recipetool = runCmd("which recipetool")
542 fromname = runCmd("recipetool --quiet pluginfile")
543 srcfile = fromname.output
544 searchpath = self.bbpath.split(':') + [os.path.dirname(recipetool.output)]
545 plugincontent = []
546 with open(srcfile) as fh:
547 plugincontent = fh.readlines()
548 try:
549 self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found')
550 for path in searchpath:
551 self._copy_file_with_cleanup(srcfile, path, 'lib', 'recipetool')
552 result = runCmd("recipetool --quiet count")
553 self.assertEqual(result.output, '1')
554 result = runCmd("recipetool --quiet multiloaded")
555 self.assertEqual(result.output, "no")
556 for path in searchpath:
557 result = runCmd("recipetool --quiet bbdir")
558 self.assertEqual(result.output, path)
559 os.unlink(os.path.join(result.output, 'lib', 'recipetool', 'bbpath.py'))
560 finally:
561 with open(srcfile, 'w') as fh:
562 fh.writelines(plugincontent)
563
564
565class RecipetoolAppendsrcBase(RecipetoolBase):
566 def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles):
567 cmd = 'recipetool appendsrcfile %s %s %s %s %s' % (options, self.templayerdir, testrecipe, newfile, destfile)
568 return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines)
569
570 def _try_recipetool_appendsrcfiles(self, testrecipe, newfiles, expectedlines=None, expectedfiles=None, destdir=None, options=''):
571
572 if destdir:
573 options += ' -D %s' % destdir
574
575 if expectedfiles is None:
576 expectedfiles = [os.path.basename(f) for f in newfiles]
577
578 cmd = 'recipetool appendsrcfiles %s %s %s %s' % (options, self.templayerdir, testrecipe, ' '.join(newfiles))
579 return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines)
580
581 def _try_recipetool_appendsrcfile_fail(self, testrecipe, newfile, destfile, checkerror):
582 cmd = 'recipetool appendsrcfile %s %s %s %s' % (self.templayerdir, testrecipe, newfile, destfile or '')
583 result = runCmd(cmd, ignore_status=True)
584 self.assertNotEqual(result.status, 0, 'Command "%s" should have failed but didn\'t' % cmd)
585 self.assertNotIn('Traceback', result.output)
586 for errorstr in checkerror:
587 self.assertIn(errorstr, result.output)
588
589 @staticmethod
590 def _get_first_file_uri(recipe):
591 '''Return the first file:// in SRC_URI for the specified recipe.'''
592 src_uri = get_bb_var('SRC_URI', recipe).split()
593 for uri in src_uri:
594 p = urllib.parse.urlparse(uri)
595 if p.scheme == 'file':
596 return p.netloc + p.path
597
598 def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, options=''):
599 if newfile is None:
600 newfile = self.testfile
601
602 if srcdir:
603 if destdir:
604 expected_subdir = os.path.join(srcdir, destdir)
605 else:
606 expected_subdir = srcdir
607 else:
608 options += " -W"
609 expected_subdir = destdir
610
611 if filename:
612 if destdir:
613 destpath = os.path.join(destdir, filename)
614 else:
615 destpath = filename
616 else:
617 filename = os.path.basename(newfile)
618 if destdir:
619 destpath = destdir + os.sep
620 else:
621 destpath = '.' + os.sep
622
Patrick Williams213cb262021-08-07 19:21:33 -0500623 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500624 '\n']
625 if has_src_uri:
626 uri = 'file://%s' % filename
627 if expected_subdir:
628 uri += ';subdir=%s' % expected_subdir
629 expectedlines[0:0] = ['SRC_URI += "%s"\n' % uri,
630 '\n']
631
632 return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename])
633
634 def _test_appendsrcfiles(self, testrecipe, newfiles, expectedfiles=None, destdir=None, options=''):
635 if expectedfiles is None:
636 expectedfiles = [os.path.basename(n) for n in newfiles]
637
638 self._try_recipetool_appendsrcfiles(testrecipe, newfiles, expectedfiles=expectedfiles, destdir=destdir, options=options)
639
640 bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'FILESEXTRAPATHS'], testrecipe)
641 src_uri = bb_vars['SRC_URI'].split()
642 for f in expectedfiles:
643 if destdir:
644 self.assertIn('file://%s;subdir=%s' % (f, destdir), src_uri)
645 else:
646 self.assertIn('file://%s' % f, src_uri)
647
648 recipefile = bb_vars['FILE']
649 bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir)
650 filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe)
651 filesextrapaths = bb_vars['FILESEXTRAPATHS'].split(':')
652 self.assertIn(filesdir, filesextrapaths)
653
654
655
656
657class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase):
658
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500659 def test_recipetool_appendsrcfile_basic(self):
660 self._test_appendsrcfile('base-files', 'a-file')
661
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500662 def test_recipetool_appendsrcfile_basic_wildcard(self):
663 testrecipe = 'base-files'
664 self._test_appendsrcfile(testrecipe, 'a-file', options='-w')
665 recipefile = get_bb_var('FILE', testrecipe)
666 bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir)
667 self.assertEqual(os.path.basename(bbappendfile), '%s_%%.bbappend' % testrecipe)
668
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500669 def test_recipetool_appendsrcfile_subdir_basic(self):
670 self._test_appendsrcfile('base-files', 'a-file', 'tmp')
671
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500672 def test_recipetool_appendsrcfile_subdir_basic_dirdest(self):
673 self._test_appendsrcfile('base-files', destdir='tmp')
674
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500675 def test_recipetool_appendsrcfile_srcdir_basic(self):
676 testrecipe = 'bash'
677 bb_vars = get_bb_vars(['S', 'WORKDIR'], testrecipe)
678 srcdir = bb_vars['S']
679 workdir = bb_vars['WORKDIR']
680 subdir = os.path.relpath(srcdir, workdir)
681 self._test_appendsrcfile(testrecipe, 'a-file', srcdir=subdir)
682
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500683 def test_recipetool_appendsrcfile_existing_in_src_uri(self):
684 testrecipe = 'base-files'
685 filepath = self._get_first_file_uri(testrecipe)
686 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
687 self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False)
688
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500689 def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self):
690 testrecipe = 'base-files'
691 subdir = 'tmp'
692 filepath = self._get_first_file_uri(testrecipe)
693 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
694
695 output = self._test_appendsrcfile(testrecipe, filepath, subdir, has_src_uri=False)
696 self.assertTrue(any('with different parameters' in l for l in output))
697
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500698 def test_recipetool_appendsrcfile_replace_file_srcdir(self):
699 testrecipe = 'bash'
700 filepath = 'Makefile.in'
701 bb_vars = get_bb_vars(['S', 'WORKDIR'], testrecipe)
702 srcdir = bb_vars['S']
703 workdir = bb_vars['WORKDIR']
704 subdir = os.path.relpath(srcdir, workdir)
705
706 self._test_appendsrcfile(testrecipe, filepath, srcdir=subdir)
707 bitbake('%s:do_unpack' % testrecipe)
Brad Bishop64c979e2019-11-04 13:55:29 -0500708 with open(self.testfile, 'r') as testfile:
709 with open(os.path.join(srcdir, filepath), 'r') as makefilein:
710 self.assertEqual(testfile.read(), makefilein.read())
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500711
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500712 def test_recipetool_appendsrcfiles_basic(self, destdir=None):
713 newfiles = [self.testfile]
714 for i in range(1, 5):
715 testfile = os.path.join(self.tempdir, 'testfile%d' % i)
716 with open(testfile, 'w') as f:
717 f.write('Test file %d\n' % i)
718 newfiles.append(testfile)
719 self._test_appendsrcfiles('gcc', newfiles, destdir=destdir, options='-W')
720
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500721 def test_recipetool_appendsrcfiles_basic_subdir(self):
722 self.test_recipetool_appendsrcfiles_basic(destdir='testdir')