summaryrefslogtreecommitdiffstats
path: root/meta
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>2019-02-25 22:27:46 +0000
commite5eadb501b93d7f5d571d952da0424e45bfb1889 (patch)
tree5a5614ee44c3a38e6c0e2533195b56ecb2e38aa8 /meta
parent5e376572d4edb3d0a54c09d3b709918b53ae6452 (diff)
downloadpoky-e5eadb501b93d7f5d571d952da0424e45bfb1889.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) (From OE-Core rev: 9cb8353a4f0137823d6ed3e467db9dd7ead7b3de) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-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 d5b6a46d49..3d77497fc4 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 buffer = True 80 buffer = True