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>
This commit is contained in:
Ross Burton
2017-01-17 23:55:46 +00:00
committed by Richard Purdie
parent 81c3d4824a
commit a304b94eae

View File

@@ -416,9 +416,8 @@ class DevtoolTests(DevtoolBase):
@testcase(1164) @testcase(1164)
def test_devtool_modify(self): def test_devtool_modify(self):
# Clean up anything in the workdir/sysroot/sstate cache import oe.path
bitbake('mdadm -c cleansstate')
# Try modifying a recipe
tempdir = tempfile.mkdtemp(prefix='devtoolqa') tempdir = tempfile.mkdtemp(prefix='devtoolqa')
self.track_for_cleanup(tempdir) self.track_for_cleanup(tempdir)
self.track_for_cleanup(self.workspacedir) self.track_for_cleanup(self.workspacedir)
@@ -429,66 +428,48 @@ class DevtoolTests(DevtoolBase):
self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created')
matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mdadm_*.bbappend')) matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mdadm_*.bbappend'))
self.assertTrue(matches, 'bbappend not created %s' % result.output) self.assertTrue(matches, 'bbappend not created %s' % result.output)
# Test devtool status # Test devtool status
result = runCmd('devtool status') result = runCmd('devtool status')
self.assertIn('mdadm', result.output) self.assertIn('mdadm', result.output)
self.assertIn(tempdir, result.output) self.assertIn(tempdir, result.output)
# Check git repo
self._check_src_repo(tempdir) self._check_src_repo(tempdir)
# Try building
def list_stamps(globsuffix='*'):
stampprefix = get_bb_var('STAMP', 'mdadm')
self.assertTrue(stampprefix, 'Unable to get STAMP value for recipe mdadm')
return glob.glob(stampprefix + globsuffix)
numstamps = len(list_stamps('.do_compile.*')) bitbake('mdadm -C unpack')
self.assertEqual(numstamps, 0, 'do_compile stamps before first build')
for x in range(10):
bitbake('mdadm')
nowstamps = len(list_stamps('.do_compile.*'))
if nowstamps == numstamps:
break
numstamps = nowstamps
else:
self.fail('build did not stabilize in 10 iterations')
# Try making (minor) modifications to the source def check_line(checkfile, expected, message, present=True):
modfile = os.path.join(tempdir, 'mdadm.8.in') # Check for $expected, on a line on its own, in checkfile.
result = runCmd("sed -i 's!^\.TH.*!.TH MDADM 8 \"\" v9.999-custom!' %s" % modfile)
def check_TH_line(checkfile, expected, message):
with open(checkfile, 'r') as f: with open(checkfile, 'r') as f:
for line in f: if present:
if line.startswith('.TH'): self.assertIn(expected + '\n', f, message)
self.assertEqual(line.rstrip(), expected, message) else:
self.assertNotIn(expected + '\n', f, message)
check_TH_line(modfile, '.TH MDADM 8 "" v9.999-custom', 'man .in file not modified (sed failed)') modfile = os.path.join(tempdir, 'mdadm.8.in')
bitbake('mdadm -c package')
pkgd = get_bb_var('PKGD', 'mdadm') pkgd = get_bb_var('PKGD', 'mdadm')
self.assertTrue(pkgd, 'Could not query PKGD variable') self.assertTrue(pkgd, 'Could not query PKGD variable')
mandir = get_bb_var('mandir', 'mdadm') mandir = get_bb_var('mandir', 'mdadm')
self.assertTrue(mandir, 'Could not query mandir variable') self.assertTrue(mandir, 'Could not query mandir variable')
if mandir[0] == '/': manfile = oe.path.join(pkgd, mandir, 'man8', 'mdadm.8')
mandir = mandir[1:]
manfile = os.path.join(pkgd, mandir, 'man8', 'mdadm.8') check_line(modfile, 'Linux Software RAID', 'Could not find initial string')
check_TH_line(manfile, '.TH MDADM 8 "" v9.999-custom', 'man file not modified. man searched file path: %s' % manfile) check_line(modfile, 'antique pin sardine', 'Unexpectedly found replacement string', present=False)
# Test reverting the change
result = runCmd("git -C %s checkout -- %s" % (tempdir, modfile)) result = runCmd("sed -i 's!^Linux Software RAID$!antique pin sardine!' %s" % modfile)
check_TH_line(modfile, '.TH MDADM 8 "" v3.4', 'man .in file not restored (git failed)') check_line(modfile, 'antique pin sardine', 'mdadm.8.in file not modified (sed failed)')
bitbake('mdadm -c package') bitbake('mdadm -c package')
pkgd = get_bb_var('PKGD', 'mdadm') check_line(manfile, 'antique pin sardine', 'man file not modified. man searched file path: %s' % manfile)
self.assertTrue(pkgd, 'Could not query PKGD variable')
mandir = get_bb_var('mandir', 'mdadm') result = runCmd('git -C %s checkout -- %s' % (tempdir, modfile))
self.assertTrue(mandir, 'Could not query mandir variable') check_line(modfile, 'Linux Software RAID', 'man .in file not restored (git failed)')
if mandir[0] == '/':
mandir = mandir[1:] bitbake('mdadm -c package')
manfile = os.path.join(pkgd, mandir, 'man8', 'mdadm.8') check_line(manfile, 'Linux Software RAID', 'man file not updated. man searched file path: %s' % manfile)
check_TH_line(manfile, '.TH MDADM 8 "" v3.4', 'man file not updated. man searched file path: %s' % manfile)
# Test devtool reset
result = runCmd('devtool reset mdadm') result = runCmd('devtool reset mdadm')
result = runCmd('devtool status') result = runCmd('devtool status')
self.assertNotIn('mdadm', result.output) self.assertNotIn('mdadm', result.output)
self.assertFalse(list_stamps(), 'Stamp files exist for recipe mdadm that should have been cleaned')
def test_devtool_buildclean(self): def test_devtool_buildclean(self):
def assertFile(path, *paths): def assertFile(path, *paths):