diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-04-13 17:03:42 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-04-15 14:19:44 +0100 |
commit | 710b01e01e670c00b60587443d56025a4ba81c33 (patch) | |
tree | 4684b0989c8fd8b5badc7c09fe61762f273fe691 /meta/lib | |
parent | e9fcc570716e68a64f2a17c0e7aa79e1cd758f39 (diff) | |
download | poky-710b01e01e670c00b60587443d56025a4ba81c33.tar.gz |
oeqa: Add test for layer append and FILESPATH tracking
This test actually tests a spectrum of bitbake functionality. Three
layers are created, one containing a recipe, one with a bbappend adding
a file to the recipe and another which overwrites the file in another
bbappend.
The correct outcomes in building the recipe are tested, with the file
in the final layer added, removed and then re-added.
This tests bitbake's cache handling as well as restoration from
sstate which happens in the final test phase.
Based on a test case from:
[YOCTO #7019]
(From OE-Core rev: e57437c0e02b148a878c8db91660674069fbd6e2)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/layerappend.py | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/layerappend.py b/meta/lib/oeqa/selftest/layerappend.py new file mode 100644 index 0000000000..79b6137cb0 --- /dev/null +++ b/meta/lib/oeqa/selftest/layerappend.py | |||
@@ -0,0 +1,95 @@ | |||
1 | import unittest | ||
2 | import os | ||
3 | import logging | ||
4 | import re | ||
5 | |||
6 | from oeqa.selftest.base import oeSelfTest | ||
7 | from oeqa.selftest.buildhistory import BuildhistoryBase | ||
8 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | ||
9 | import oeqa.utils.ftools as ftools | ||
10 | from oeqa.utils.decorators import testcase | ||
11 | |||
12 | class LayerAppendTests(oeSelfTest): | ||
13 | layerconf = """ | ||
14 | # We have a conf and classes directory, append to BBPATH | ||
15 | BBPATH .= ":${LAYERDIR}" | ||
16 | |||
17 | # We have a recipes directory, add to BBFILES | ||
18 | BBFILES += "${LAYERDIR}/recipes*/*.bb ${LAYERDIR}/recipes*/*.bbappend" | ||
19 | |||
20 | BBFILE_COLLECTIONS += "meta-layerINT" | ||
21 | BBFILE_PATTERN_meta-layerINT := "^${LAYERDIR}/" | ||
22 | BBFILE_PRIORITY_meta-layerINT = "6" | ||
23 | """ | ||
24 | recipe = """ | ||
25 | LICENSE="CLOSED" | ||
26 | INHIBIT_DEFAULT_DEPS = "1" | ||
27 | |||
28 | python do_build() { | ||
29 | bb.plain('Building ...') | ||
30 | } | ||
31 | addtask build | ||
32 | """ | ||
33 | append = """ | ||
34 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
35 | |||
36 | SRC_URI_append = " file://appendtest.txt" | ||
37 | |||
38 | sysroot_stage_all_append() { | ||
39 | install -m 644 ${WORKDIR}/appendtest.txt ${SYSROOT_DESTDIR}/ | ||
40 | } | ||
41 | |||
42 | """ | ||
43 | |||
44 | append2 = """ | ||
45 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
46 | |||
47 | SRC_URI_append += "file://appendtest.txt" | ||
48 | """ | ||
49 | layerappend = "BBLAYERS += \"COREBASE/meta-layertest0 COREBASE/meta-layertest1 COREBASE/meta-layertest2\"" | ||
50 | |||
51 | def tearDownLocal(self): | ||
52 | ftools.remove_from_file(self.builddir + "/conf/bblayers.conf", self.layerappend.replace("COREBASE", self.builddir + "/..")) | ||
53 | |||
54 | def test_layer_appends(self): | ||
55 | corebase = get_bb_var("COREBASE") | ||
56 | stagingdir = get_bb_var("STAGING_DIR_TARGET") | ||
57 | for l in ["0", "1", "2"]: | ||
58 | layer = os.path.join(corebase, "meta-layertest" + l) | ||
59 | self.assertFalse(os.path.exists(layer)) | ||
60 | os.mkdir(layer) | ||
61 | os.mkdir(layer + "/conf") | ||
62 | with open(layer + "/conf/layer.conf", "w") as f: | ||
63 | f.write(self.layerconf.replace("INT", l)) | ||
64 | os.mkdir(layer + "/recipes-test") | ||
65 | if l == "0": | ||
66 | with open(layer + "/recipes-test/layerappendtest.bb", "w") as f: | ||
67 | f.write(self.recipe) | ||
68 | elif l == "1": | ||
69 | with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f: | ||
70 | f.write(self.append) | ||
71 | os.mkdir(layer + "/recipes-test/layerappendtest") | ||
72 | with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f: | ||
73 | f.write("Layer 1 test") | ||
74 | elif l == "2": | ||
75 | with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f: | ||
76 | f.write(self.append2) | ||
77 | os.mkdir(layer + "/recipes-test/layerappendtest") | ||
78 | with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f: | ||
79 | f.write("Layer 2 test") | ||
80 | self.track_for_cleanup(layer) | ||
81 | ftools.append_file(self.builddir + "/conf/bblayers.conf", self.layerappend.replace("COREBASE", self.builddir + "/..")) | ||
82 | bitbake("layerappendtest") | ||
83 | data = ftools.read_file(stagingdir + "/appendtest.txt") | ||
84 | self.assertEqual(data, "Layer 2 test") | ||
85 | os.remove(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt") | ||
86 | bitbake("layerappendtest") | ||
87 | data = ftools.read_file(stagingdir + "/appendtest.txt") | ||
88 | self.assertEqual(data, "Layer 1 test") | ||
89 | with open(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt", "w") as f: | ||
90 | f.write("Layer 2 test") | ||
91 | bitbake("layerappendtest") | ||
92 | data = ftools.read_file(stagingdir + "/appendtest.txt") | ||
93 | self.assertEqual(data, "Layer 2 test") | ||
94 | |||
95 | |||