diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/devtool.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/devtool.py | 145 |
1 files changed, 113 insertions, 32 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index bc1e40ef83..432d9c9a67 100644 --- a/meta/lib/oeqa/selftest/cases/devtool.py +++ b/meta/lib/oeqa/selftest/cases/devtool.py | |||
@@ -286,10 +286,13 @@ class DevtoolTestCase(OESelftestTestCase): | |||
286 | else: | 286 | else: |
287 | self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') | 287 | self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') |
288 | 288 | ||
289 | def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri): | 289 | def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri, srcrev=None): |
290 | self.track_for_cleanup(self.workspacedir) | 290 | self.track_for_cleanup(self.workspacedir) |
291 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | 291 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') |
292 | result = runCmd('devtool add --version %s %s %s' % (version, pn, git_url)) | 292 | command = 'devtool add --version %s %s %s' % (version, pn, git_url) |
293 | if srcrev : | ||
294 | command += ' --srcrev %s' %srcrev | ||
295 | result = runCmd(command) | ||
293 | self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created') | 296 | self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created') |
294 | # Check the recipe name is correct | 297 | # Check the recipe name is correct |
295 | recipefile = get_bb_var('FILE', pn) | 298 | recipefile = get_bb_var('FILE', pn) |
@@ -479,11 +482,12 @@ class DevtoolAddTests(DevtoolBase): | |||
479 | 482 | ||
480 | def test_devtool_add_git_style2(self): | 483 | def test_devtool_add_git_style2(self): |
481 | version = 'v3.1.0' | 484 | version = 'v3.1.0' |
485 | srcrev = 'v3.1.0' | ||
482 | pn = 'mbedtls' | 486 | pn = 'mbedtls' |
483 | # this will trigger reformat_git_uri with branch parameter in url | 487 | # this will trigger reformat_git_uri with branch parameter in url |
484 | git_url = "'git://git@github.com/ARMmbed/mbedtls.git;protocol=https'" | 488 | 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" | 489 | 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) | 490 | self._test_devtool_add_git_url(git_url, version, pn, resulting_src_uri, srcrev) |
487 | 491 | ||
488 | def test_devtool_add_library(self): | 492 | def test_devtool_add_library(self): |
489 | # Fetch source | 493 | # Fetch source |
@@ -749,6 +753,25 @@ class DevtoolModifyTests(DevtoolBase): | |||
749 | result = runCmd('devtool status') | 753 | result = runCmd('devtool status') |
750 | self.assertNotIn('mdadm', result.output) | 754 | self.assertNotIn('mdadm', result.output) |
751 | 755 | ||
756 | def test_devtool_modify_go(self): | ||
757 | import oe.path | ||
758 | from tempfile import TemporaryDirectory | ||
759 | with TemporaryDirectory(prefix='devtoolqa') as tempdir: | ||
760 | self.track_for_cleanup(self.workspacedir) | ||
761 | self.add_command_to_tearDown('bitbake -c clean go-helloworld') | ||
762 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
763 | result = runCmd('devtool modify go-helloworld -x %s' % tempdir) | ||
764 | self.assertExists( | ||
765 | oe.path.join(tempdir, 'src', 'golang.org', 'x', 'example', 'go.mod'), | ||
766 | 'Extracted source could not be found' | ||
767 | ) | ||
768 | self.assertExists( | ||
769 | oe.path.join(self.workspacedir, 'conf', 'layer.conf'), | ||
770 | 'Workspace directory not created' | ||
771 | ) | ||
772 | matches = glob.glob(oe.path.join(self.workspacedir, 'appends', 'go-helloworld_*.bbappend')) | ||
773 | self.assertTrue(matches, 'bbappend not created %s' % result.output) | ||
774 | |||
752 | def test_devtool_buildclean(self): | 775 | def test_devtool_buildclean(self): |
753 | def assertFile(path, *paths): | 776 | def assertFile(path, *paths): |
754 | f = os.path.join(path, *paths) | 777 | f = os.path.join(path, *paths) |
@@ -875,13 +898,8 @@ class DevtoolModifyTests(DevtoolBase): | |||
875 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) | 898 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) |
876 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | 899 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') |
877 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 900 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
878 | srcfile = os.path.join(tempdir, 'oe-local-files/share/dot.bashrc') | 901 | 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') | 902 | 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)) | 903 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe)) |
886 | self.assertTrue(matches, 'bbappend not created') | 904 | self.assertTrue(matches, 'bbappend not created') |
887 | # Test devtool status | 905 | # Test devtool status |
@@ -952,9 +970,9 @@ class DevtoolModifyTests(DevtoolBase): | |||
952 | # others git:// in SRC_URI | 970 | # others git:// in SRC_URI |
953 | # cointains a patch | 971 | # cointains a patch |
954 | testrecipe = 'hello-rs' | 972 | testrecipe = 'hello-rs' |
955 | bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'WORKDIR', 'CARGO_HOME'], testrecipe) | 973 | bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'UNPACKDIR', 'CARGO_HOME'], testrecipe) |
956 | recipefile = bb_vars['FILE'] | 974 | recipefile = bb_vars['FILE'] |
957 | workdir = bb_vars['WORKDIR'] | 975 | unpackdir = bb_vars['UNPACKDIR'] |
958 | cargo_home = bb_vars['CARGO_HOME'] | 976 | cargo_home = bb_vars['CARGO_HOME'] |
959 | src_uri = bb_vars['SRC_URI'].split() | 977 | src_uri = bb_vars['SRC_URI'].split() |
960 | self.assertTrue(src_uri[0].startswith('git://'), | 978 | self.assertTrue(src_uri[0].startswith('git://'), |
@@ -1025,7 +1043,7 @@ class DevtoolModifyTests(DevtoolBase): | |||
1025 | self.assertEqual(parms['type'], 'git-dependency', 'git dependencies uri should have "type=git-dependency"') | 1043 | self.assertEqual(parms['type'], 'git-dependency', 'git dependencies uri should have "type=git-dependency"') |
1026 | raw_url = raw_url.replace("git://", '%s://' % parms['protocol']) | 1044 | raw_url = raw_url.replace("git://", '%s://' % parms['protocol']) |
1027 | patch_line = '[patch."%s"]' % raw_url | 1045 | patch_line = '[patch."%s"]' % raw_url |
1028 | path_patched = os.path.join(workdir, parms['destsuffix']) | 1046 | path_patched = os.path.join(unpackdir, parms['destsuffix']) |
1029 | path_override_line = '%s = { path = "%s" }' % (parms['name'], path_patched) | 1047 | path_override_line = '%s = { path = "%s" }' % (parms['name'], path_patched) |
1030 | # Would have been better to use tomllib to read this file :/ | 1048 | # Would have been better to use tomllib to read this file :/ |
1031 | self.assertIn(patch_line, cargo_config_contents) | 1049 | self.assertIn(patch_line, cargo_config_contents) |
@@ -1274,7 +1292,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1274 | with open(bbappendfile, 'r') as f: | 1292 | with open(bbappendfile, 'r') as f: |
1275 | self.assertEqual(expectedlines, f.readlines()) | 1293 | self.assertEqual(expectedlines, f.readlines()) |
1276 | # Drop new commit and check patch gets deleted | 1294 | # Drop new commit and check patch gets deleted |
1277 | result = runCmd('git reset HEAD^', cwd=tempsrcdir) | 1295 | result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir) |
1278 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) | 1296 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) |
1279 | self.assertNotExists(patchfile, 'Patch file not deleted') | 1297 | self.assertNotExists(patchfile, 'Patch file not deleted') |
1280 | expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', | 1298 | expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', |
@@ -1283,6 +1301,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1283 | self.assertEqual(expectedlines2, f.readlines()) | 1301 | self.assertEqual(expectedlines2, f.readlines()) |
1284 | # Put commit back and check we can run it if layer isn't in bblayers.conf | 1302 | # Put commit back and check we can run it if layer isn't in bblayers.conf |
1285 | os.remove(bbappendfile) | 1303 | os.remove(bbappendfile) |
1304 | result = runCmd("sed 's!\\(#define VERSION\\W*\"[^\"]*\\)\"!\\1-custom\"!' -i ReadMe.c", cwd=tempsrcdir) | ||
1286 | result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) | 1305 | result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) |
1287 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) | 1306 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) |
1288 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) | 1307 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) |
@@ -1357,7 +1376,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1357 | with open(bbappendfile, 'r') as f: | 1376 | with open(bbappendfile, 'r') as f: |
1358 | self.assertEqual(expectedlines, set(f.readlines())) | 1377 | self.assertEqual(expectedlines, set(f.readlines())) |
1359 | # Drop new commit and check SRCREV changes | 1378 | # Drop new commit and check SRCREV changes |
1360 | result = runCmd('git reset HEAD^', cwd=tempsrcdir) | 1379 | result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir) |
1361 | result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) | 1380 | 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') | 1381 | self.assertNotExists(os.path.join(appenddir, testrecipe), 'Patch directory should not be created') |
1363 | result = runCmd('git rev-parse HEAD', cwd=tempsrcdir) | 1382 | result = runCmd('git rev-parse HEAD', cwd=tempsrcdir) |
@@ -1369,6 +1388,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1369 | self.assertEqual(expectedlines, set(f.readlines())) | 1388 | self.assertEqual(expectedlines, set(f.readlines())) |
1370 | # Put commit back and check we can run it if layer isn't in bblayers.conf | 1389 | # Put commit back and check we can run it if layer isn't in bblayers.conf |
1371 | os.remove(bbappendfile) | 1390 | os.remove(bbappendfile) |
1391 | result = runCmd('echo "# Additional line" >> Makefile.am', cwd=tempsrcdir) | ||
1372 | result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) | 1392 | result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) |
1373 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) | 1393 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) |
1374 | result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) | 1394 | result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) |
@@ -1400,22 +1420,39 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1400 | # Try building just to ensure we haven't broken that | 1420 | # Try building just to ensure we haven't broken that |
1401 | bitbake("%s" % testrecipe) | 1421 | bitbake("%s" % testrecipe) |
1402 | # Edit / commit local source | 1422 | # Edit / commit local source |
1403 | runCmd('echo "/* Foobar */" >> oe-local-files/makedevs.c', cwd=tempdir) | 1423 | runCmd('echo "/* Foobar */" >> makedevs.c', cwd=tempdir) |
1404 | runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) | 1424 | runCmd('echo "Foo" > new-local', cwd=tempdir) |
1405 | runCmd('echo "Bar" > new-file', cwd=tempdir) | 1425 | runCmd('echo "Bar" > new-file', cwd=tempdir) |
1406 | runCmd('git add new-file', cwd=tempdir) | 1426 | runCmd('git add new-file', cwd=tempdir) |
1407 | runCmd('git commit -m "Add new file"', cwd=tempdir) | 1427 | runCmd('git commit -m "Add new file"', cwd=tempdir) |
1408 | self.add_command_to_tearDown('cd %s; git clean -fd .; git checkout .' % | 1428 | runCmd('git add new-local', cwd=tempdir) |
1409 | os.path.dirname(recipefile)) | ||
1410 | runCmd('devtool update-recipe %s' % testrecipe) | 1429 | runCmd('devtool update-recipe %s' % testrecipe) |
1411 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), | 1430 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), |
1412 | (' M', '.*/makedevs/makedevs.c$'), | 1431 | (' M', '.*/makedevs/makedevs.c$'), |
1413 | ('??', '.*/makedevs/new-local$'), | 1432 | ('??', '.*/makedevs/new-local$'), |
1414 | ('??', '.*/makedevs/0001-Add-new-file.patch$')] | 1433 | ('??', '.*/makedevs/0001-Add-new-file.patch$')] |
1415 | self._check_repo_status(os.path.dirname(recipefile), expected_status) | 1434 | self._check_repo_status(os.path.dirname(recipefile), expected_status) |
1416 | 1435 | # Now try to update recipe in another layer, so first, clean it | |
1417 | def test_devtool_update_recipe_local_files_2(self): | 1436 | 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""" | 1437 | # Create a temporary layer and add it to bblayers.conf |
1438 | self._create_temp_layer(templayerdir, True, 'templayer') | ||
1439 | # Update recipe in templayer | ||
1440 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) | ||
1441 | self.assertNotIn('WARNING:', result.output) | ||
1442 | # Check recipe is still clean | ||
1443 | self._check_repo_status(os.path.dirname(recipefile), []) | ||
1444 | splitpath = os.path.dirname(recipefile).split(os.sep) | ||
1445 | appenddir = os.path.join(templayerdir, splitpath[-2], splitpath[-1]) | ||
1446 | bbappendfile = self._check_bbappend(testrecipe, recipefile, appenddir) | ||
1447 | patchfile = os.path.join(appenddir, testrecipe, '0001-Add-new-file.patch') | ||
1448 | new_local_file = os.path.join(appenddir, testrecipe, 'new_local') | ||
1449 | local_file = os.path.join(appenddir, testrecipe, 'makedevs.c') | ||
1450 | self.assertExists(patchfile, 'Patch file 0001-Add-new-file.patch not created') | ||
1451 | self.assertExists(local_file, 'File makedevs.c not created') | ||
1452 | self.assertExists(patchfile, 'File new_local not created') | ||
1453 | |||
1454 | def _test_devtool_update_recipe_local_files_2(self): | ||
1455 | """Check local source files support when editing local files in Git""" | ||
1419 | testrecipe = 'devtool-test-local' | 1456 | testrecipe = 'devtool-test-local' |
1420 | recipefile = get_bb_var('FILE', testrecipe) | 1457 | recipefile = get_bb_var('FILE', testrecipe) |
1421 | recipedir = os.path.dirname(recipefile) | 1458 | recipedir = os.path.dirname(recipefile) |
@@ -1430,17 +1467,13 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1430 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 1467 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
1431 | # Check git repo | 1468 | # Check git repo |
1432 | self._check_src_repo(tempdir) | 1469 | 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 | 1470 | # Edit / commit local sources |
1438 | runCmd('echo "# Foobar" >> oe-local-files/file1', cwd=tempdir) | 1471 | runCmd('echo "# Foobar" >> file1', cwd=tempdir) |
1439 | runCmd('git commit -am "Edit existing file"', cwd=tempdir) | 1472 | runCmd('git commit -am "Edit existing file"', cwd=tempdir) |
1440 | runCmd('git rm oe-local-files/file2', cwd=tempdir) | 1473 | runCmd('git rm file2', cwd=tempdir) |
1441 | runCmd('git commit -m"Remove file"', cwd=tempdir) | 1474 | runCmd('git commit -m"Remove file"', cwd=tempdir) |
1442 | runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) | 1475 | runCmd('echo "Foo" > new-local', cwd=tempdir) |
1443 | runCmd('git add oe-local-files/new-local', cwd=tempdir) | 1476 | runCmd('git add new-local', cwd=tempdir) |
1444 | runCmd('git commit -m "Add new local file"', cwd=tempdir) | 1477 | runCmd('git commit -m "Add new local file"', cwd=tempdir) |
1445 | runCmd('echo "Gar" > new-file', cwd=tempdir) | 1478 | runCmd('echo "Gar" > new-file', cwd=tempdir) |
1446 | runCmd('git add new-file', cwd=tempdir) | 1479 | runCmd('git add new-file', cwd=tempdir) |
@@ -1449,7 +1482,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1449 | os.path.dirname(recipefile)) | 1482 | os.path.dirname(recipefile)) |
1450 | # Checkout unmodified file to working copy -> devtool should still pick | 1483 | # Checkout unmodified file to working copy -> devtool should still pick |
1451 | # the modified version from HEAD | 1484 | # the modified version from HEAD |
1452 | runCmd('git checkout HEAD^ -- oe-local-files/file1', cwd=tempdir) | 1485 | runCmd('git checkout HEAD^ -- file1', cwd=tempdir) |
1453 | runCmd('devtool update-recipe %s' % testrecipe) | 1486 | runCmd('devtool update-recipe %s' % testrecipe) |
1454 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), | 1487 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), |
1455 | (' M', '.*/file1$'), | 1488 | (' M', '.*/file1$'), |
@@ -1524,7 +1557,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1524 | # (don't bother with cleaning the recipe on teardown, we won't be building it) | 1557 | # (don't bother with cleaning the recipe on teardown, we won't be building it) |
1525 | result = runCmd('devtool modify %s' % testrecipe) | 1558 | result = runCmd('devtool modify %s' % testrecipe) |
1526 | # Modify one file | 1559 | # Modify one file |
1527 | runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe, 'oe-local-files')) | 1560 | 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))) | 1561 | 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) | 1562 | result = runCmd('devtool update-recipe %s' % testrecipe) |
1530 | expected_status = [(' M', '.*/%s/file2$' % testrecipe)] | 1563 | expected_status = [(' M', '.*/%s/file2$' % testrecipe)] |
@@ -1753,6 +1786,8 @@ class DevtoolExtractTests(DevtoolBase): | |||
1753 | # Definitions | 1786 | # Definitions |
1754 | testrecipe = 'mdadm' | 1787 | testrecipe = 'mdadm' |
1755 | testfile = '/sbin/mdadm' | 1788 | testfile = '/sbin/mdadm' |
1789 | if "usrmerge" in get_bb_var('DISTRO_FEATURES'): | ||
1790 | testfile = '/usr/sbin/mdadm' | ||
1756 | testimage = 'oe-selftest-image' | 1791 | testimage = 'oe-selftest-image' |
1757 | testcommand = '/sbin/mdadm --help' | 1792 | testcommand = '/sbin/mdadm --help' |
1758 | # Build an image to run | 1793 | # Build an image to run |
@@ -1982,6 +2017,52 @@ class DevtoolUpgradeTests(DevtoolBase): | |||
1982 | newlines = f.readlines() | 2017 | newlines = f.readlines() |
1983 | self.assertEqual(desiredlines, newlines) | 2018 | self.assertEqual(desiredlines, newlines) |
1984 | 2019 | ||
2020 | def test_devtool_upgrade_recipe_update_extra_tasks(self): | ||
2021 | # Check preconditions | ||
2022 | self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') | ||
2023 | self.track_for_cleanup(self.workspacedir) | ||
2024 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
2025 | recipe = 'python3-guessing-game' | ||
2026 | version = '0.2.0' | ||
2027 | commit = '40cf004c2772ffa20ea803fa3be1528a75be3e98' | ||
2028 | oldrecipefile = get_bb_var('FILE', recipe) | ||
2029 | oldcratesincfile = os.path.join(os.path.dirname(oldrecipefile), os.path.basename(oldrecipefile).strip('_git.bb') + '-crates.inc') | ||
2030 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
2031 | self.track_for_cleanup(tempdir) | ||
2032 | # Check that recipe is not already under devtool control | ||
2033 | result = runCmd('devtool status') | ||
2034 | self.assertNotIn(recipe, result.output) | ||
2035 | # Check upgrade | ||
2036 | result = runCmd('devtool upgrade %s %s --version %s --srcrev %s' % (recipe, tempdir, version, commit)) | ||
2037 | # Check if srctree at least is populated | ||
2038 | self.assertTrue(len(os.listdir(tempdir)) > 0, 'srctree (%s) should be populated with new (%s) source code' % (tempdir, commit)) | ||
2039 | # Check new recipe file and new -crates.inc files are present | ||
2040 | newrecipefile = os.path.join(self.workspacedir, 'recipes', recipe, os.path.basename(oldrecipefile)) | ||
2041 | newcratesincfile = os.path.join(self.workspacedir, 'recipes', recipe, os.path.basename(oldcratesincfile)) | ||
2042 | self.assertExists(newrecipefile, 'Recipe file should exist after upgrade') | ||
2043 | self.assertExists(newcratesincfile, 'Recipe crates.inc file should exist after upgrade') | ||
2044 | # Check devtool status and make sure recipe is present | ||
2045 | result = runCmd('devtool status') | ||
2046 | self.assertIn(recipe, result.output) | ||
2047 | self.assertIn(tempdir, result.output) | ||
2048 | # Check recipe got changed as expected | ||
2049 | with open(oldrecipefile + '.upgraded', 'r') as f: | ||
2050 | desiredlines = f.readlines() | ||
2051 | with open(newrecipefile, 'r') as f: | ||
2052 | newlines = f.readlines() | ||
2053 | self.assertEqual(desiredlines, newlines) | ||
2054 | # Check crates.inc got changed as expected | ||
2055 | with open(oldcratesincfile + '.upgraded', 'r') as f: | ||
2056 | desiredlines = f.readlines() | ||
2057 | with open(newcratesincfile, 'r') as f: | ||
2058 | newlines = f.readlines() | ||
2059 | self.assertEqual(desiredlines, newlines) | ||
2060 | # Check devtool reset recipe | ||
2061 | result = runCmd('devtool reset %s -n' % recipe) | ||
2062 | result = runCmd('devtool status') | ||
2063 | self.assertNotIn(recipe, result.output) | ||
2064 | self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after resetting') | ||
2065 | |||
1985 | def test_devtool_layer_plugins(self): | 2066 | def test_devtool_layer_plugins(self): |
1986 | """Test that devtool can use plugins from other layers. | 2067 | """Test that devtool can use plugins from other layers. |
1987 | 2068 | ||