diff options
| author | Julien Stephan <jstephan@baylibre.com> | 2023-11-22 12:08:17 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-01 11:48:25 +0000 |
| commit | 49f549a14288acf3bc795e64dc888be86825d6a7 (patch) | |
| tree | 842b7108a315e4fe9a8501564e5f3b6ad2750523 | |
| parent | 89f16624842a91e063dc9e6b98787d44c55e4900 (diff) | |
| download | poky-49f549a14288acf3bc795e64dc888be86825d6a7.tar.gz | |
oeqa/selftest/devtool: add test for git submodules
Add a test for gitsm recipes.
This tests that we can do changes on submodules, commit them and
properly extract the patches
(From OE-Core rev: 2fb69161fe9d25691b75a043ec5566ffe4a25b37)
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/devtool.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index ab58971fec..2a11886e4b 100644 --- a/meta/lib/oeqa/selftest/cases/devtool.py +++ b/meta/lib/oeqa/selftest/cases/devtool.py | |||
| @@ -1598,6 +1598,53 @@ class DevtoolUpdateTests(DevtoolBase): | |||
| 1598 | # Try building | 1598 | # Try building |
| 1599 | bitbake('%s -c patch' % testrecipe) | 1599 | bitbake('%s -c patch' % testrecipe) |
| 1600 | 1600 | ||
| 1601 | def test_devtool_git_submodules(self): | ||
| 1602 | # This tests if we can add a patch in a git submodule and extract it properly using devtool finish | ||
| 1603 | # Check preconditions | ||
| 1604 | self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') | ||
| 1605 | self.track_for_cleanup(self.workspacedir) | ||
| 1606 | recipe = 'vulkan-samples' | ||
| 1607 | src_uri = get_bb_var('SRC_URI', recipe) | ||
| 1608 | self.assertIn('gitsm://', src_uri, 'This test expects the %s recipe to be a git recipe with submodules' % recipe) | ||
| 1609 | oldrecipefile = get_bb_var('FILE', recipe) | ||
| 1610 | recipedir = os.path.dirname(oldrecipefile) | ||
| 1611 | result = runCmd('git status --porcelain .', cwd=recipedir) | ||
| 1612 | if result.output.strip(): | ||
| 1613 | self.fail('Recipe directory for %s contains uncommitted changes' % recipe) | ||
| 1614 | self.assertIn('/meta/', recipedir) | ||
| 1615 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
| 1616 | self.track_for_cleanup(tempdir) | ||
| 1617 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
| 1618 | result = runCmd('devtool modify %s %s' % (recipe, tempdir)) | ||
| 1619 | self.assertExists(os.path.join(tempdir, 'CMakeLists.txt'), 'Extracted source could not be found') | ||
| 1620 | # Test devtool status | ||
| 1621 | result = runCmd('devtool status') | ||
| 1622 | self.assertIn(recipe, result.output) | ||
| 1623 | self.assertIn(tempdir, result.output) | ||
| 1624 | # Modify a source file in a submodule, (grab the first one) | ||
| 1625 | result = runCmd('git submodule --quiet foreach \'echo $sm_path\'', cwd=tempdir) | ||
| 1626 | submodule = result.output.splitlines()[0] | ||
| 1627 | submodule_path = os.path.join(tempdir, submodule) | ||
| 1628 | runCmd('echo "#This is a first comment" >> testfile', cwd=submodule_path) | ||
| 1629 | result = runCmd('git status --porcelain . ', cwd=submodule_path) | ||
| 1630 | self.assertIn("testfile", result.output) | ||
| 1631 | runCmd('git add testfile; git commit -m "Adding a new file"', cwd=submodule_path) | ||
| 1632 | |||
| 1633 | # Try finish to the original layer | ||
| 1634 | self.add_command_to_tearDown('rm -rf %s ; cd %s ; git checkout %s' % (recipedir, os.path.dirname(recipedir), recipedir)) | ||
| 1635 | runCmd('devtool finish -f %s meta' % recipe) | ||
| 1636 | result = runCmd('devtool status') | ||
| 1637 | self.assertNotIn(recipe, result.output, 'Recipe should have been reset by finish but wasn\'t') | ||
| 1638 | self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after finish') | ||
| 1639 | expected_status = [(' M', '.*/%s$' % os.path.basename(oldrecipefile)), | ||
| 1640 | ('??', '.*/.*-Adding-a-new-file.patch$')] | ||
| 1641 | self._check_repo_status(recipedir, expected_status) | ||
| 1642 | # Make sure the patch is added to the recipe with the correct "patchdir" option | ||
| 1643 | result = runCmd('git diff .', cwd=recipedir) | ||
| 1644 | addlines = [ | ||
| 1645 | 'file://0001-Adding-a-new-file.patch;patchdir=%s \\\\' % submodule | ||
| 1646 | ] | ||
| 1647 | self._check_diff(result.output, addlines, []) | ||
| 1601 | 1648 | ||
| 1602 | class DevtoolExtractTests(DevtoolBase): | 1649 | class DevtoolExtractTests(DevtoolBase): |
| 1603 | 1650 | ||
