summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-07-26 16:27:44 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-31 22:47:36 +0100
commitd9a9a2d80e648a9f0556f6e3eb3eea7ee65539ab (patch)
tree4a41d5355196ec22ec7bd01f418e4ece22bede49 /meta/lib
parentef6941fa56b078f45cc072be44c16d0e066a1e68 (diff)
downloadpoky-d9a9a2d80e648a9f0556f6e3eb3eea7ee65539ab.tar.gz
oe-selftest: devtool: avoid parallel races by using temporary copy of core
Some of the devtool tests make changes to files under meta/ - legitimately since we want these tests to be working with real recipes and associated files. Unfortunately with the new oe-selftest parallelisation this can break other tests if files go missing at the wrong time (among other scenarios). To avoid this issue, simply take a copy of the core repository and use that for these tests. (We copy the entire repository since changing the path of meta/ influences COREBASE and thus we need to have things like scripts/ alongside as well). (From OE-Core rev: 2457cd57b4195924ef127f497efa2f34f411e660) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/cases/devtool.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index 43a66c8e28..3c1189003d 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -11,6 +11,70 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer
11from oeqa.utils.commands import get_bb_vars, runqemu, get_test_layer 11from oeqa.utils.commands import get_bb_vars, runqemu, get_test_layer
12from oeqa.core.decorator.oeid import OETestID 12from oeqa.core.decorator.oeid import OETestID
13 13
14oldmetapath = None
15
16def setUpModule():
17 import bb.utils
18
19 global templayerdir
20 templayerdir = tempfile.mkdtemp(prefix='devtoolqa')
21 corecopydir = os.path.join(templayerdir, 'core-copy')
22 bblayers_conf = os.path.join(os.environ['BUILDDIR'], 'conf', 'bblayers.conf')
23 edited_layers = []
24
25 # We need to take a copy of the meta layer so we can modify it and not
26 # have any races against other tests that might be running in parallel
27 # however things like COREBASE mean that you can't just copy meta, you
28 # need the whole repository.
29 def bblayers_edit_cb(layerpath, canonical_layerpath):
30 global oldmetapath
31 if not canonical_layerpath.endswith('/'):
32 # This helps us match exactly when we're using this path later
33 canonical_layerpath += '/'
34 if not edited_layers and canonical_layerpath.endswith('/meta/'):
35 edited_layers.append(layerpath)
36 oldmetapath = layerpath
37 result = runCmd('git rev-parse --show-toplevel', cwd=canonical_layerpath)
38 oldreporoot = result.output.rstrip()
39 newmetapath = os.path.join(corecopydir, os.path.relpath(oldmetapath, oldreporoot))
40 runCmd('git clone %s %s' % (oldreporoot, corecopydir), cwd=templayerdir)
41 # Now we need to copy any modified files
42 # You might ask "why not just copy the entire tree instead of
43 # cloning and doing this?" - well, the problem with that is
44 # TMPDIR or an equally large subdirectory might exist
45 # under COREBASE and we don't want to copy that, so we have
46 # to be selective.
47 result = runCmd('git status --porcelain', cwd=oldreporoot)
48 for line in result.output.splitlines():
49 if line.startswith(' M ') or line.startswith('?? '):
50 relpth = line.split()[1]
51 pth = os.path.join(oldreporoot, relpth)
52 if pth.startswith(canonical_layerpath):
53 if relpth.endswith('/'):
54 destdir = os.path.join(corecopydir, relpth)
55 shutil.copytree(pth, destdir)
56 else:
57 destdir = os.path.join(corecopydir, os.path.dirname(relpth))
58 bb.utils.mkdirhier(destdir)
59 shutil.copy2(pth, destdir)
60 return newmetapath
61 else:
62 return layerpath
63 bb.utils.edit_bblayers_conf(bblayers_conf, None, None, bblayers_edit_cb)
64
65def tearDownModule():
66 if oldmetapath:
67 edited_layers = []
68 def bblayers_edit_cb(layerpath, canonical_layerpath):
69 if not edited_layers and canonical_layerpath.endswith('/meta'):
70 edited_layers.append(layerpath)
71 return oldmetapath
72 else:
73 return layerpath
74 bblayers_conf = os.path.join(os.environ['BUILDDIR'], 'conf', 'bblayers.conf')
75 bb.utils.edit_bblayers_conf(bblayers_conf, None, None, bblayers_edit_cb)
76 shutil.rmtree(templayerdir)
77
14class DevtoolBase(OESelftestTestCase): 78class DevtoolBase(OESelftestTestCase):
15 79
16 @classmethod 80 @classmethod