diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/devtool.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/devtool.py | 182 |
1 files changed, 132 insertions, 50 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index c8f9534e41..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('\\'): |
@@ -317,7 +321,7 @@ class DevtoolBase(DevtoolTestCase): | |||
317 | cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate | 321 | cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate |
318 | cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n' | 322 | cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n' |
319 | % cls.original_sstate) | 323 | % cls.original_sstate) |
320 | cls.sstate_conf += ('BB_HASHSERVE_UPSTREAM = "hashserv.yocto.io:8687"\n') | 324 | cls.sstate_conf += ('BB_HASHSERVE_UPSTREAM = "hashserv.yoctoproject.org:8686"\n') |
321 | 325 | ||
322 | @classmethod | 326 | @classmethod |
323 | def tearDownClass(cls): | 327 | def tearDownClass(cls): |
@@ -465,7 +469,7 @@ class DevtoolAddTests(DevtoolBase): | |||
465 | checkvars = {} | 469 | checkvars = {} |
466 | checkvars['LICENSE'] = 'GPL-2.0-only' | 470 | checkvars['LICENSE'] = 'GPL-2.0-only' |
467 | checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263' | 471 | checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263' |
468 | checkvars['S'] = '${WORKDIR}/git' | 472 | checkvars['S'] = None |
469 | checkvars['PV'] = '0.1+git' | 473 | checkvars['PV'] = '0.1+git' |
470 | 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' |
471 | checkvars['SRCREV'] = srcrev | 475 | checkvars['SRCREV'] = srcrev |
@@ -561,7 +565,7 @@ class DevtoolAddTests(DevtoolBase): | |||
561 | recipefile = get_bb_var('FILE', testrecipe) | 565 | recipefile = get_bb_var('FILE', testrecipe) |
562 | 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') |
563 | checkvars = {} | 567 | checkvars = {} |
564 | checkvars['S'] = '${WORKDIR}/MarkupSafe-${PV}' | 568 | checkvars['S'] = '${UNPACKDIR}/MarkupSafe-${PV}' |
565 | checkvars['SRC_URI'] = url.replace(testver, '${PV}') | 569 | checkvars['SRC_URI'] = url.replace(testver, '${PV}') |
566 | self._test_recipe_contents(recipefile, checkvars, []) | 570 | self._test_recipe_contents(recipefile, checkvars, []) |
567 | # Try with version specified | 571 | # Try with version specified |
@@ -578,7 +582,7 @@ class DevtoolAddTests(DevtoolBase): | |||
578 | recipefile = get_bb_var('FILE', testrecipe) | 582 | recipefile = get_bb_var('FILE', testrecipe) |
579 | 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') |
580 | checkvars = {} | 584 | checkvars = {} |
581 | checkvars['S'] = '${WORKDIR}/MarkupSafe-%s' % testver | 585 | checkvars['S'] = '${UNPACKDIR}/MarkupSafe-%s' % testver |
582 | checkvars['SRC_URI'] = url | 586 | checkvars['SRC_URI'] = url |
583 | self._test_recipe_contents(recipefile, checkvars, []) | 587 | self._test_recipe_contents(recipefile, checkvars, []) |
584 | 588 | ||
@@ -605,7 +609,7 @@ class DevtoolAddTests(DevtoolBase): | |||
605 | recipefile = get_bb_var('FILE', testrecipe) | 609 | recipefile = get_bb_var('FILE', testrecipe) |
606 | self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named') | 610 | self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named') |
607 | checkvars = {} | 611 | checkvars = {} |
608 | checkvars['S'] = '${WORKDIR}/git' | 612 | checkvars['S'] = None |
609 | checkvars['PV'] = '1.0+git' | 613 | checkvars['PV'] = '1.0+git' |
610 | checkvars['SRC_URI'] = url_branch | 614 | checkvars['SRC_URI'] = url_branch |
611 | checkvars['SRCREV'] = '${AUTOREV}' | 615 | checkvars['SRCREV'] = '${AUTOREV}' |
@@ -624,7 +628,7 @@ class DevtoolAddTests(DevtoolBase): | |||
624 | recipefile = get_bb_var('FILE', testrecipe) | 628 | recipefile = get_bb_var('FILE', testrecipe) |
625 | self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named') | 629 | self.assertIn('_git.bb', recipefile, 'Recipe file incorrectly named') |
626 | checkvars = {} | 630 | checkvars = {} |
627 | checkvars['S'] = '${WORKDIR}/git' | 631 | checkvars['S'] = None |
628 | checkvars['PV'] = '1.5+git' | 632 | checkvars['PV'] = '1.5+git' |
629 | checkvars['SRC_URI'] = url_branch | 633 | checkvars['SRC_URI'] = url_branch |
630 | checkvars['SRCREV'] = checkrev | 634 | checkvars['SRCREV'] = checkrev |
@@ -753,6 +757,25 @@ class DevtoolModifyTests(DevtoolBase): | |||
753 | result = runCmd('devtool status') | 757 | result = runCmd('devtool status') |
754 | self.assertNotIn('mdadm', result.output) | 758 | self.assertNotIn('mdadm', result.output) |
755 | 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 | |||
756 | def test_devtool_buildclean(self): | 779 | def test_devtool_buildclean(self): |
757 | def assertFile(path, *paths): | 780 | def assertFile(path, *paths): |
758 | f = os.path.join(path, *paths) | 781 | f = os.path.join(path, *paths) |
@@ -879,13 +902,8 @@ class DevtoolModifyTests(DevtoolBase): | |||
879 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) | 902 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) |
880 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | 903 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') |
881 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 904 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
882 | srcfile = os.path.join(tempdir, 'oe-local-files/share/dot.bashrc') | 905 | srcfile = os.path.join(tempdir, 'share/dot.bashrc') |
883 | srclink = os.path.join(tempdir, 'share/dot.bashrc') | ||
884 | self.assertExists(srcfile, 'Extracted source could not be found') | 906 | self.assertExists(srcfile, 'Extracted source could not be found') |
885 | if os.path.islink(srclink) and os.path.exists(srclink) and os.path.samefile(srcfile, srclink): | ||
886 | correct_symlink = True | ||
887 | self.assertTrue(correct_symlink, 'Source symlink to oe-local-files is broken') | ||
888 | |||
889 | 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)) |
890 | self.assertTrue(matches, 'bbappend not created') | 908 | self.assertTrue(matches, 'bbappend not created') |
891 | # Test devtool status | 909 | # Test devtool status |
@@ -956,9 +974,9 @@ class DevtoolModifyTests(DevtoolBase): | |||
956 | # others git:// in SRC_URI | 974 | # others git:// in SRC_URI |
957 | # cointains a patch | 975 | # cointains a patch |
958 | testrecipe = 'hello-rs' | 976 | testrecipe = 'hello-rs' |
959 | 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) |
960 | recipefile = bb_vars['FILE'] | 978 | recipefile = bb_vars['FILE'] |
961 | workdir = bb_vars['WORKDIR'] | 979 | unpackdir = bb_vars['UNPACKDIR'] |
962 | cargo_home = bb_vars['CARGO_HOME'] | 980 | cargo_home = bb_vars['CARGO_HOME'] |
963 | src_uri = bb_vars['SRC_URI'].split() | 981 | src_uri = bb_vars['SRC_URI'].split() |
964 | self.assertTrue(src_uri[0].startswith('git://'), | 982 | self.assertTrue(src_uri[0].startswith('git://'), |
@@ -1009,7 +1027,7 @@ class DevtoolModifyTests(DevtoolBase): | |||
1009 | # 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 |
1010 | bitbake('-c configure %s' % testrecipe) | 1028 | bitbake('-c configure %s' % testrecipe) |
1011 | 1029 | ||
1012 | cargo_config_path = os.path.join(cargo_home, 'config') | 1030 | cargo_config_path = os.path.join(cargo_home, 'config.toml') |
1013 | with open(cargo_config_path, "r") as f: | 1031 | with open(cargo_config_path, "r") as f: |
1014 | cargo_config_contents = [line.strip('\n') for line in f.readlines()] | 1032 | cargo_config_contents = [line.strip('\n') for line in f.readlines()] |
1015 | 1033 | ||
@@ -1029,7 +1047,7 @@ class DevtoolModifyTests(DevtoolBase): | |||
1029 | 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"') |
1030 | raw_url = raw_url.replace("git://", '%s://' % parms['protocol']) | 1048 | raw_url = raw_url.replace("git://", '%s://' % parms['protocol']) |
1031 | patch_line = '[patch."%s"]' % raw_url | 1049 | patch_line = '[patch."%s"]' % raw_url |
1032 | path_patched = os.path.join(workdir, parms['destsuffix']) | 1050 | path_patched = os.path.join(unpackdir, parms['destsuffix']) |
1033 | path_override_line = '%s = { path = "%s" }' % (parms['name'], path_patched) | 1051 | path_override_line = '%s = { path = "%s" }' % (parms['name'], path_patched) |
1034 | # Would have been better to use tomllib to read this file :/ | 1052 | # Would have been better to use tomllib to read this file :/ |
1035 | self.assertIn(patch_line, cargo_config_contents) | 1053 | self.assertIn(patch_line, cargo_config_contents) |
@@ -1167,13 +1185,16 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1167 | result = runCmd('echo "A new file" > devtool-new-file', cwd=tempdir) | 1185 | result = runCmd('echo "A new file" > devtool-new-file', cwd=tempdir) |
1168 | result = runCmd('git add devtool-new-file', cwd=tempdir) | 1186 | result = runCmd('git add devtool-new-file', cwd=tempdir) |
1169 | result = runCmd('git commit -m "Add a new file"', cwd=tempdir) | 1187 | result = runCmd('git commit -m "Add a new file"', cwd=tempdir) |
1170 | 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) | ||
1171 | result = runCmd('devtool update-recipe %s' % testrecipe) | 1190 | result = runCmd('devtool update-recipe %s' % testrecipe) |
1172 | result = runCmd('git add minicom', cwd=os.path.dirname(recipefile)) | 1191 | result = runCmd('git add minicom', cwd=os.path.dirname(recipefile)) |
1173 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), | 1192 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), |
1174 | ('A ', '.*/0001-Change-the-README.patch$'), | 1193 | ('A ', '.*/0001-Change-the-README.patch$'), |
1175 | ('A ', '.*/0002-Add-a-new-file.patch$')] | 1194 | ('A ', '.*/0002-Add-a-new-file.patch$')] |
1176 | 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), []) | ||
1177 | 1198 | ||
1178 | def test_devtool_update_recipe_git(self): | 1199 | def test_devtool_update_recipe_git(self): |
1179 | # Check preconditions | 1200 | # Check preconditions |
@@ -1230,7 +1251,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1230 | 1251 | ||
1231 | def test_devtool_update_recipe_append(self): | 1252 | def test_devtool_update_recipe_append(self): |
1232 | # Check preconditions | 1253 | # Check preconditions |
1233 | testrecipe = 'mdadm' | 1254 | testrecipe = 'minicom' |
1234 | bb_vars = get_bb_vars(['FILE', 'SRC_URI'], testrecipe) | 1255 | bb_vars = get_bb_vars(['FILE', 'SRC_URI'], testrecipe) |
1235 | recipefile = bb_vars['FILE'] | 1256 | recipefile = bb_vars['FILE'] |
1236 | src_uri = bb_vars['SRC_URI'] | 1257 | src_uri = bb_vars['SRC_URI'] |
@@ -1248,7 +1269,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1248 | # Check git repo | 1269 | # Check git repo |
1249 | self._check_src_repo(tempsrcdir) | 1270 | self._check_src_repo(tempsrcdir) |
1250 | # Add a commit | 1271 | # Add a commit |
1251 | result = runCmd("sed 's!\\(#define VERSION\\W*\"[^\"]*\\)\"!\\1-custom\"!' -i ReadMe.c", cwd=tempsrcdir) | 1272 | result = runCmd('echo "Additional line" >> README', cwd=tempsrcdir) |
1252 | 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) |
1253 | 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)) |
1254 | # Create a temporary layer and add it to bblayers.conf | 1275 | # Create a temporary layer and add it to bblayers.conf |
@@ -1278,7 +1299,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1278 | with open(bbappendfile, 'r') as f: | 1299 | with open(bbappendfile, 'r') as f: |
1279 | self.assertEqual(expectedlines, f.readlines()) | 1300 | self.assertEqual(expectedlines, f.readlines()) |
1280 | # Drop new commit and check patch gets deleted | 1301 | # Drop new commit and check patch gets deleted |
1281 | result = runCmd('git reset HEAD^', cwd=tempsrcdir) | 1302 | result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir) |
1282 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) | 1303 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) |
1283 | self.assertNotExists(patchfile, 'Patch file not deleted') | 1304 | self.assertNotExists(patchfile, 'Patch file not deleted') |
1284 | expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', | 1305 | expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', |
@@ -1287,6 +1308,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1287 | self.assertEqual(expectedlines2, f.readlines()) | 1308 | self.assertEqual(expectedlines2, f.readlines()) |
1288 | # 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 |
1289 | os.remove(bbappendfile) | 1310 | os.remove(bbappendfile) |
1311 | result = runCmd('echo "Additional line" >> README', cwd=tempsrcdir) | ||
1290 | 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) |
1291 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) | 1313 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) |
1292 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) | 1314 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) |
@@ -1361,7 +1383,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1361 | with open(bbappendfile, 'r') as f: | 1383 | with open(bbappendfile, 'r') as f: |
1362 | self.assertEqual(expectedlines, set(f.readlines())) | 1384 | self.assertEqual(expectedlines, set(f.readlines())) |
1363 | # Drop new commit and check SRCREV changes | 1385 | # Drop new commit and check SRCREV changes |
1364 | result = runCmd('git reset HEAD^', cwd=tempsrcdir) | 1386 | result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir) |
1365 | 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)) |
1366 | 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') |
1367 | result = runCmd('git rev-parse HEAD', cwd=tempsrcdir) | 1389 | result = runCmd('git rev-parse HEAD', cwd=tempsrcdir) |
@@ -1373,6 +1395,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1373 | self.assertEqual(expectedlines, set(f.readlines())) | 1395 | self.assertEqual(expectedlines, set(f.readlines())) |
1374 | # 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 |
1375 | os.remove(bbappendfile) | 1397 | os.remove(bbappendfile) |
1398 | result = runCmd('echo "# Additional line" >> Makefile.am', cwd=tempsrcdir) | ||
1376 | result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) | 1399 | result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) |
1377 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) | 1400 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) |
1378 | 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)) |
@@ -1404,11 +1427,12 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1404 | # Try building just to ensure we haven't broken that | 1427 | # Try building just to ensure we haven't broken that |
1405 | bitbake("%s" % testrecipe) | 1428 | bitbake("%s" % testrecipe) |
1406 | # Edit / commit local source | 1429 | # Edit / commit local source |
1407 | runCmd('echo "/* Foobar */" >> oe-local-files/makedevs.c', cwd=tempdir) | 1430 | runCmd('echo "/* Foobar */" >> makedevs.c', cwd=tempdir) |
1408 | runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) | 1431 | runCmd('echo "Foo" > new-local', cwd=tempdir) |
1409 | runCmd('echo "Bar" > new-file', cwd=tempdir) | 1432 | runCmd('echo "Bar" > new-file', cwd=tempdir) |
1410 | runCmd('git add new-file', cwd=tempdir) | 1433 | runCmd('git add new-file', cwd=tempdir) |
1411 | runCmd('git commit -m "Add new file"', cwd=tempdir) | 1434 | runCmd('git commit -m "Add new file"', cwd=tempdir) |
1435 | runCmd('git add new-local', cwd=tempdir) | ||
1412 | runCmd('devtool update-recipe %s' % testrecipe) | 1436 | runCmd('devtool update-recipe %s' % testrecipe) |
1413 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), | 1437 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), |
1414 | (' M', '.*/makedevs/makedevs.c$'), | 1438 | (' M', '.*/makedevs/makedevs.c$'), |
@@ -1434,8 +1458,8 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1434 | self.assertExists(local_file, 'File makedevs.c not created') | 1458 | self.assertExists(local_file, 'File makedevs.c not created') |
1435 | self.assertExists(patchfile, 'File new_local not created') | 1459 | self.assertExists(patchfile, 'File new_local not created') |
1436 | 1460 | ||
1437 | def test_devtool_update_recipe_local_files_2(self): | 1461 | def _test_devtool_update_recipe_local_files_2(self): |
1438 | """Check local source files support when oe-local-files is in Git""" | 1462 | """Check local source files support when editing local files in Git""" |
1439 | testrecipe = 'devtool-test-local' | 1463 | testrecipe = 'devtool-test-local' |
1440 | recipefile = get_bb_var('FILE', testrecipe) | 1464 | recipefile = get_bb_var('FILE', testrecipe) |
1441 | recipedir = os.path.dirname(recipefile) | 1465 | recipedir = os.path.dirname(recipefile) |
@@ -1450,17 +1474,13 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1450 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 1474 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
1451 | # Check git repo | 1475 | # Check git repo |
1452 | self._check_src_repo(tempdir) | 1476 | self._check_src_repo(tempdir) |
1453 | # Add oe-local-files to Git | ||
1454 | runCmd('rm oe-local-files/.gitignore', cwd=tempdir) | ||
1455 | runCmd('git add oe-local-files', cwd=tempdir) | ||
1456 | runCmd('git commit -m "Add local sources"', cwd=tempdir) | ||
1457 | # Edit / commit local sources | 1477 | # Edit / commit local sources |
1458 | runCmd('echo "# Foobar" >> oe-local-files/file1', cwd=tempdir) | 1478 | runCmd('echo "# Foobar" >> file1', cwd=tempdir) |
1459 | runCmd('git commit -am "Edit existing file"', cwd=tempdir) | 1479 | runCmd('git commit -am "Edit existing file"', cwd=tempdir) |
1460 | runCmd('git rm oe-local-files/file2', cwd=tempdir) | 1480 | runCmd('git rm file2', cwd=tempdir) |
1461 | runCmd('git commit -m"Remove file"', cwd=tempdir) | 1481 | runCmd('git commit -m"Remove file"', cwd=tempdir) |
1462 | runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) | 1482 | runCmd('echo "Foo" > new-local', cwd=tempdir) |
1463 | runCmd('git add oe-local-files/new-local', cwd=tempdir) | 1483 | runCmd('git add new-local', cwd=tempdir) |
1464 | runCmd('git commit -m "Add new local file"', cwd=tempdir) | 1484 | runCmd('git commit -m "Add new local file"', cwd=tempdir) |
1465 | runCmd('echo "Gar" > new-file', cwd=tempdir) | 1485 | runCmd('echo "Gar" > new-file', cwd=tempdir) |
1466 | runCmd('git add new-file', cwd=tempdir) | 1486 | runCmd('git add new-file', cwd=tempdir) |
@@ -1469,7 +1489,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1469 | os.path.dirname(recipefile)) | 1489 | os.path.dirname(recipefile)) |
1470 | # Checkout unmodified file to working copy -> devtool should still pick | 1490 | # Checkout unmodified file to working copy -> devtool should still pick |
1471 | # the modified version from HEAD | 1491 | # the modified version from HEAD |
1472 | runCmd('git checkout HEAD^ -- oe-local-files/file1', cwd=tempdir) | 1492 | runCmd('git checkout HEAD^ -- file1', cwd=tempdir) |
1473 | runCmd('devtool update-recipe %s' % testrecipe) | 1493 | runCmd('devtool update-recipe %s' % testrecipe) |
1474 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), | 1494 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), |
1475 | (' M', '.*/file1$'), | 1495 | (' M', '.*/file1$'), |
@@ -1544,7 +1564,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1544 | # (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) |
1545 | result = runCmd('devtool modify %s' % testrecipe) | 1565 | result = runCmd('devtool modify %s' % testrecipe) |
1546 | # Modify one file | 1566 | # Modify one file |
1547 | 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)) |
1548 | 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))) |
1549 | result = runCmd('devtool update-recipe %s' % testrecipe) | 1569 | result = runCmd('devtool update-recipe %s' % testrecipe) |
1550 | expected_status = [(' M', '.*/%s/file2$' % testrecipe)] | 1570 | expected_status = [(' M', '.*/%s/file2$' % testrecipe)] |
@@ -1607,12 +1627,12 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1607 | # Check preconditions | 1627 | # Check preconditions |
1608 | testrecipe = 'dos2unix' | 1628 | testrecipe = 'dos2unix' |
1609 | self.append_config('ERROR_QA:remove:pn-dos2unix = "patch-status"\n') | 1629 | self.append_config('ERROR_QA:remove:pn-dos2unix = "patch-status"\n') |
1610 | 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) |
1611 | 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) |
1612 | workdir_git = '%s/git/' % bb_vars['WORKDIR'] | 1632 | unpackdir_git = '%s/%s/' % (bb_vars['UNPACKDIR'], bb_vars['BB_GIT_DEFAULT_DESTSUFFIX']) |
1613 | if not bb_vars['S'].startswith(workdir_git): | 1633 | if not bb_vars['S'].startswith(unpackdir_git): |
1614 | 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) |
1615 | subdir = bb_vars['S'].split(workdir_git, 1)[1] | 1635 | subdir = bb_vars['S'].split(unpackdir_git, 1)[1] |
1616 | # Clean up anything in the workdir/sysroot/sstate cache | 1636 | # Clean up anything in the workdir/sysroot/sstate cache |
1617 | bitbake('%s -c cleansstate' % testrecipe) | 1637 | bitbake('%s -c cleansstate' % testrecipe) |
1618 | # Try modifying a recipe | 1638 | # Try modifying a recipe |
@@ -1740,6 +1760,8 @@ class DevtoolExtractTests(DevtoolBase): | |||
1740 | 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') |
1741 | self._check_src_repo(tempdir) | 1761 | self._check_src_repo(tempdir) |
1742 | 1762 | ||
1763 | class DevtoolResetTests(DevtoolBase): | ||
1764 | |||
1743 | def test_devtool_reset_all(self): | 1765 | def test_devtool_reset_all(self): |
1744 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | 1766 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') |
1745 | self.track_for_cleanup(tempdir) | 1767 | self.track_for_cleanup(tempdir) |
@@ -1766,6 +1788,21 @@ class DevtoolExtractTests(DevtoolBase): | |||
1766 | matches2 = glob.glob(stampprefix2 + '*') | 1788 | matches2 = glob.glob(stampprefix2 + '*') |
1767 | 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) |
1768 | 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 | |||
1804 | class DevtoolDeployTargetTests(DevtoolBase): | ||
1805 | |||
1769 | @OETestTag("runqemu") | 1806 | @OETestTag("runqemu") |
1770 | def test_devtool_deploy_target(self): | 1807 | def test_devtool_deploy_target(self): |
1771 | self._check_runqemu_prerequisites() | 1808 | self._check_runqemu_prerequisites() |
@@ -1773,6 +1810,8 @@ class DevtoolExtractTests(DevtoolBase): | |||
1773 | # Definitions | 1810 | # Definitions |
1774 | testrecipe = 'mdadm' | 1811 | testrecipe = 'mdadm' |
1775 | testfile = '/sbin/mdadm' | 1812 | testfile = '/sbin/mdadm' |
1813 | if "usrmerge" in get_bb_var('DISTRO_FEATURES'): | ||
1814 | testfile = '/usr/sbin/mdadm' | ||
1776 | testimage = 'oe-selftest-image' | 1815 | testimage = 'oe-selftest-image' |
1777 | testcommand = '/sbin/mdadm --help' | 1816 | testcommand = '/sbin/mdadm --help' |
1778 | # Build an image to run | 1817 | # Build an image to run |
@@ -1831,6 +1870,8 @@ class DevtoolExtractTests(DevtoolBase): | |||
1831 | 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) |
1832 | 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') |
1833 | 1872 | ||
1873 | class DevtoolBuildImageTests(DevtoolBase): | ||
1874 | |||
1834 | def test_devtool_build_image(self): | 1875 | def test_devtool_build_image(self): |
1835 | """Test devtool build-image plugin""" | 1876 | """Test devtool build-image plugin""" |
1836 | # Check preconditions | 1877 | # Check preconditions |
@@ -2002,6 +2043,52 @@ class DevtoolUpgradeTests(DevtoolBase): | |||
2002 | newlines = f.readlines() | 2043 | newlines = f.readlines() |
2003 | self.assertEqual(desiredlines, newlines) | 2044 | self.assertEqual(desiredlines, newlines) |
2004 | 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 | |||
2005 | def test_devtool_layer_plugins(self): | 2092 | def test_devtool_layer_plugins(self): |
2006 | """Test that devtool can use plugins from other layers. | 2093 | """Test that devtool can use plugins from other layers. |
2007 | 2094 | ||
@@ -2327,7 +2414,7 @@ class DevtoolUpgradeTests(DevtoolBase): | |||
2327 | newsrctree = os.path.join(self.workspacedir, 'sources', newrecipename) | 2414 | newsrctree = os.path.join(self.workspacedir, 'sources', newrecipename) |
2328 | self.assertExists(newsrctree, 'Source directory not renamed') | 2415 | self.assertExists(newsrctree, 'Source directory not renamed') |
2329 | checkvars = {} | 2416 | checkvars = {} |
2330 | checkvars['S'] = '${WORKDIR}/%s-%s' % (recipename, recipever) | 2417 | checkvars['S'] = '${UNPACKDIR}/%s-%s' % (recipename, recipever) |
2331 | checkvars['SRC_URI'] = url | 2418 | checkvars['SRC_URI'] = url |
2332 | self._test_recipe_contents(newrecipefile, checkvars, []) | 2419 | self._test_recipe_contents(newrecipefile, checkvars, []) |
2333 | # Try again - change just name this time | 2420 | # Try again - change just name this time |
@@ -2339,7 +2426,7 @@ class DevtoolUpgradeTests(DevtoolBase): | |||
2339 | 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') |
2340 | 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') |
2341 | checkvars = {} | 2428 | checkvars = {} |
2342 | checkvars['S'] = '${WORKDIR}/%s-${PV}' % recipename | 2429 | checkvars['S'] = '${UNPACKDIR}/%s-${PV}' % recipename |
2343 | checkvars['SRC_URI'] = url.replace(recipever, '${PV}') | 2430 | checkvars['SRC_URI'] = url.replace(recipever, '${PV}') |
2344 | self._test_recipe_contents(newrecipefile, checkvars, []) | 2431 | self._test_recipe_contents(newrecipefile, checkvars, []) |
2345 | # Try again - change just version this time | 2432 | # Try again - change just version this time |
@@ -2350,7 +2437,7 @@ class DevtoolUpgradeTests(DevtoolBase): | |||
2350 | self.assertExists(newrecipefile, 'Recipe file not renamed') | 2437 | self.assertExists(newrecipefile, 'Recipe file not renamed') |
2351 | 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') |
2352 | checkvars = {} | 2439 | checkvars = {} |
2353 | checkvars['S'] = '${WORKDIR}/${BPN}-%s' % recipever | 2440 | checkvars['S'] = '${UNPACKDIR}/${BPN}-%s' % recipever |
2354 | checkvars['SRC_URI'] = url | 2441 | checkvars['SRC_URI'] = url |
2355 | self._test_recipe_contents(newrecipefile, checkvars, []) | 2442 | self._test_recipe_contents(newrecipefile, checkvars, []) |
2356 | 2443 | ||
@@ -2472,7 +2559,7 @@ class DevtoolIdeSdkTests(DevtoolBase): | |||
2472 | self.track_for_cleanup(tempdir) | 2559 | self.track_for_cleanup(tempdir) |
2473 | self.add_command_to_tearDown('bitbake -c clean %s' % recipe_name) | 2560 | self.add_command_to_tearDown('bitbake -c clean %s' % recipe_name) |
2474 | 2561 | ||
2475 | result = runCmd('devtool modify %s -x %s' % (recipe_name, tempdir)) | 2562 | result = runCmd('devtool modify %s -x %s --debug-build' % (recipe_name, tempdir)) |
2476 | self.assertExists(os.path.join(tempdir, build_file), | 2563 | self.assertExists(os.path.join(tempdir, build_file), |
2477 | 'Extracted source could not be found') | 2564 | 'Extracted source could not be found') |
2478 | self.assertExists(os.path.join(self.workspacedir, 'conf', | 2565 | self.assertExists(os.path.join(self.workspacedir, 'conf', |
@@ -2524,11 +2611,6 @@ class DevtoolIdeSdkTests(DevtoolBase): | |||
2524 | i_and_d_script_path = os.path.join( | 2611 | i_and_d_script_path = os.path.join( |
2525 | self._workspace_scripts_dir(recipe_name), i_and_d_script) | 2612 | self._workspace_scripts_dir(recipe_name), i_and_d_script) |
2526 | self.assertExists(i_and_d_script_path) | 2613 | self.assertExists(i_and_d_script_path) |
2527 | del_script = "delete_package_dirs_" + recipe_id | ||
2528 | del_script_path = os.path.join( | ||
2529 | self._workspace_scripts_dir(recipe_name), del_script) | ||
2530 | self.assertExists(del_script_path) | ||
2531 | runCmd(del_script_path, cwd=tempdir) | ||
2532 | 2614 | ||
2533 | 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): |
2534 | """Verify deployment and execution in Qemu system work for one recipe. | 2616 | """Verify deployment and execution in Qemu system work for one recipe. |