diff options
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 | |||