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.py99
1 files changed, 67 insertions, 32 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index bc1e40ef83..1cafb922ea 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -286,10 +286,13 @@ class DevtoolTestCase(OESelftestTestCase):
else:
self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test')
- def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri):
+ def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri, srcrev=None):
self.track_for_cleanup(self.workspacedir)
self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
- result = runCmd('devtool add --version %s %s %s' % (version, pn, git_url))
+ command = 'devtool add --version %s %s %s' % (version, pn, git_url)
+ if srcrev :
+ command += ' --srcrev %s' %srcrev
+ result = runCmd(command)
self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
# Check the recipe name is correct
recipefile = get_bb_var('FILE', pn)
@@ -479,11 +482,12 @@ class DevtoolAddTests(DevtoolBase):
def test_devtool_add_git_style2(self):
version = 'v3.1.0'
+ srcrev = 'v3.1.0'
pn = 'mbedtls'
# this will trigger reformat_git_uri with branch parameter in url
git_url = "'git://git@github.com/ARMmbed/mbedtls.git;protocol=https'"
- resulting_src_uri = "gitsm://git@github.com/ARMmbed/mbedtls.git;protocol=https;branch=master"
- self._test_devtool_add_git_url(git_url, version, pn, resulting_src_uri)
+ resulting_src_uri = "git://git@github.com/ARMmbed/mbedtls.git;protocol=https;branch=master"
+ self._test_devtool_add_git_url(git_url, version, pn, resulting_src_uri, srcrev)
def test_devtool_add_library(self):
# Fetch source
@@ -749,6 +753,25 @@ class DevtoolModifyTests(DevtoolBase):
result = runCmd('devtool status')
self.assertNotIn('mdadm', result.output)
+ def test_devtool_modify_go(self):
+ import oe.path
+ from tempfile import TemporaryDirectory
+ with TemporaryDirectory(prefix='devtoolqa') as tempdir:
+ self.track_for_cleanup(self.workspacedir)
+ self.add_command_to_tearDown('bitbake -c clean go-helloworld')
+ self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+ result = runCmd('devtool modify go-helloworld -x %s' % tempdir)
+ self.assertExists(
+ oe.path.join(tempdir, 'src', 'golang.org', 'x', 'example', 'go.mod'),
+ 'Extracted source could not be found'
+ )
+ self.assertExists(
+ oe.path.join(self.workspacedir, 'conf', 'layer.conf'),
+ 'Workspace directory not created'
+ )
+ matches = glob.glob(oe.path.join(self.workspacedir, 'appends', 'go-helloworld_*.bbappend'))
+ self.assertTrue(matches, 'bbappend not created %s' % result.output)
+
def test_devtool_buildclean(self):
def assertFile(path, *paths):
f = os.path.join(path, *paths)
@@ -875,13 +898,8 @@ class DevtoolModifyTests(DevtoolBase):
self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe)
self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
- srcfile = os.path.join(tempdir, 'oe-local-files/share/dot.bashrc')
- srclink = os.path.join(tempdir, 'share/dot.bashrc')
+ srcfile = os.path.join(tempdir, 'share/dot.bashrc')
self.assertExists(srcfile, 'Extracted source could not be found')
- if os.path.islink(srclink) and os.path.exists(srclink) and os.path.samefile(srcfile, srclink):
- correct_symlink = True
- self.assertTrue(correct_symlink, 'Source symlink to oe-local-files is broken')
-
matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe))
self.assertTrue(matches, 'bbappend not created')
# Test devtool status
@@ -952,9 +970,9 @@ class DevtoolModifyTests(DevtoolBase):
# others git:// in SRC_URI
# cointains a patch
testrecipe = 'hello-rs'
- bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'WORKDIR', 'CARGO_HOME'], testrecipe)
+ bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'UNPACKDIR', 'CARGO_HOME'], testrecipe)
recipefile = bb_vars['FILE']
- workdir = bb_vars['WORKDIR']
+ unpackdir = bb_vars['UNPACKDIR']
cargo_home = bb_vars['CARGO_HOME']
src_uri = bb_vars['SRC_URI'].split()
self.assertTrue(src_uri[0].startswith('git://'),
@@ -1025,7 +1043,7 @@ class DevtoolModifyTests(DevtoolBase):
self.assertEqual(parms['type'], 'git-dependency', 'git dependencies uri should have "type=git-dependency"')
raw_url = raw_url.replace("git://", '%s://' % parms['protocol'])
patch_line = '[patch."%s"]' % raw_url
- path_patched = os.path.join(workdir, parms['destsuffix'])
+ path_patched = os.path.join(unpackdir, parms['destsuffix'])
path_override_line = '%s = { path = "%s" }' % (parms['name'], path_patched)
# Would have been better to use tomllib to read this file :/
self.assertIn(patch_line, cargo_config_contents)
@@ -1274,7 +1292,7 @@ class DevtoolUpdateTests(DevtoolBase):
with open(bbappendfile, 'r') as f:
self.assertEqual(expectedlines, f.readlines())
# Drop new commit and check patch gets deleted
- result = runCmd('git reset HEAD^', cwd=tempsrcdir)
+ result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir)
result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
self.assertNotExists(patchfile, 'Patch file not deleted')
expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
@@ -1283,6 +1301,7 @@ class DevtoolUpdateTests(DevtoolBase):
self.assertEqual(expectedlines2, f.readlines())
# Put commit back and check we can run it if layer isn't in bblayers.conf
os.remove(bbappendfile)
+ result = runCmd("sed 's!\\(#define VERSION\\W*\"[^\"]*\\)\"!\\1-custom\"!' -i ReadMe.c", cwd=tempsrcdir)
result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir)
result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir)
result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
@@ -1357,7 +1376,7 @@ class DevtoolUpdateTests(DevtoolBase):
with open(bbappendfile, 'r') as f:
self.assertEqual(expectedlines, set(f.readlines()))
# Drop new commit and check SRCREV changes
- result = runCmd('git reset HEAD^', cwd=tempsrcdir)
+ result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir)
result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
self.assertNotExists(os.path.join(appenddir, testrecipe), 'Patch directory should not be created')
result = runCmd('git rev-parse HEAD', cwd=tempsrcdir)
@@ -1369,6 +1388,7 @@ class DevtoolUpdateTests(DevtoolBase):
self.assertEqual(expectedlines, set(f.readlines()))
# Put commit back and check we can run it if layer isn't in bblayers.conf
os.remove(bbappendfile)
+ result = runCmd('echo "# Additional line" >> Makefile.am', cwd=tempsrcdir)
result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir)
result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir)
result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
@@ -1400,22 +1420,39 @@ class DevtoolUpdateTests(DevtoolBase):
# Try building just to ensure we haven't broken that
bitbake("%s" % testrecipe)
# Edit / commit local source
- runCmd('echo "/* Foobar */" >> oe-local-files/makedevs.c', cwd=tempdir)
- runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir)
+ runCmd('echo "/* Foobar */" >> makedevs.c', cwd=tempdir)
+ runCmd('echo "Foo" > new-local', cwd=tempdir)
runCmd('echo "Bar" > new-file', cwd=tempdir)
runCmd('git add new-file', cwd=tempdir)
runCmd('git commit -m "Add new file"', cwd=tempdir)
- self.add_command_to_tearDown('cd %s; git clean -fd .; git checkout .' %
- os.path.dirname(recipefile))
+ runCmd('git add new-local', cwd=tempdir)
runCmd('devtool update-recipe %s' % testrecipe)
expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)),
(' M', '.*/makedevs/makedevs.c$'),
('??', '.*/makedevs/new-local$'),
('??', '.*/makedevs/0001-Add-new-file.patch$')]
self._check_repo_status(os.path.dirname(recipefile), expected_status)
-
- def test_devtool_update_recipe_local_files_2(self):
- """Check local source files support when oe-local-files is in Git"""
+ # Now try to update recipe in another layer, so first, clean it
+ runCmd('cd %s; git clean -fd .; git checkout .' % os.path.dirname(recipefile))
+ # Create a temporary layer and add it to bblayers.conf
+ self._create_temp_layer(templayerdir, True, 'templayer')
+ # Update recipe in templayer
+ result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
+ self.assertNotIn('WARNING:', result.output)
+ # Check recipe is still clean
+ self._check_repo_status(os.path.dirname(recipefile), [])
+ splitpath = os.path.dirname(recipefile).split(os.sep)
+ appenddir = os.path.join(templayerdir, splitpath[-2], splitpath[-1])
+ bbappendfile = self._check_bbappend(testrecipe, recipefile, appenddir)
+ patchfile = os.path.join(appenddir, testrecipe, '0001-Add-new-file.patch')
+ new_local_file = os.path.join(appenddir, testrecipe, 'new_local')
+ local_file = os.path.join(appenddir, testrecipe, 'makedevs.c')
+ self.assertExists(patchfile, 'Patch file 0001-Add-new-file.patch not created')
+ self.assertExists(local_file, 'File makedevs.c not created')
+ self.assertExists(patchfile, 'File new_local not created')
+
+ def _test_devtool_update_recipe_local_files_2(self):
+ """Check local source files support when editing local files in Git"""
testrecipe = 'devtool-test-local'
recipefile = get_bb_var('FILE', testrecipe)
recipedir = os.path.dirname(recipefile)
@@ -1430,17 +1467,13 @@ class DevtoolUpdateTests(DevtoolBase):
result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
# Check git repo
self._check_src_repo(tempdir)
- # Add oe-local-files to Git
- runCmd('rm oe-local-files/.gitignore', cwd=tempdir)
- runCmd('git add oe-local-files', cwd=tempdir)
- runCmd('git commit -m "Add local sources"', cwd=tempdir)
# Edit / commit local sources
- runCmd('echo "# Foobar" >> oe-local-files/file1', cwd=tempdir)
+ runCmd('echo "# Foobar" >> file1', cwd=tempdir)
runCmd('git commit -am "Edit existing file"', cwd=tempdir)
- runCmd('git rm oe-local-files/file2', cwd=tempdir)
+ runCmd('git rm file2', cwd=tempdir)
runCmd('git commit -m"Remove file"', cwd=tempdir)
- runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir)
- runCmd('git add oe-local-files/new-local', cwd=tempdir)
+ runCmd('echo "Foo" > new-local', cwd=tempdir)
+ runCmd('git add new-local', cwd=tempdir)
runCmd('git commit -m "Add new local file"', cwd=tempdir)
runCmd('echo "Gar" > new-file', cwd=tempdir)
runCmd('git add new-file', cwd=tempdir)
@@ -1449,7 +1482,7 @@ class DevtoolUpdateTests(DevtoolBase):
os.path.dirname(recipefile))
# Checkout unmodified file to working copy -> devtool should still pick
# the modified version from HEAD
- runCmd('git checkout HEAD^ -- oe-local-files/file1', cwd=tempdir)
+ runCmd('git checkout HEAD^ -- file1', cwd=tempdir)
runCmd('devtool update-recipe %s' % testrecipe)
expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)),
(' M', '.*/file1$'),
@@ -1524,7 +1557,7 @@ class DevtoolUpdateTests(DevtoolBase):
# (don't bother with cleaning the recipe on teardown, we won't be building it)
result = runCmd('devtool modify %s' % testrecipe)
# Modify one file
- runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe, 'oe-local-files'))
+ runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe))
self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile)))
result = runCmd('devtool update-recipe %s' % testrecipe)
expected_status = [(' M', '.*/%s/file2$' % testrecipe)]
@@ -1753,6 +1786,8 @@ class DevtoolExtractTests(DevtoolBase):
# Definitions
testrecipe = 'mdadm'
testfile = '/sbin/mdadm'
+ if "usrmerge" in get_bb_var('DISTRO_FEATURES'):
+ testfile = '/usr/sbin/mdadm'
testimage = 'oe-selftest-image'
testcommand = '/sbin/mdadm --help'
# Build an image to run