summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2017-01-17 23:55:46 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-19 22:47:22 +0000
commita304b94eae99ade6d99800eeaf588c48d01506f6 (patch)
tree4a829c054e133092164ee7b7b2291114b21b8057
parent81c3d4824af983029e9621fbdb377f4cf9aabb5a (diff)
downloadpoky-a304b94eae99ade6d99800eeaf588c48d01506f6.tar.gz
oeqa/selftest/devtool: rewrite modify testcase
The modify testcase had to be updated as it started failing when mdadm was upgraded due to hardcoding version numbers in the test. I then noticed how inefficient the test was and mostly rewrote it. Start by changing the minor modification to change "Linux Software RAID" (the subtitle of the man page) to "antique pin sardine" (a nonsense phrase that is unlikely to appear upstream), and neaten the logic. Start by not removing sstate at the beginning of the test. To ensure builds happen we can use -f and -C, and iterating the sstate cache is time consuming. Don't bitbake mdadm repeatedly until it stabilizes, we can start with bitbake -C unpack to ensure that a full build is done from scratch. os.path.join has the interesting quirk that join(/foo, /bar) results in /bar, so use oe.path.join instead of working around that manually. Don't repeatedly call get_bb_var(), each call results in a call to bitbake. These changes reduce the runtime of the test from over 600 seconds to around 160 seconds on my machine. (From OE-Core rev: fc97963bc61bf16112859fe1d7e460a13d34baca) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/devtool.py73
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):