summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/devtool.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/devtool.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/devtool.py216
1 files changed, 159 insertions, 57 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index bc1e40ef83..05f228f03e 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -64,11 +64,15 @@ def setUpModule():
64 # under COREBASE and we don't want to copy that, so we have 64 # under COREBASE and we don't want to copy that, so we have
65 # to be selective. 65 # to be selective.
66 result = runCmd('git status --porcelain', cwd=oldreporoot) 66 result = runCmd('git status --porcelain', cwd=oldreporoot)
67
68 # Also copy modifications to the 'scripts/' directory
69 canonical_layerpath_scripts = os.path.normpath(canonical_layerpath + "../scripts")
70
67 for line in result.output.splitlines(): 71 for line in result.output.splitlines():
68 if line.startswith(' M ') or line.startswith('?? '): 72 if line.startswith(' M ') or line.startswith('?? '):
69 relpth = line.split()[1] 73 relpth = line.split()[1]
70 pth = os.path.join(oldreporoot, relpth) 74 pth = os.path.join(oldreporoot, relpth)
71 if pth.startswith(canonical_layerpath): 75 if pth.startswith(canonical_layerpath) or pth.startswith(canonical_layerpath_scripts):
72 if relpth.endswith('/'): 76 if relpth.endswith('/'):
73 destdir = os.path.join(corecopydir, relpth) 77 destdir = os.path.join(corecopydir, relpth)
74 # avoid race condition by not copying .pyc files YPBZ#13421,13803 78 # avoid race condition by not copying .pyc files YPBZ#13421,13803
@@ -150,7 +154,7 @@ class DevtoolTestCase(OESelftestTestCase):
150 value = invalue 154 value = invalue
151 invar = None 155 invar = None
152 elif '=' in line: 156 elif '=' in line:
153 splitline = line.split('=', 1) 157 splitline = re.split(r"[?+:]*=[+]?", line, 1)
154 var = splitline[0].rstrip() 158 var = splitline[0].rstrip()
155 value = splitline[1].strip().strip('"') 159 value = splitline[1].strip().strip('"')
156 if value.endswith('\\'): 160 if value.endswith('\\'):
@@ -286,10 +290,13 @@ class DevtoolTestCase(OESelftestTestCase):
286 else: 290 else:
287 self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') 291 self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test')
288 292
289 def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri): 293 def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri, srcrev=None):
290 self.track_for_cleanup(self.workspacedir) 294 self.track_for_cleanup(self.workspacedir)
291 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') 295 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
292 result = runCmd('devtool add --version %s %s %s' % (version, pn, git_url)) 296 command = 'devtool add --version %s %s %s' % (version, pn, git_url)
297 if srcrev :
298 command += ' --srcrev %s' %srcrev
299 result = runCmd(command)
293 self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created') 300 self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
294 # Check the recipe name is correct 301 # Check the recipe name is correct
295 recipefile = get_bb_var('FILE', pn) 302 recipefile = get_bb_var('FILE', pn)
@@ -314,7 +321,7 @@ class DevtoolBase(DevtoolTestCase):
314 cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate 321 cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate
315 cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n' 322 cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n'
316 % cls.original_sstate) 323 % cls.original_sstate)
317 cls.sstate_conf += ('BB_HASHSERVE_UPSTREAM = "hashserv.yocto.io:8687"\n') 324 cls.sstate_conf += ('BB_HASHSERVE_UPSTREAM = "hashserv.yoctoproject.org:8686"\n')
318 325
319 @classmethod 326 @classmethod
320 def tearDownClass(cls): 327 def tearDownClass(cls):
@@ -462,7 +469,7 @@ class DevtoolAddTests(DevtoolBase):
462 checkvars = {} 469 checkvars = {}
463 checkvars['LICENSE'] = 'GPL-2.0-only' 470 checkvars['LICENSE'] = 'GPL-2.0-only'
464 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263' 471 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263'
465 checkvars['S'] = '${WORKDIR}/git' 472 checkvars['S'] = None
466 checkvars['PV'] = '0.1+git' 473 checkvars['PV'] = '0.1+git'
467 checkvars['SRC_URI'] = 'git://git.yoctoproject.org/git/dbus-wait;protocol=https;branch=master' 474 checkvars['SRC_URI'] = 'git://git.yoctoproject.org/git/dbus-wait;protocol=https;branch=master'
468 checkvars['SRCREV'] = srcrev 475 checkvars['SRCREV'] = srcrev
@@ -479,11 +486,12 @@ class DevtoolAddTests(DevtoolBase):
479 486
480 def test_devtool_add_git_style2(self): 487 def test_devtool_add_git_style2(self):
481 version = 'v3.1.0' 488 version = 'v3.1.0'
489 srcrev = 'v3.1.0'
482 pn = 'mbedtls' 490 pn = 'mbedtls'
483 # this will trigger reformat_git_uri with branch parameter in url 491 # this will trigger reformat_git_uri with branch parameter in url
484 git_url = "'git://git@github.com/ARMmbed/mbedtls.git;protocol=https'" 492 git_url = "'git://git@github.com/ARMmbed/mbedtls.git;protocol=https'"
485 resulting_src_uri = "gitsm://git@github.com/ARMmbed/mbedtls.git;protocol=https;branch=master" 493 resulting_src_uri = "git://git@github.com/ARMmbed/mbedtls.git;protocol=https;branch=master"
486 self._test_devtool_add_git_url(git_url, version, pn, resulting_src_uri) 494 self._test_devtool_add_git_url(git_url, version, pn, resulting_src_uri, srcrev)
487 495
488 def test_devtool_add_library(self): 496 def test_devtool_add_library(self):
489 # Fetch source 497 # Fetch source
@@ -557,7 +565,7 @@ class DevtoolAddTests(DevtoolBase):
557 recipefile = get_bb_var('FILE', testrecipe) 565 recipefile = get_bb_var('FILE', testrecipe)
558 self.assertIn('%s_%s.bb' % (testrecipe, testver), recipefile, 'Recipe file incorrectly named') 566 self.assertIn('%s_%s.bb' % (testrecipe, testver), recipefile, 'Recipe file incorrectly named')
559 checkvars = {} 567 checkvars = {}
560 checkvars['S'] = '${WORKDIR}/MarkupSafe-${PV}' 568 checkvars['S'] = '${UNPACKDIR}/MarkupSafe-${PV}'
561 checkvars['SRC_URI'] = url.replace(testver, '${PV}') 569 checkvars['SRC_URI'] = url.replace(testver, '${PV}')
562 self._test_recipe_contents(recipefile, checkvars, []) 570 self._test_recipe_contents(recipefile, checkvars, [])
563 # Try with version specified 571 # Try with version specified
@@ -574,7 +582,7 @@ class DevtoolAddTests(DevtoolBase):
574 recipefile = get_bb_var('FILE', testrecipe) 582 recipefile = get_bb_var('FILE', testrecipe)
575 self.assertIn('%s_%s.bb' % (testrecipe, fakever), recipefile, 'Recipe file incorrectly named') 583 self.assertIn('%s_%s.bb' % (testrecipe, fakever), recipefile, 'Recipe file incorrectly named')
576 checkvars = {} 584 checkvars = {}
577 checkvars['S'] = '${WORKDIR}/MarkupSafe-%s' % testver 585 checkvars['S'] = '${UNPACKDIR}/MarkupSafe-%s' % testver
578 checkvars['SRC_URI'] = url 586 checkvars['SRC_URI'] = url
579 self._test_recipe_contents(recipefile, checkvars, []) 587 self._test_recipe_contents(recipefile, checkvars, [])
580 588
@@ -601,7 +609,7 @@ class DevtoolAddTests(DevtoolBase):
601 recipefile = get_bb_var('FILE', testrecipe) 609 recipefile = get_bb_var('FILE', testrecipe)
602 self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named') 610 self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named')
603 checkvars = {} 611 checkvars = {}
604 checkvars['S'] = '${WORKDIR}/git' 612 checkvars['S'] = None
605 checkvars['PV'] = '1.0+git' 613 checkvars['PV'] = '1.0+git'
606 checkvars['SRC_URI'] = url_branch 614 checkvars['SRC_URI'] = url_branch
607 checkvars['SRCREV'] = '${AUTOREV}' 615 checkvars['SRCREV'] = '${AUTOREV}'
@@ -620,7 +628,7 @@ class DevtoolAddTests(DevtoolBase):
620 recipefile = get_bb_var('FILE', testrecipe) 628 recipefile = get_bb_var('FILE', testrecipe)
621 self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named') 629 self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named')
622 checkvars = {} 630 checkvars = {}
623 checkvars['S'] = '${WORKDIR}/git' 631 checkvars['S'] = None
624 checkvars['PV'] = '1.5+git' 632 checkvars['PV'] = '1.5+git'
625 checkvars['SRC_URI'] = url_branch 633 checkvars['SRC_URI'] = url_branch
626 checkvars['SRCREV'] = checkrev 634 checkvars['SRCREV'] = checkrev
@@ -749,6 +757,25 @@ class DevtoolModifyTests(DevtoolBase):
749 result = runCmd('devtool status') 757 result = runCmd('devtool status')
750 self.assertNotIn('mdadm', result.output) 758 self.assertNotIn('mdadm', result.output)
751 759
760 def test_devtool_modify_go(self):
761 import oe.path
762 from tempfile import TemporaryDirectory
763 with TemporaryDirectory(prefix='devtoolqa') as tempdir:
764 self.track_for_cleanup(self.workspacedir)
765 self.add_command_to_tearDown('bitbake -c clean go-helloworld')
766 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
767 result = runCmd('devtool modify go-helloworld -x %s' % tempdir)
768 self.assertExists(
769 oe.path.join(tempdir, 'src', 'golang.org', 'x', 'example', 'go.mod'),
770 'Extracted source could not be found'
771 )
772 self.assertExists(
773 oe.path.join(self.workspacedir, 'conf', 'layer.conf'),
774 'Workspace directory not created'
775 )
776 matches = glob.glob(oe.path.join(self.workspacedir, 'appends', 'go-helloworld_*.bbappend'))
777 self.assertTrue(matches, 'bbappend not created %s' % result.output)
778
752 def test_devtool_buildclean(self): 779 def test_devtool_buildclean(self):
753 def assertFile(path, *paths): 780 def assertFile(path, *paths):
754 f = os.path.join(path, *paths) 781 f = os.path.join(path, *paths)
@@ -875,13 +902,8 @@ class DevtoolModifyTests(DevtoolBase):
875 self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) 902 self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe)
876 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') 903 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
877 result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) 904 result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
878 srcfile = os.path.join(tempdir, 'oe-local-files/share/dot.bashrc') 905 srcfile = os.path.join(tempdir, 'share/dot.bashrc')
879 srclink = os.path.join(tempdir, 'share/dot.bashrc')
880 self.assertExists(srcfile, 'Extracted source could not be found') 906 self.assertExists(srcfile, 'Extracted source could not be found')
881 if os.path.islink(srclink) and os.path.exists(srclink) and os.path.samefile(srcfile, srclink):
882 correct_symlink = True
883 self.assertTrue(correct_symlink, 'Source symlink to oe-local-files is broken')
884
885 matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe)) 907 matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe))
886 self.assertTrue(matches, 'bbappend not created') 908 self.assertTrue(matches, 'bbappend not created')
887 # Test devtool status 909 # Test devtool status
@@ -952,9 +974,9 @@ class DevtoolModifyTests(DevtoolBase):
952 # others git:// in SRC_URI 974 # others git:// in SRC_URI
953 # cointains a patch 975 # cointains a patch
954 testrecipe = 'hello-rs' 976 testrecipe = 'hello-rs'
955 bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'WORKDIR', 'CARGO_HOME'], testrecipe) 977 bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'UNPACKDIR', 'CARGO_HOME'], testrecipe)
956 recipefile = bb_vars['FILE'] 978 recipefile = bb_vars['FILE']
957 workdir = bb_vars['WORKDIR'] 979 unpackdir = bb_vars['UNPACKDIR']
958 cargo_home = bb_vars['CARGO_HOME'] 980 cargo_home = bb_vars['CARGO_HOME']
959 src_uri = bb_vars['SRC_URI'].split() 981 src_uri = bb_vars['SRC_URI'].split()
960 self.assertTrue(src_uri[0].startswith('git://'), 982 self.assertTrue(src_uri[0].startswith('git://'),
@@ -1005,7 +1027,7 @@ class DevtoolModifyTests(DevtoolBase):
1005 # Configure the recipe to check that the git dependencies are correctly patched in cargo config 1027 # Configure the recipe to check that the git dependencies are correctly patched in cargo config
1006 bitbake('-c configure %s' % testrecipe) 1028 bitbake('-c configure %s' % testrecipe)
1007 1029
1008 cargo_config_path = os.path.join(cargo_home, 'config') 1030 cargo_config_path = os.path.join(cargo_home, 'config.toml')
1009 with open(cargo_config_path, "r") as f: 1031 with open(cargo_config_path, "r") as f:
1010 cargo_config_contents = [line.strip('\n') for line in f.readlines()] 1032 cargo_config_contents = [line.strip('\n') for line in f.readlines()]
1011 1033
@@ -1025,7 +1047,7 @@ class DevtoolModifyTests(DevtoolBase):
1025 self.assertEqual(parms['type'], 'git-dependency', 'git dependencies uri should have "type=git-dependency"') 1047 self.assertEqual(parms['type'], 'git-dependency', 'git dependencies uri should have "type=git-dependency"')
1026 raw_url = raw_url.replace("git://", '%s://' % parms['protocol']) 1048 raw_url = raw_url.replace("git://", '%s://' % parms['protocol'])
1027 patch_line = '[patch."%s"]' % raw_url 1049 patch_line = '[patch."%s"]' % raw_url
1028 path_patched = os.path.join(workdir, parms['destsuffix']) 1050 path_patched = os.path.join(unpackdir, parms['destsuffix'])
1029 path_override_line = '%s = { path = "%s" }' % (parms['name'], path_patched) 1051 path_override_line = '%s = { path = "%s" }' % (parms['name'], path_patched)
1030 # Would have been better to use tomllib to read this file :/ 1052 # Would have been better to use tomllib to read this file :/
1031 self.assertIn(patch_line, cargo_config_contents) 1053 self.assertIn(patch_line, cargo_config_contents)
@@ -1163,13 +1185,16 @@ class DevtoolUpdateTests(DevtoolBase):
1163 result = runCmd('echo "A new file" > devtool-new-file', cwd=tempdir) 1185 result = runCmd('echo "A new file" > devtool-new-file', cwd=tempdir)
1164 result = runCmd('git add devtool-new-file', cwd=tempdir) 1186 result = runCmd('git add devtool-new-file', cwd=tempdir)
1165 result = runCmd('git commit -m "Add a new file"', cwd=tempdir) 1187 result = runCmd('git commit -m "Add a new file"', cwd=tempdir)
1166 self.add_command_to_tearDown('cd %s; rm %s/*.patch; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile))) 1188 cleanup_cmd = 'cd %s; rm %s/*.patch; git add %s; git checkout %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile))
1189 self.add_command_to_tearDown(cleanup_cmd)
1167 result = runCmd('devtool update-recipe %s' % testrecipe) 1190 result = runCmd('devtool update-recipe %s' % testrecipe)
1168 result = runCmd('git add minicom', cwd=os.path.dirname(recipefile)) 1191 result = runCmd('git add minicom', cwd=os.path.dirname(recipefile))
1169 expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), 1192 expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)),
1170 ('A ', '.*/0001-Change-the-README.patch$'), 1193 ('A ', '.*/0001-Change-the-README.patch$'),
1171 ('A ', '.*/0002-Add-a-new-file.patch$')] 1194 ('A ', '.*/0002-Add-a-new-file.patch$')]
1172 self._check_repo_status(os.path.dirname(recipefile), expected_status) 1195 self._check_repo_status(os.path.dirname(recipefile), expected_status)
1196 result = runCmd(cleanup_cmd)
1197 self._check_repo_status(os.path.dirname(recipefile), [])
1173 1198
1174 def test_devtool_update_recipe_git(self): 1199 def test_devtool_update_recipe_git(self):
1175 # Check preconditions 1200 # Check preconditions
@@ -1226,7 +1251,7 @@ class DevtoolUpdateTests(DevtoolBase):
1226 1251
1227 def test_devtool_update_recipe_append(self): 1252 def test_devtool_update_recipe_append(self):
1228 # Check preconditions 1253 # Check preconditions
1229 testrecipe = 'mdadm' 1254 testrecipe = 'minicom'
1230 bb_vars = get_bb_vars(['FILE', 'SRC_URI'], testrecipe) 1255 bb_vars = get_bb_vars(['FILE', 'SRC_URI'], testrecipe)
1231 recipefile = bb_vars['FILE'] 1256 recipefile = bb_vars['FILE']
1232 src_uri = bb_vars['SRC_URI'] 1257 src_uri = bb_vars['SRC_URI']
@@ -1244,7 +1269,7 @@ class DevtoolUpdateTests(DevtoolBase):
1244 # Check git repo 1269 # Check git repo
1245 self._check_src_repo(tempsrcdir) 1270 self._check_src_repo(tempsrcdir)
1246 # Add a commit 1271 # Add a commit
1247 result = runCmd("sed 's!\\(#define VERSION\\W*\"[^\"]*\\)\"!\\1-custom\"!' -i ReadMe.c", cwd=tempsrcdir) 1272 result = runCmd('echo "Additional line" >> README', cwd=tempsrcdir)
1248 result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) 1273 result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir)
1249 self.add_command_to_tearDown('cd %s; rm -f %s/*.patch; git checkout .' % (os.path.dirname(recipefile), testrecipe)) 1274 self.add_command_to_tearDown('cd %s; rm -f %s/*.patch; git checkout .' % (os.path.dirname(recipefile), testrecipe))
1250 # Create a temporary layer and add it to bblayers.conf 1275 # Create a temporary layer and add it to bblayers.conf
@@ -1274,7 +1299,7 @@ class DevtoolUpdateTests(DevtoolBase):
1274 with open(bbappendfile, 'r') as f: 1299 with open(bbappendfile, 'r') as f:
1275 self.assertEqual(expectedlines, f.readlines()) 1300 self.assertEqual(expectedlines, f.readlines())
1276 # Drop new commit and check patch gets deleted 1301 # Drop new commit and check patch gets deleted
1277 result = runCmd('git reset HEAD^', cwd=tempsrcdir) 1302 result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir)
1278 result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) 1303 result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
1279 self.assertNotExists(patchfile, 'Patch file not deleted') 1304 self.assertNotExists(patchfile, 'Patch file not deleted')
1280 expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', 1305 expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
@@ -1283,6 +1308,7 @@ class DevtoolUpdateTests(DevtoolBase):
1283 self.assertEqual(expectedlines2, f.readlines()) 1308 self.assertEqual(expectedlines2, f.readlines())
1284 # Put commit back and check we can run it if layer isn't in bblayers.conf 1309 # Put commit back and check we can run it if layer isn't in bblayers.conf
1285 os.remove(bbappendfile) 1310 os.remove(bbappendfile)
1311 result = runCmd('echo "Additional line" >> README', cwd=tempsrcdir)
1286 result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) 1312 result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir)
1287 result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) 1313 result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir)
1288 result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) 1314 result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
@@ -1357,7 +1383,7 @@ class DevtoolUpdateTests(DevtoolBase):
1357 with open(bbappendfile, 'r') as f: 1383 with open(bbappendfile, 'r') as f:
1358 self.assertEqual(expectedlines, set(f.readlines())) 1384 self.assertEqual(expectedlines, set(f.readlines()))
1359 # Drop new commit and check SRCREV changes 1385 # Drop new commit and check SRCREV changes
1360 result = runCmd('git reset HEAD^', cwd=tempsrcdir) 1386 result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir)
1361 result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) 1387 result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
1362 self.assertNotExists(os.path.join(appenddir, testrecipe), 'Patch directory should not be created') 1388 self.assertNotExists(os.path.join(appenddir, testrecipe), 'Patch directory should not be created')
1363 result = runCmd('git rev-parse HEAD', cwd=tempsrcdir) 1389 result = runCmd('git rev-parse HEAD', cwd=tempsrcdir)
@@ -1369,6 +1395,7 @@ class DevtoolUpdateTests(DevtoolBase):
1369 self.assertEqual(expectedlines, set(f.readlines())) 1395 self.assertEqual(expectedlines, set(f.readlines()))
1370 # Put commit back and check we can run it if layer isn't in bblayers.conf 1396 # Put commit back and check we can run it if layer isn't in bblayers.conf
1371 os.remove(bbappendfile) 1397 os.remove(bbappendfile)
1398 result = runCmd('echo "# Additional line" >> Makefile.am', cwd=tempsrcdir)
1372 result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) 1399 result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir)
1373 result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) 1400 result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir)
1374 result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) 1401 result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
@@ -1400,22 +1427,39 @@ class DevtoolUpdateTests(DevtoolBase):
1400 # Try building just to ensure we haven't broken that 1427 # Try building just to ensure we haven't broken that
1401 bitbake("%s" % testrecipe) 1428 bitbake("%s" % testrecipe)
1402 # Edit / commit local source 1429 # Edit / commit local source
1403 runCmd('echo "/* Foobar */" >> oe-local-files/makedevs.c', cwd=tempdir) 1430 runCmd('echo "/* Foobar */" >> makedevs.c', cwd=tempdir)
1404 runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) 1431 runCmd('echo "Foo" > new-local', cwd=tempdir)
1405 runCmd('echo "Bar" > new-file', cwd=tempdir) 1432 runCmd('echo "Bar" > new-file', cwd=tempdir)
1406 runCmd('git add new-file', cwd=tempdir) 1433 runCmd('git add new-file', cwd=tempdir)
1407 runCmd('git commit -m "Add new file"', cwd=tempdir) 1434 runCmd('git commit -m "Add new file"', cwd=tempdir)
1408 self.add_command_to_tearDown('cd %s; git clean -fd .; git checkout .' % 1435 runCmd('git add new-local', cwd=tempdir)
1409 os.path.dirname(recipefile))
1410 runCmd('devtool update-recipe %s' % testrecipe) 1436 runCmd('devtool update-recipe %s' % testrecipe)
1411 expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), 1437 expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)),
1412 (' M', '.*/makedevs/makedevs.c$'), 1438 (' M', '.*/makedevs/makedevs.c$'),
1413 ('??', '.*/makedevs/new-local$'), 1439 ('??', '.*/makedevs/new-local$'),
1414 ('??', '.*/makedevs/0001-Add-new-file.patch$')] 1440 ('??', '.*/makedevs/0001-Add-new-file.patch$')]
1415 self._check_repo_status(os.path.dirname(recipefile), expected_status) 1441 self._check_repo_status(os.path.dirname(recipefile), expected_status)
1416 1442 # Now try to update recipe in another layer, so first, clean it
1417 def test_devtool_update_recipe_local_files_2(self): 1443 runCmd('cd %s; git clean -fd .; git checkout .' % os.path.dirname(recipefile))
1418 """Check local source files support when oe-local-files is in Git""" 1444 # Create a temporary layer and add it to bblayers.conf
1445 self._create_temp_layer(templayerdir, True, 'templayer')
1446 # Update recipe in templayer
1447 result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
1448 self.assertNotIn('WARNING:', result.output)
1449 # Check recipe is still clean
1450 self._check_repo_status(os.path.dirname(recipefile), [])
1451 splitpath = os.path.dirname(recipefile).split(os.sep)
1452 appenddir = os.path.join(templayerdir, splitpath[-2], splitpath[-1])
1453 bbappendfile = self._check_bbappend(testrecipe, recipefile, appenddir)
1454 patchfile = os.path.join(appenddir, testrecipe, '0001-Add-new-file.patch')
1455 new_local_file = os.path.join(appenddir, testrecipe, 'new_local')
1456 local_file = os.path.join(appenddir, testrecipe, 'makedevs.c')
1457 self.assertExists(patchfile, 'Patch file 0001-Add-new-file.patch not created')
1458 self.assertExists(local_file, 'File makedevs.c not created')
1459 self.assertExists(patchfile, 'File new_local not created')
1460
1461 def _test_devtool_update_recipe_local_files_2(self):
1462 """Check local source files support when editing local files in Git"""
1419 testrecipe = 'devtool-test-local' 1463 testrecipe = 'devtool-test-local'
1420 recipefile = get_bb_var('FILE', testrecipe) 1464 recipefile = get_bb_var('FILE', testrecipe)
1421 recipedir = os.path.dirname(recipefile) 1465 recipedir = os.path.dirname(recipefile)
@@ -1430,17 +1474,13 @@ class DevtoolUpdateTests(DevtoolBase):
1430 result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) 1474 result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
1431 # Check git repo 1475 # Check git repo
1432 self._check_src_repo(tempdir) 1476 self._check_src_repo(tempdir)
1433 # Add oe-local-files to Git
1434 runCmd('rm oe-local-files/.gitignore', cwd=tempdir)
1435 runCmd('git add oe-local-files', cwd=tempdir)
1436 runCmd('git commit -m "Add local sources"', cwd=tempdir)
1437 # Edit / commit local sources 1477 # Edit / commit local sources
1438 runCmd('echo "# Foobar" >> oe-local-files/file1', cwd=tempdir) 1478 runCmd('echo "# Foobar" >> file1', cwd=tempdir)
1439 runCmd('git commit -am "Edit existing file"', cwd=tempdir) 1479 runCmd('git commit -am "Edit existing file"', cwd=tempdir)
1440 runCmd('git rm oe-local-files/file2', cwd=tempdir) 1480 runCmd('git rm file2', cwd=tempdir)
1441 runCmd('git commit -m"Remove file"', cwd=tempdir) 1481 runCmd('git commit -m"Remove file"', cwd=tempdir)
1442 runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) 1482 runCmd('echo "Foo" > new-local', cwd=tempdir)
1443 runCmd('git add oe-local-files/new-local', cwd=tempdir) 1483 runCmd('git add new-local', cwd=tempdir)
1444 runCmd('git commit -m "Add new local file"', cwd=tempdir) 1484 runCmd('git commit -m "Add new local file"', cwd=tempdir)
1445 runCmd('echo "Gar" > new-file', cwd=tempdir) 1485 runCmd('echo "Gar" > new-file', cwd=tempdir)
1446 runCmd('git add new-file', cwd=tempdir) 1486 runCmd('git add new-file', cwd=tempdir)
@@ -1449,7 +1489,7 @@ class DevtoolUpdateTests(DevtoolBase):
1449 os.path.dirname(recipefile)) 1489 os.path.dirname(recipefile))
1450 # Checkout unmodified file to working copy -> devtool should still pick 1490 # Checkout unmodified file to working copy -> devtool should still pick
1451 # the modified version from HEAD 1491 # the modified version from HEAD
1452 runCmd('git checkout HEAD^ -- oe-local-files/file1', cwd=tempdir) 1492 runCmd('git checkout HEAD^ -- file1', cwd=tempdir)
1453 runCmd('devtool update-recipe %s' % testrecipe) 1493 runCmd('devtool update-recipe %s' % testrecipe)
1454 expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), 1494 expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)),
1455 (' M', '.*/file1$'), 1495 (' M', '.*/file1$'),
@@ -1524,7 +1564,7 @@ class DevtoolUpdateTests(DevtoolBase):
1524 # (don't bother with cleaning the recipe on teardown, we won't be building it) 1564 # (don't bother with cleaning the recipe on teardown, we won't be building it)
1525 result = runCmd('devtool modify %s' % testrecipe) 1565 result = runCmd('devtool modify %s' % testrecipe)
1526 # Modify one file 1566 # Modify one file
1527 runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe, 'oe-local-files')) 1567 runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe))
1528 self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile))) 1568 self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile)))
1529 result = runCmd('devtool update-recipe %s' % testrecipe) 1569 result = runCmd('devtool update-recipe %s' % testrecipe)
1530 expected_status = [(' M', '.*/%s/file2$' % testrecipe)] 1570 expected_status = [(' M', '.*/%s/file2$' % testrecipe)]
@@ -1587,12 +1627,12 @@ class DevtoolUpdateTests(DevtoolBase):
1587 # Check preconditions 1627 # Check preconditions
1588 testrecipe = 'dos2unix' 1628 testrecipe = 'dos2unix'
1589 self.append_config('ERROR_QA:remove:pn-dos2unix = "patch-status"\n') 1629 self.append_config('ERROR_QA:remove:pn-dos2unix = "patch-status"\n')
1590 bb_vars = get_bb_vars(['SRC_URI', 'S', 'WORKDIR', 'FILE'], testrecipe) 1630 bb_vars = get_bb_vars(['SRC_URI', 'S', 'UNPACKDIR', 'FILE', 'BB_GIT_DEFAULT_DESTSUFFIX'], testrecipe)
1591 self.assertIn('git://', bb_vars['SRC_URI'], 'This test expects the %s recipe to be a git recipe' % testrecipe) 1631 self.assertIn('git://', bb_vars['SRC_URI'], 'This test expects the %s recipe to be a git recipe' % testrecipe)
1592 workdir_git = '%s/git/' % bb_vars['WORKDIR'] 1632 unpackdir_git = '%s/%s/' % (bb_vars['UNPACKDIR'], bb_vars['BB_GIT_DEFAULT_DESTSUFFIX'])
1593 if not bb_vars['S'].startswith(workdir_git): 1633 if not bb_vars['S'].startswith(unpackdir_git):
1594 self.fail('This test expects the %s recipe to be building from a subdirectory of the git repo' % testrecipe) 1634 self.fail('This test expects the %s recipe to be building from a subdirectory of the git repo' % testrecipe)
1595 subdir = bb_vars['S'].split(workdir_git, 1)[1] 1635 subdir = bb_vars['S'].split(unpackdir_git, 1)[1]
1596 # Clean up anything in the workdir/sysroot/sstate cache 1636 # Clean up anything in the workdir/sysroot/sstate cache
1597 bitbake('%s -c cleansstate' % testrecipe) 1637 bitbake('%s -c cleansstate' % testrecipe)
1598 # Try modifying a recipe 1638 # Try modifying a recipe
@@ -1720,6 +1760,8 @@ class DevtoolExtractTests(DevtoolBase):
1720 self.assertExists(os.path.join(tempdir, 'Makefile.am'), 'Extracted source could not be found') 1760 self.assertExists(os.path.join(tempdir, 'Makefile.am'), 'Extracted source could not be found')
1721 self._check_src_repo(tempdir) 1761 self._check_src_repo(tempdir)
1722 1762
1763class DevtoolResetTests(DevtoolBase):
1764
1723 def test_devtool_reset_all(self): 1765 def test_devtool_reset_all(self):
1724 tempdir = tempfile.mkdtemp(prefix='devtoolqa') 1766 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
1725 self.track_for_cleanup(tempdir) 1767 self.track_for_cleanup(tempdir)
@@ -1746,6 +1788,21 @@ class DevtoolExtractTests(DevtoolBase):
1746 matches2 = glob.glob(stampprefix2 + '*') 1788 matches2 = glob.glob(stampprefix2 + '*')
1747 self.assertFalse(matches2, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe2) 1789 self.assertFalse(matches2, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe2)
1748 1790
1791 def test_devtool_reset_re_plus_plus(self):
1792 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
1793 self.track_for_cleanup(tempdir)
1794 self.track_for_cleanup(self.workspacedir)
1795 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
1796 testrecipe = 'devtool-test-reset-re++'
1797 result = runCmd('devtool modify %s' % testrecipe)
1798 result = runCmd('devtool reset -n %s' % testrecipe)
1799 self.assertIn(testrecipe, result.output)
1800 result = runCmd('devtool status')
1801 self.assertNotIn(testrecipe, result.output)
1802 self.assertNotExists(os.path.join(self.workspacedir, 'recipes', testrecipe), 'Recipe directory should not exist after resetting')
1803
1804class DevtoolDeployTargetTests(DevtoolBase):
1805
1749 @OETestTag("runqemu") 1806 @OETestTag("runqemu")
1750 def test_devtool_deploy_target(self): 1807 def test_devtool_deploy_target(self):
1751 self._check_runqemu_prerequisites() 1808 self._check_runqemu_prerequisites()
@@ -1753,6 +1810,8 @@ class DevtoolExtractTests(DevtoolBase):
1753 # Definitions 1810 # Definitions
1754 testrecipe = 'mdadm' 1811 testrecipe = 'mdadm'
1755 testfile = '/sbin/mdadm' 1812 testfile = '/sbin/mdadm'
1813 if "usrmerge" in get_bb_var('DISTRO_FEATURES'):
1814 testfile = '/usr/sbin/mdadm'
1756 testimage = 'oe-selftest-image' 1815 testimage = 'oe-selftest-image'
1757 testcommand = '/sbin/mdadm --help' 1816 testcommand = '/sbin/mdadm --help'
1758 # Build an image to run 1817 # Build an image to run
@@ -1811,6 +1870,8 @@ class DevtoolExtractTests(DevtoolBase):
1811 result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand), ignore_status=True) 1870 result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand), ignore_status=True)
1812 self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have') 1871 self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have')
1813 1872
1873class DevtoolBuildImageTests(DevtoolBase):
1874
1814 def test_devtool_build_image(self): 1875 def test_devtool_build_image(self):
1815 """Test devtool build-image plugin""" 1876 """Test devtool build-image plugin"""
1816 # Check preconditions 1877 # Check preconditions
@@ -1982,6 +2043,52 @@ class DevtoolUpgradeTests(DevtoolBase):
1982 newlines = f.readlines() 2043 newlines = f.readlines()
1983 self.assertEqual(desiredlines, newlines) 2044 self.assertEqual(desiredlines, newlines)
1984 2045
2046 def test_devtool_upgrade_recipe_upgrade_extra_tasks(self):
2047 # Check preconditions
2048 self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
2049 self.track_for_cleanup(self.workspacedir)
2050 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
2051 recipe = 'python3-guessing-game'
2052 version = '0.2.0'
2053 commit = '40cf004c2772ffa20ea803fa3be1528a75be3e98'
2054 oldrecipefile = get_bb_var('FILE', recipe)
2055 oldcratesincfile = os.path.join(os.path.dirname(oldrecipefile), os.path.basename(oldrecipefile).strip('_git.bb') + '-crates.inc')
2056 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
2057 self.track_for_cleanup(tempdir)
2058 # Check that recipe is not already under devtool control
2059 result = runCmd('devtool status')
2060 self.assertNotIn(recipe, result.output)
2061 # Check upgrade
2062 result = runCmd('devtool upgrade %s %s --version %s --srcrev %s' % (recipe, tempdir, version, commit))
2063 # Check if srctree at least is populated
2064 self.assertTrue(len(os.listdir(tempdir)) > 0, 'srctree (%s) should be populated with new (%s) source code' % (tempdir, commit))
2065 # Check new recipe file and new -crates.inc files are present
2066 newrecipefile = os.path.join(self.workspacedir, 'recipes', recipe, os.path.basename(oldrecipefile))
2067 newcratesincfile = os.path.join(self.workspacedir, 'recipes', recipe, os.path.basename(oldcratesincfile))
2068 self.assertExists(newrecipefile, 'Recipe file should exist after upgrade')
2069 self.assertExists(newcratesincfile, 'Recipe crates.inc file should exist after upgrade')
2070 # Check devtool status and make sure recipe is present
2071 result = runCmd('devtool status')
2072 self.assertIn(recipe, result.output)
2073 self.assertIn(tempdir, result.output)
2074 # Check recipe got changed as expected
2075 with open(oldrecipefile + '.upgraded', 'r') as f:
2076 desiredlines = f.readlines()
2077 with open(newrecipefile, 'r') as f:
2078 newlines = f.readlines()
2079 self.assertEqual(desiredlines, newlines)
2080 # Check crates.inc got changed as expected
2081 with open(oldcratesincfile + '.upgraded', 'r') as f:
2082 desiredlines = f.readlines()
2083 with open(newcratesincfile, 'r') as f:
2084 newlines = f.readlines()
2085 self.assertEqual(desiredlines, newlines)
2086 # Check devtool reset recipe
2087 result = runCmd('devtool reset %s -n' % recipe)
2088 result = runCmd('devtool status')
2089 self.assertNotIn(recipe, result.output)
2090 self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after resetting')
2091
1985 def test_devtool_layer_plugins(self): 2092 def test_devtool_layer_plugins(self):
1986 """Test that devtool can use plugins from other layers. 2093 """Test that devtool can use plugins from other layers.
1987 2094
@@ -2307,7 +2414,7 @@ class DevtoolUpgradeTests(DevtoolBase):
2307 newsrctree = os.path.join(self.workspacedir, 'sources', newrecipename) 2414 newsrctree = os.path.join(self.workspacedir, 'sources', newrecipename)
2308 self.assertExists(newsrctree, 'Source directory not renamed') 2415 self.assertExists(newsrctree, 'Source directory not renamed')
2309 checkvars = {} 2416 checkvars = {}
2310 checkvars['S'] = '${WORKDIR}/%s-%s' % (recipename, recipever) 2417 checkvars['S'] = '${UNPACKDIR}/%s-%s' % (recipename, recipever)
2311 checkvars['SRC_URI'] = url 2418 checkvars['SRC_URI'] = url
2312 self._test_recipe_contents(newrecipefile, checkvars, []) 2419 self._test_recipe_contents(newrecipefile, checkvars, [])
2313 # Try again - change just name this time 2420 # Try again - change just name this time
@@ -2319,7 +2426,7 @@ class DevtoolUpgradeTests(DevtoolBase):
2319 self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipename), 'Old recipe directory still exists') 2426 self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipename), 'Old recipe directory still exists')
2320 self.assertExists(os.path.join(self.workspacedir, 'sources', newrecipename), 'Source directory not renamed') 2427 self.assertExists(os.path.join(self.workspacedir, 'sources', newrecipename), 'Source directory not renamed')
2321 checkvars = {} 2428 checkvars = {}
2322 checkvars['S'] = '${WORKDIR}/%s-${PV}' % recipename 2429 checkvars['S'] = '${UNPACKDIR}/%s-${PV}' % recipename
2323 checkvars['SRC_URI'] = url.replace(recipever, '${PV}') 2430 checkvars['SRC_URI'] = url.replace(recipever, '${PV}')
2324 self._test_recipe_contents(newrecipefile, checkvars, []) 2431 self._test_recipe_contents(newrecipefile, checkvars, [])
2325 # Try again - change just version this time 2432 # Try again - change just version this time
@@ -2330,7 +2437,7 @@ class DevtoolUpgradeTests(DevtoolBase):
2330 self.assertExists(newrecipefile, 'Recipe file not renamed') 2437 self.assertExists(newrecipefile, 'Recipe file not renamed')
2331 self.assertExists(os.path.join(self.workspacedir, 'sources', recipename), 'Source directory no longer exists') 2438 self.assertExists(os.path.join(self.workspacedir, 'sources', recipename), 'Source directory no longer exists')
2332 checkvars = {} 2439 checkvars = {}
2333 checkvars['S'] = '${WORKDIR}/${BPN}-%s' % recipever 2440 checkvars['S'] = '${UNPACKDIR}/${BPN}-%s' % recipever
2334 checkvars['SRC_URI'] = url 2441 checkvars['SRC_URI'] = url
2335 self._test_recipe_contents(newrecipefile, checkvars, []) 2442 self._test_recipe_contents(newrecipefile, checkvars, [])
2336 2443
@@ -2452,7 +2559,7 @@ class DevtoolIdeSdkTests(DevtoolBase):
2452 self.track_for_cleanup(tempdir) 2559 self.track_for_cleanup(tempdir)
2453 self.add_command_to_tearDown('bitbake -c clean %s' % recipe_name) 2560 self.add_command_to_tearDown('bitbake -c clean %s' % recipe_name)
2454 2561
2455 result = runCmd('devtool modify %s -x %s' % (recipe_name, tempdir)) 2562 result = runCmd('devtool modify %s -x %s --debug-build' % (recipe_name, tempdir))
2456 self.assertExists(os.path.join(tempdir, build_file), 2563 self.assertExists(os.path.join(tempdir, build_file),
2457 'Extracted source could not be found') 2564 'Extracted source could not be found')
2458 self.assertExists(os.path.join(self.workspacedir, 'conf', 2565 self.assertExists(os.path.join(self.workspacedir, 'conf',
@@ -2504,11 +2611,6 @@ class DevtoolIdeSdkTests(DevtoolBase):
2504 i_and_d_script_path = os.path.join( 2611 i_and_d_script_path = os.path.join(
2505 self._workspace_scripts_dir(recipe_name), i_and_d_script) 2612 self._workspace_scripts_dir(recipe_name), i_and_d_script)
2506 self.assertExists(i_and_d_script_path) 2613 self.assertExists(i_and_d_script_path)
2507 del_script = "delete_package_dirs_" + recipe_id
2508 del_script_path = os.path.join(
2509 self._workspace_scripts_dir(recipe_name), del_script)
2510 self.assertExists(del_script_path)
2511 runCmd(del_script_path, cwd=tempdir)
2512 2614
2513 def _devtool_ide_sdk_qemu(self, tempdir, qemu, recipe_name, example_exe): 2615 def _devtool_ide_sdk_qemu(self, tempdir, qemu, recipe_name, example_exe):
2514 """Verify deployment and execution in Qemu system work for one recipe. 2616 """Verify deployment and execution in Qemu system work for one recipe.