diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/devtool.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 73 |
1 files changed, 27 insertions, 46 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 94b6b393c8..887c1e6b4c 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py | |||
| @@ -416,9 +416,8 @@ class DevtoolTests(DevtoolBase): | |||
| 416 | 416 | ||
| 417 | @testcase(1164) | 417 | @testcase(1164) |
| 418 | def test_devtool_modify(self): | 418 | def test_devtool_modify(self): |
| 419 | # Clean up anything in the workdir/sysroot/sstate cache | 419 | import oe.path |
| 420 | bitbake('mdadm -c cleansstate') | 420 | |
| 421 | # Try modifying a recipe | ||
| 422 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | 421 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') |
| 423 | self.track_for_cleanup(tempdir) | 422 | self.track_for_cleanup(tempdir) |
| 424 | self.track_for_cleanup(self.workspacedir) | 423 | self.track_for_cleanup(self.workspacedir) |
| @@ -429,66 +428,48 @@ class DevtoolTests(DevtoolBase): | |||
| 429 | self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') | 428 | self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') |
| 430 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mdadm_*.bbappend')) | 429 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mdadm_*.bbappend')) |
| 431 | self.assertTrue(matches, 'bbappend not created %s' % result.output) | 430 | self.assertTrue(matches, 'bbappend not created %s' % result.output) |
| 431 | |||
| 432 | # Test devtool status | 432 | # Test devtool status |
| 433 | result = runCmd('devtool status') | 433 | result = runCmd('devtool status') |
| 434 | self.assertIn('mdadm', result.output) | 434 | self.assertIn('mdadm', result.output) |
| 435 | self.assertIn(tempdir, result.output) | 435 | self.assertIn(tempdir, result.output) |
| 436 | # Check git repo | ||
| 437 | self._check_src_repo(tempdir) | 436 | self._check_src_repo(tempdir) |
| 438 | # Try building | ||
| 439 | def list_stamps(globsuffix='*'): | ||
| 440 | stampprefix = get_bb_var('STAMP', 'mdadm') | ||
| 441 | self.assertTrue(stampprefix, 'Unable to get STAMP value for recipe mdadm') | ||
| 442 | return glob.glob(stampprefix + globsuffix) | ||
| 443 | |||
| 444 | numstamps = len(list_stamps('.do_compile.*')) | ||
| 445 | self.assertEqual(numstamps, 0, 'do_compile stamps before first build') | ||
| 446 | for x in range(10): | ||
| 447 | bitbake('mdadm') | ||
| 448 | nowstamps = len(list_stamps('.do_compile.*')) | ||
| 449 | if nowstamps == numstamps: | ||
| 450 | break | ||
| 451 | numstamps = nowstamps | ||
| 452 | else: | ||
| 453 | self.fail('build did not stabilize in 10 iterations') | ||
| 454 | 437 | ||
| 455 | # Try making (minor) modifications to the source | 438 | bitbake('mdadm -C unpack') |
| 456 | modfile = os.path.join(tempdir, 'mdadm.8.in') | ||
| 457 | result = runCmd("sed -i 's!^\.TH.*!.TH MDADM 8 \"\" v9.999-custom!' %s" % modfile) | ||
| 458 | 439 | ||
| 459 | def check_TH_line(checkfile, expected, message): | 440 | def check_line(checkfile, expected, message, present=True): |
| 441 | # Check for $expected, on a line on its own, in checkfile. | ||
| 460 | with open(checkfile, 'r') as f: | 442 | with open(checkfile, 'r') as f: |
| 461 | for line in f: | 443 | if present: |
| 462 | if line.startswith('.TH'): | 444 | self.assertIn(expected + '\n', f, message) |
| 463 | self.assertEqual(line.rstrip(), expected, message) | 445 | else: |
| 446 | self.assertNotIn(expected + '\n', f, message) | ||
| 464 | 447 | ||
| 465 | check_TH_line(modfile, '.TH MDADM 8 "" v9.999-custom', 'man .in file not modified (sed failed)') | 448 | modfile = os.path.join(tempdir, 'mdadm.8.in') |
| 466 | bitbake('mdadm -c package') | ||
| 467 | pkgd = get_bb_var('PKGD', 'mdadm') | 449 | pkgd = get_bb_var('PKGD', 'mdadm') |
| 468 | self.assertTrue(pkgd, 'Could not query PKGD variable') | 450 | self.assertTrue(pkgd, 'Could not query PKGD variable') |
| 469 | mandir = get_bb_var('mandir', 'mdadm') | 451 | mandir = get_bb_var('mandir', 'mdadm') |
| 470 | self.assertTrue(mandir, 'Could not query mandir variable') | 452 | self.assertTrue(mandir, 'Could not query mandir variable') |
| 471 | if mandir[0] == '/': | 453 | manfile = oe.path.join(pkgd, mandir, 'man8', 'mdadm.8') |
| 472 | mandir = mandir[1:] | 454 | |
| 473 | manfile = os.path.join(pkgd, mandir, 'man8', 'mdadm.8') | 455 | check_line(modfile, 'Linux Software RAID', 'Could not find initial string') |
| 474 | check_TH_line(manfile, '.TH MDADM 8 "" v9.999-custom', 'man file not modified. man searched file path: %s' % manfile) | 456 | check_line(modfile, 'antique pin sardine', 'Unexpectedly found replacement string', present=False) |
| 475 | # Test reverting the change | 457 | |
| 476 | result = runCmd("git -C %s checkout -- %s" % (tempdir, modfile)) | 458 | result = runCmd("sed -i 's!^Linux Software RAID$!antique pin sardine!' %s" % modfile) |
| 477 | check_TH_line(modfile, '.TH MDADM 8 "" v3.4', 'man .in file not restored (git failed)') | 459 | check_line(modfile, 'antique pin sardine', 'mdadm.8.in file not modified (sed failed)') |
| 460 | |||
| 478 | bitbake('mdadm -c package') | 461 | bitbake('mdadm -c package') |
| 479 | pkgd = get_bb_var('PKGD', 'mdadm') | 462 | check_line(manfile, 'antique pin sardine', 'man file not modified. man searched file path: %s' % manfile) |
| 480 | self.assertTrue(pkgd, 'Could not query PKGD variable') | 463 | |
| 481 | mandir = get_bb_var('mandir', 'mdadm') | 464 | result = runCmd('git -C %s checkout -- %s' % (tempdir, modfile)) |
| 482 | self.assertTrue(mandir, 'Could not query mandir variable') | 465 | check_line(modfile, 'Linux Software RAID', 'man .in file not restored (git failed)') |
| 483 | if mandir[0] == '/': | 466 | |
| 484 | mandir = mandir[1:] | 467 | bitbake('mdadm -c package') |
| 485 | manfile = os.path.join(pkgd, mandir, 'man8', 'mdadm.8') | 468 | check_line(manfile, 'Linux Software RAID', 'man file not updated. man searched file path: %s' % manfile) |
| 486 | check_TH_line(manfile, '.TH MDADM 8 "" v3.4', 'man file not updated. man searched file path: %s' % manfile) | 469 | |
| 487 | # Test devtool reset | ||
| 488 | result = runCmd('devtool reset mdadm') | 470 | result = runCmd('devtool reset mdadm') |
| 489 | result = runCmd('devtool status') | 471 | result = runCmd('devtool status') |
| 490 | self.assertNotIn('mdadm', result.output) | 472 | self.assertNotIn('mdadm', result.output) |
| 491 | self.assertFalse(list_stamps(), 'Stamp files exist for recipe mdadm that should have been cleaned') | ||
| 492 | 473 | ||
| 493 | def test_devtool_buildclean(self): | 474 | def test_devtool_buildclean(self): |
| 494 | def assertFile(path, *paths): | 475 | def assertFile(path, *paths): |
