aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-11-28 15:16:26 +1300
committerPaul Eggleton <paul.eggleton@linux.intel.com>2017-12-05 14:39:24 +1300
commit8b8a491a037ad5a214b412dcaae999466d4aea64 (patch)
treea87714279576d242df220e71b95d4a88826d302b
parenta5f6739f23dda738c7b1862c672b9d9cdec8190e (diff)
downloadopenembedded-core-contrib-8b8a491a037ad5a214b412dcaae999466d4aea64.tar.gz
oe-selftest: devtool: add test for multiple source trees
Add two synthetic tests for devtool modify + devtool finish: first with multiple source trees side-by-side, and second to test with one as a subdirectory of the main source tree. These also test devtool finish's recently added dry-run option and that detects and errors on uncommitted changes without being forced. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--meta-selftest/recipes-test/devtool/devtool-test-multisrc-subdir_1.0.bb13
-rw-r--r--meta-selftest/recipes-test/devtool/devtool-test-multisrc/example-files.tar.gzbin0 -> 236 bytes
-rw-r--r--meta-selftest/recipes-test/devtool/devtool-test-multisrc/example.patch7
-rw-r--r--meta-selftest/recipes-test/devtool/devtool-test-multisrc/mypackage-1.0.tar.gzbin0 -> 903 bytes
-rw-r--r--meta-selftest/recipes-test/devtool/devtool-test-multisrc_1.0.bb11
-rw-r--r--meta/lib/oeqa/selftest/cases/devtool.py109
6 files changed, 140 insertions, 0 deletions
diff --git a/meta-selftest/recipes-test/devtool/devtool-test-multisrc-subdir_1.0.bb b/meta-selftest/recipes-test/devtool/devtool-test-multisrc-subdir_1.0.bb
new file mode 100644
index 0000000000..0430382429
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-test-multisrc-subdir_1.0.bb
@@ -0,0 +1,13 @@
+SUMMARY = "Recipe to test multiple source trees"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://settings-daemon.c;beginline=1;endline=26;md5=8d77ba1c7a55df48d8d06c5f3d86b49d"
+
+SRC_URI = "git://git.yoctoproject.org/xsettings-daemon;name=xsettings-daemon \
+ git://git.yoctoproject.org/libfakekey;name=libfakekey;destsuffix=git/libfakekey \
+"
+
+SRCREV_xsettings-daemon = "b2e5da502f8c5ff75e9e6da771372ef8e40fd9a2"
+SRCREV_libfakekey = "7ad885912efb2131e80914e964d5e635b0d07b40"
+
+S = "${WORKDIR}/git"
+
diff --git a/meta-selftest/recipes-test/devtool/devtool-test-multisrc/example-files.tar.gz b/meta-selftest/recipes-test/devtool/devtool-test-multisrc/example-files.tar.gz
new file mode 100644
index 0000000000..fdab4b7367
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-test-multisrc/example-files.tar.gz
Binary files differ
diff --git a/meta-selftest/recipes-test/devtool/devtool-test-multisrc/example.patch b/meta-selftest/recipes-test/devtool/devtool-test-multisrc/example.patch
new file mode 100644
index 0000000000..2e48bf1e7c
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-test-multisrc/example.patch
@@ -0,0 +1,7 @@
+diff -udNr example-files/test2 example-files2/test2
+--- example-files/test2 2017-11-22 10:29:11.766891385 +1300
++++ example-files2/test2 2017-11-22 10:30:08.920094705 +1300
+@@ -1 +1,3 @@
+ Another example file
++
++More content added here
diff --git a/meta-selftest/recipes-test/devtool/devtool-test-multisrc/mypackage-1.0.tar.gz b/meta-selftest/recipes-test/devtool/devtool-test-multisrc/mypackage-1.0.tar.gz
new file mode 100644
index 0000000000..b513b283e9
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-test-multisrc/mypackage-1.0.tar.gz
Binary files differ
diff --git a/meta-selftest/recipes-test/devtool/devtool-test-multisrc_1.0.bb b/meta-selftest/recipes-test/devtool/devtool-test-multisrc_1.0.bb
new file mode 100644
index 0000000000..2b81f83387
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-test-multisrc_1.0.bb
@@ -0,0 +1,11 @@
+SUMMARY = "Recipe to test multiple source trees"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+SRC_URI = "file://mypackage-${PV}.tar.gz \
+ file://example-files.tar.gz \
+ file://example.patch;patchdir=../example-files \
+"
+
+S = "${WORKDIR}/mypackage-${PV}"
+
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index 96072be189..b051b7c97b 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -1568,6 +1568,115 @@ class DevtoolTests(DevtoolBase):
if files:
self.fail('Unexpected file(s) copied next to bbappend: %s' % ', '.join(files))
+ def test_devtool_finish_modify_multisrc(self):
+ # Check preconditions
+ self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
+ # Try modifying a recipe
+ self.track_for_cleanup(self.workspacedir)
+ recipe = 'devtool-test-multisrc'
+ recipefile = get_bb_var('FILE', recipe)
+ recipedir = os.path.dirname(recipefile)
+ result = runCmd('git status --porcelain .', cwd=recipedir)
+ if result.output.strip():
+ self.fail('Recipe directory for %s contains uncommitted changes' % recipe)
+ tempdir = tempfile.mkdtemp(prefix='devtoolqa')
+ self.track_for_cleanup(tempdir)
+ self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+ result = runCmd('devtool modify %s %s' % (recipe, tempdir))
+ mainsrc = os.path.join(tempdir, 'mypackage-1.0')
+ extrasrc = os.path.join(tempdir, 'example-files')
+ self.assertExists(os.path.join(mainsrc, 'mainfile.c'), 'Extracted main source tree could not be found')
+ self.assertExists(os.path.join(extrasrc, 'test2'), 'Extracted extra source tree could not be found')
+ # Try dry-run finishing without changes
+ result = runCmd('devtool finish %s meta-selftest -N' % recipe)
+ self.assertIn('No patches or files need updating', result.output)
+ # Make some changes to both the main and extra source trees
+ with open(os.path.join(mainsrc, 'mainfile.c'), 'a') as f:
+ f.write('\n/* Additional comment */\n')
+ result = runCmd('git commit -a -m "Add a comment"', cwd=mainsrc)
+ with open(os.path.join(extrasrc, 'test2'), 'a') as f:
+ f.write('\nAnother line\n')
+ result = runCmd('git commit -a -m "Add another line"', cwd=extrasrc)
+ # Try finishing now with dry-run to see if it reports what we expect
+ result = runCmd('devtool finish %s meta-selftest -N' % recipe)
+ self.assertNotIn('No patches or files need updating', result.output)
+ self.assertIn('+ file://0001-Add-a-comment.patch \\', result.output)
+ self.assertIn('+ file://0001-Add-another-line.patch;patchdir=../example-files \\', result.output)
+ self.assertNotIn('Removing', result.output)
+ # Now really finish
+ self.add_command_to_tearDown('rm -rf %s ; cd %s ; git checkout %s' % (recipedir, os.path.dirname(recipedir), recipedir))
+ result = runCmd('devtool finish %s meta-selftest' % recipe)
+ expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)),
+ ('??', '.*/.*-Add-a-comment.patch$'),
+ ('??', '.*/.*-Add-another-line.patch$')]
+ self._check_repo_status(recipedir, expected_status)
+
+ def test_devtool_finish_modify_multisrc_subdir(self):
+ # Check preconditions
+ self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
+ # Try modifying a recipe
+ self.track_for_cleanup(self.workspacedir)
+ recipe = 'devtool-test-multisrc-subdir'
+ recipefile = get_bb_var('FILE', recipe)
+ recipedir = os.path.dirname(recipefile)
+ result = runCmd('git status --porcelain .', cwd=recipedir)
+ if result.output.strip():
+ self.fail('Recipe directory for %s contains uncommitted changes' % recipe)
+ tempdir = tempfile.mkdtemp(prefix='devtoolqa')
+ self.track_for_cleanup(tempdir)
+ self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+ result = runCmd('devtool modify %s %s' % (recipe, tempdir))
+ mainsrc = tempdir
+ extrasrc = os.path.join(tempdir, 'libfakekey')
+ self.assertExists(os.path.join(mainsrc, 'xsettings-client.c'), 'Extracted main source tree could not be found')
+ self.assertExists(os.path.join(extrasrc, 'configure.ac'), 'Extracted extra source tree could not be found')
+ # Try dry-run finishing without changes
+ result = runCmd('devtool finish %s meta-selftest -N' % recipe)
+ self.assertIn('No patches or files need updating', result.output)
+ # Make some changes to both the main and extra source trees
+ with open(os.path.join(mainsrc, 'xsettings-client.c'), 'a') as f:
+ f.write('\n/* Additional comment */\n')
+ result = runCmd('git commit -a -m "Add a comment"', cwd=mainsrc)
+ with open(os.path.join(extrasrc, 'README'), 'a') as f:
+ f.write('\nAnother line\n')
+ result = runCmd('git commit -a -m "Add another line to README"', cwd=extrasrc)
+ # Try finishing now with dry-run to see if it reports what we expect
+ # However, the first time it will fail because git treats sub-repositories
+ # the same as submodules, so the parent will appear to have uncommitted changes
+ failed = False
+ try:
+ result = runCmd('devtool finish %s meta-selftest -N' % recipe, assert_error=False)
+ except CommandError as err:
+ if err.retcode != 1:
+ self.fail('Unexpected failure from devtool finish:\n%s' % err.output)
+ lines = []
+ collecting = False
+ for line in err.output.splitlines():
+ if collecting:
+ if line:
+ lines.append(line)
+ elif line.startswith('ERROR: Source tree %s is not clean' % mainsrc):
+ collecting = True
+ lines = lines[:-1]
+ self.assertEqual(lines, [' M libfakekey'], 'Unexpected modifications to main source tree')
+ if not collecting:
+ self.fail('devtool finish did not report uncommitted changes as expected:\n%s' % err.output)
+ failed = True
+ if not failed:
+ self.fail('devtool finish was expected to fail but did not:\n%s' % result.output)
+ result = runCmd('devtool finish %s meta-selftest -N -f' % recipe)
+ self.assertNotIn('No patches or files need updating', result.output)
+ self.assertIn('+ file://0001-Add-a-comment.patch \\', result.output)
+ self.assertIn('+ file://0001-Add-another-line-to-README.patch;patchdir=libfakekey \\', result.output)
+ self.assertNotIn('Removing', result.output)
+ self.add_command_to_tearDown('rm -rf %s ; cd %s ; git checkout %s' % (recipedir, os.path.dirname(recipedir), recipedir))
+ result = runCmd('devtool finish %s -f meta-selftest' % recipe)
+ expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)),
+ ('??', '.*/%s/$' % recipe)]
+ self._check_repo_status(recipedir, expected_status)
+ self.assertExists(os.path.join(os.path.dirname(recipefile), recipe, '0001-Add-a-comment.patch'))
+ self.assertExists(os.path.join(os.path.dirname(recipefile), recipe, '0001-Add-another-line-to-README.patch'))
+
@OETestID(1626)
def test_devtool_rename(self):
# Check preconditions