summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-04-13 17:03:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-04-15 14:19:44 +0100
commit710b01e01e670c00b60587443d56025a4ba81c33 (patch)
tree4684b0989c8fd8b5badc7c09fe61762f273fe691 /meta/lib
parente9fcc570716e68a64f2a17c0e7aa79e1cd758f39 (diff)
downloadpoky-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.py95
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 @@
1import unittest
2import os
3import logging
4import re
5
6from oeqa.selftest.base import oeSelfTest
7from oeqa.selftest.buildhistory import BuildhistoryBase
8from oeqa.utils.commands import runCmd, bitbake, get_bb_var
9import oeqa.utils.ftools as ftools
10from oeqa.utils.decorators import testcase
11
12class LayerAppendTests(oeSelfTest):
13 layerconf = """
14# We have a conf and classes directory, append to BBPATH
15BBPATH .= ":${LAYERDIR}"
16
17# We have a recipes directory, add to BBFILES
18BBFILES += "${LAYERDIR}/recipes*/*.bb ${LAYERDIR}/recipes*/*.bbappend"
19
20BBFILE_COLLECTIONS += "meta-layerINT"
21BBFILE_PATTERN_meta-layerINT := "^${LAYERDIR}/"
22BBFILE_PRIORITY_meta-layerINT = "6"
23"""
24 recipe = """
25LICENSE="CLOSED"
26INHIBIT_DEFAULT_DEPS = "1"
27
28python do_build() {
29 bb.plain('Building ...')
30}
31addtask build
32"""
33 append = """
34FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
35
36SRC_URI_append = " file://appendtest.txt"
37
38sysroot_stage_all_append() {
39 install -m 644 ${WORKDIR}/appendtest.txt ${SYSROOT_DESTDIR}/
40}
41
42"""
43
44 append2 = """
45FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
46
47SRC_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