diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/devtool.py | 64 |
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 | |||
11 | from oeqa.utils.commands import get_bb_vars, runqemu, get_test_layer | 11 | from oeqa.utils.commands import get_bb_vars, runqemu, get_test_layer |
12 | from oeqa.core.decorator.oeid import OETestID | 12 | from oeqa.core.decorator.oeid import OETestID |
13 | 13 | ||
14 | oldmetapath = None | ||
15 | |||
16 | def 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 | |||
65 | def 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 | |||
14 | class DevtoolBase(OESelftestTestCase): | 78 | class DevtoolBase(OESelftestTestCase): |
15 | 79 | ||
16 | @classmethod | 80 | @classmethod |