diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2015-05-29 16:35:41 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-01 07:43:31 +0100 |
commit | 0a9f59e8d2b742322ed90986cdeff7587e40a7d1 (patch) | |
tree | 59c481740a3071fd3ff14696416cbd9fddd7186c /meta | |
parent | afb01421e2a93f3fa1e67236e49d6ea3f22e925e (diff) | |
download | poky-0a9f59e8d2b742322ed90986cdeff7587e40a7d1.tar.gz |
oe-selftest: devtool: add method for checking srctree repo
Removes some code duplication.
(From OE-Core rev: 5bd2ca137a496e34bb62cfafd406db8ae78635d6)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 23aa85a498..0df96e794c 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py | |||
@@ -92,6 +92,17 @@ class DevtoolTests(DevtoolBase): | |||
92 | 'This test cannot be run with a workspace directory ' | 92 | 'This test cannot be run with a workspace directory ' |
93 | 'under the build directory') | 93 | 'under the build directory') |
94 | 94 | ||
95 | def _check_src_repo(self, repo_dir): | ||
96 | """Check srctree git repository""" | ||
97 | self.assertTrue(os.path.isdir(os.path.join(repo_dir, '.git')), | ||
98 | 'git repository for external source tree not found') | ||
99 | result = runCmd('git status --porcelain', cwd=repo_dir) | ||
100 | self.assertEqual(result.output.strip(), "", | ||
101 | 'Created git repo is not clean') | ||
102 | result = runCmd('git symbolic-ref HEAD', cwd=repo_dir) | ||
103 | self.assertEqual(result.output.strip(), "refs/heads/devtool", | ||
104 | 'Wrong branch in git repo') | ||
105 | |||
95 | @testcase(1158) | 106 | @testcase(1158) |
96 | def test_create_workspace(self): | 107 | def test_create_workspace(self): |
97 | # Check preconditions | 108 | # Check preconditions |
@@ -288,7 +299,6 @@ class DevtoolTests(DevtoolBase): | |||
288 | self.add_command_to_tearDown('bitbake -c clean mdadm') | 299 | self.add_command_to_tearDown('bitbake -c clean mdadm') |
289 | result = runCmd('devtool modify mdadm -x %s' % tempdir) | 300 | result = runCmd('devtool modify mdadm -x %s' % tempdir) |
290 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile')), 'Extracted source could not be found') | 301 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile')), 'Extracted source could not be found') |
291 | self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found') | ||
292 | self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') | 302 | self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') |
293 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mdadm_*.bbappend')) | 303 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mdadm_*.bbappend')) |
294 | self.assertTrue(matches, 'bbappend not created %s' % result.output) | 304 | self.assertTrue(matches, 'bbappend not created %s' % result.output) |
@@ -297,10 +307,7 @@ class DevtoolTests(DevtoolBase): | |||
297 | self.assertIn('mdadm', result.output) | 307 | self.assertIn('mdadm', result.output) |
298 | self.assertIn(tempdir, result.output) | 308 | self.assertIn(tempdir, result.output) |
299 | # Check git repo | 309 | # Check git repo |
300 | result = runCmd('git status --porcelain', cwd=tempdir) | 310 | self._check_src_repo(tempdir) |
301 | self.assertEqual(result.output.strip(), "", 'Created git repo is not clean') | ||
302 | result = runCmd('git symbolic-ref HEAD', cwd=tempdir) | ||
303 | self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo') | ||
304 | # Try building | 311 | # Try building |
305 | bitbake('mdadm') | 312 | bitbake('mdadm') |
306 | # Try making (minor) modifications to the source | 313 | # Try making (minor) modifications to the source |
@@ -400,7 +407,6 @@ class DevtoolTests(DevtoolBase): | |||
400 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) | 407 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) |
401 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 408 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
402 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile')), 'Extracted source could not be found') | 409 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile')), 'Extracted source could not be found') |
403 | self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found') | ||
404 | self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created. devtool output: %s' % result.output) | 410 | self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created. devtool output: %s' % result.output) |
405 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mkelfimage_*.bbappend')) | 411 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mkelfimage_*.bbappend')) |
406 | self.assertTrue(matches, 'bbappend not created') | 412 | self.assertTrue(matches, 'bbappend not created') |
@@ -409,10 +415,7 @@ class DevtoolTests(DevtoolBase): | |||
409 | self.assertIn(testrecipe, result.output) | 415 | self.assertIn(testrecipe, result.output) |
410 | self.assertIn(tempdir, result.output) | 416 | self.assertIn(tempdir, result.output) |
411 | # Check git repo | 417 | # Check git repo |
412 | result = runCmd('git status --porcelain', cwd=tempdir) | 418 | self._check_src_repo(tempdir) |
413 | self.assertEqual(result.output.strip(), "", 'Created git repo is not clean') | ||
414 | result = runCmd('git symbolic-ref HEAD', cwd=tempdir) | ||
415 | self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo') | ||
416 | # Try building | 419 | # Try building |
417 | bitbake(testrecipe) | 420 | bitbake(testrecipe) |
418 | 421 | ||
@@ -464,11 +467,7 @@ class DevtoolTests(DevtoolBase): | |||
464 | # (don't bother with cleaning the recipe on teardown, we won't be building it) | 467 | # (don't bother with cleaning the recipe on teardown, we won't be building it) |
465 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 468 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
466 | # Check git repo | 469 | # Check git repo |
467 | self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found') | 470 | self._check_src_repo(tempdir) |
468 | result = runCmd('git status --porcelain', cwd=tempdir) | ||
469 | self.assertEqual(result.output.strip(), "", 'Created git repo is not clean') | ||
470 | result = runCmd('git symbolic-ref HEAD', cwd=tempdir) | ||
471 | self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo') | ||
472 | # Add a couple of commits | 471 | # Add a couple of commits |
473 | # FIXME: this only tests adding, need to also test update and remove | 472 | # FIXME: this only tests adding, need to also test update and remove |
474 | result = runCmd('echo "Additional line" >> README', cwd=tempdir) | 473 | result = runCmd('echo "Additional line" >> README', cwd=tempdir) |
@@ -514,11 +513,7 @@ class DevtoolTests(DevtoolBase): | |||
514 | # (don't bother with cleaning the recipe on teardown, we won't be building it) | 513 | # (don't bother with cleaning the recipe on teardown, we won't be building it) |
515 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 514 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
516 | # Check git repo | 515 | # Check git repo |
517 | self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found') | 516 | self._check_src_repo(tempdir) |
518 | result = runCmd('git status --porcelain', cwd=tempdir) | ||
519 | self.assertEqual(result.output.strip(), "", 'Created git repo is not clean') | ||
520 | result = runCmd('git symbolic-ref HEAD', cwd=tempdir) | ||
521 | self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo') | ||
522 | # Add a couple of commits | 517 | # Add a couple of commits |
523 | # FIXME: this only tests adding, need to also test update and remove | 518 | # FIXME: this only tests adding, need to also test update and remove |
524 | result = runCmd('echo "# Additional line" >> Makefile', cwd=tempdir) | 519 | result = runCmd('echo "# Additional line" >> Makefile', cwd=tempdir) |
@@ -604,11 +599,7 @@ class DevtoolTests(DevtoolBase): | |||
604 | # (don't bother with cleaning the recipe on teardown, we won't be building it) | 599 | # (don't bother with cleaning the recipe on teardown, we won't be building it) |
605 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempsrcdir)) | 600 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempsrcdir)) |
606 | # Check git repo | 601 | # Check git repo |
607 | self.assertTrue(os.path.isdir(os.path.join(tempsrcdir, '.git')), 'git repository for external source tree not found') | 602 | self._check_src_repo(tempsrcdir) |
608 | result = runCmd('git status --porcelain', cwd=tempsrcdir) | ||
609 | self.assertEqual(result.output.strip(), "", 'Created git repo is not clean') | ||
610 | result = runCmd('git symbolic-ref HEAD', cwd=tempsrcdir) | ||
611 | self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo') | ||
612 | # Add a commit | 603 | # Add a commit |
613 | result = runCmd("sed 's!\\(#define VERSION\\W*\"[^\"]*\\)\"!\\1-custom\"!' -i ReadMe.c", cwd=tempsrcdir) | 604 | result = runCmd("sed 's!\\(#define VERSION\\W*\"[^\"]*\\)\"!\\1-custom\"!' -i ReadMe.c", cwd=tempsrcdir) |
614 | result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) | 605 | result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) |
@@ -682,11 +673,7 @@ class DevtoolTests(DevtoolBase): | |||
682 | # (don't bother with cleaning the recipe on teardown, we won't be building it) | 673 | # (don't bother with cleaning the recipe on teardown, we won't be building it) |
683 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempsrcdir)) | 674 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempsrcdir)) |
684 | # Check git repo | 675 | # Check git repo |
685 | self.assertTrue(os.path.isdir(os.path.join(tempsrcdir, '.git')), 'git repository for external source tree not found') | 676 | self._check_src_repo(tempsrcdir) |
686 | result = runCmd('git status --porcelain', cwd=tempsrcdir) | ||
687 | self.assertEqual(result.output.strip(), "", 'Created git repo is not clean') | ||
688 | result = runCmd('git symbolic-ref HEAD', cwd=tempsrcdir) | ||
689 | self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo') | ||
690 | # Add a commit | 677 | # Add a commit |
691 | result = runCmd('echo "# Additional line" >> Makefile', cwd=tempsrcdir) | 678 | result = runCmd('echo "# Additional line" >> Makefile', cwd=tempsrcdir) |
692 | result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) | 679 | result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) |
@@ -763,7 +750,7 @@ class DevtoolTests(DevtoolBase): | |||
763 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | 750 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') |
764 | result = runCmd('devtool extract remake %s' % tempdir) | 751 | result = runCmd('devtool extract remake %s' % tempdir) |
765 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') | 752 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') |
766 | self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found') | 753 | self._check_src_repo(tempdir) |
767 | 754 | ||
768 | @testcase(1168) | 755 | @testcase(1168) |
769 | def test_devtool_reset_all(self): | 756 | def test_devtool_reset_all(self): |