diff options
author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2017-05-12 14:40:21 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-06 19:02:43 +0100 |
commit | 157c3be2ca93f076033f725ec1ee912df91f7488 (patch) | |
tree | 8ef896ff7adf78d63b34059cd5b017a4f0a3419a /meta/lib/oeqa/selftest/cases/layerappend.py | |
parent | 10c512b60d1167122b5fe778b93838dca3def717 (diff) | |
download | poky-157c3be2ca93f076033f725ec1ee912df91f7488.tar.gz |
oeqa/selftest/cases: Migrate test cases into the new oe-qa framework
New framework has different classes/decorators so adapt current test cases to
support these. Changes include changes on base classes and decorators.
Also include paths in selftest/__init__.py isn't needed because the
loader is the standard unittest one.
(From OE-Core rev: ddbbefdd124604d10bd47dd0266b55a764fcc0ab)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/layerappend.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/layerappend.py | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/layerappend.py b/meta/lib/oeqa/selftest/cases/layerappend.py new file mode 100644 index 0000000000..9562116309 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/layerappend.py | |||
@@ -0,0 +1,95 @@ | |||
1 | import os | ||
2 | |||
3 | from oeqa.selftest.case import OESelftestTestCase | ||
4 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | ||
5 | import oeqa.utils.ftools as ftools | ||
6 | from oeqa.core.decorator.oeid import OETestID | ||
7 | |||
8 | class LayerAppendTests(OESelftestTestCase): | ||
9 | layerconf = """ | ||
10 | # We have a conf and classes directory, append to BBPATH | ||
11 | BBPATH .= ":${LAYERDIR}" | ||
12 | |||
13 | # We have a recipes directory, add to BBFILES | ||
14 | BBFILES += "${LAYERDIR}/recipes*/*.bb ${LAYERDIR}/recipes*/*.bbappend" | ||
15 | |||
16 | BBFILE_COLLECTIONS += "meta-layerINT" | ||
17 | BBFILE_PATTERN_meta-layerINT := "^${LAYERDIR}/" | ||
18 | BBFILE_PRIORITY_meta-layerINT = "6" | ||
19 | """ | ||
20 | recipe = """ | ||
21 | LICENSE="CLOSED" | ||
22 | INHIBIT_DEFAULT_DEPS = "1" | ||
23 | |||
24 | python do_build() { | ||
25 | bb.plain('Building ...') | ||
26 | } | ||
27 | addtask build | ||
28 | """ | ||
29 | append = """ | ||
30 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
31 | |||
32 | SRC_URI_append = " file://appendtest.txt" | ||
33 | |||
34 | sysroot_stage_all_append() { | ||
35 | install -m 644 ${WORKDIR}/appendtest.txt ${SYSROOT_DESTDIR}/ | ||
36 | } | ||
37 | |||
38 | """ | ||
39 | |||
40 | append2 = """ | ||
41 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
42 | |||
43 | SRC_URI_append += "file://appendtest.txt" | ||
44 | """ | ||
45 | layerappend = '' | ||
46 | |||
47 | def tearDownLocal(self): | ||
48 | if self.layerappend: | ||
49 | ftools.remove_from_file(self.builddir + "/conf/bblayers.conf", self.layerappend) | ||
50 | super(LayerAppendTests, self).tearDownLocal() | ||
51 | |||
52 | @OETestID(1196) | ||
53 | def test_layer_appends(self): | ||
54 | corebase = get_bb_var("COREBASE") | ||
55 | |||
56 | for l in ["0", "1", "2"]: | ||
57 | layer = os.path.join(corebase, "meta-layertest" + l) | ||
58 | self.assertFalse(os.path.exists(layer)) | ||
59 | os.mkdir(layer) | ||
60 | os.mkdir(layer + "/conf") | ||
61 | with open(layer + "/conf/layer.conf", "w") as f: | ||
62 | f.write(self.layerconf.replace("INT", l)) | ||
63 | os.mkdir(layer + "/recipes-test") | ||
64 | if l == "0": | ||
65 | with open(layer + "/recipes-test/layerappendtest.bb", "w") as f: | ||
66 | f.write(self.recipe) | ||
67 | elif l == "1": | ||
68 | with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f: | ||
69 | f.write(self.append) | ||
70 | os.mkdir(layer + "/recipes-test/layerappendtest") | ||
71 | with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f: | ||
72 | f.write("Layer 1 test") | ||
73 | elif l == "2": | ||
74 | with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f: | ||
75 | f.write(self.append2) | ||
76 | os.mkdir(layer + "/recipes-test/layerappendtest") | ||
77 | with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f: | ||
78 | f.write("Layer 2 test") | ||
79 | self.track_for_cleanup(layer) | ||
80 | |||
81 | self.layerappend = "BBLAYERS += \"{0}/meta-layertest0 {0}/meta-layertest1 {0}/meta-layertest2\"".format(corebase) | ||
82 | ftools.append_file(self.builddir + "/conf/bblayers.conf", self.layerappend) | ||
83 | stagingdir = get_bb_var("SYSROOT_DESTDIR", "layerappendtest") | ||
84 | bitbake("layerappendtest") | ||
85 | data = ftools.read_file(stagingdir + "/appendtest.txt") | ||
86 | self.assertEqual(data, "Layer 2 test") | ||
87 | os.remove(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt") | ||
88 | bitbake("layerappendtest") | ||
89 | data = ftools.read_file(stagingdir + "/appendtest.txt") | ||
90 | self.assertEqual(data, "Layer 1 test") | ||
91 | with open(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt", "w") as f: | ||
92 | f.write("Layer 2 test") | ||
93 | bitbake("layerappendtest") | ||
94 | data = ftools.read_file(stagingdir + "/appendtest.txt") | ||
95 | self.assertEqual(data, "Layer 2 test") | ||