blob: a82a6c8b9d31903d0e35042d32ba5e6e6eda28aa [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001import 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 @testcase(1196)
55 def test_layer_appends(self):
56 corebase = get_bb_var("COREBASE")
57 stagingdir = get_bb_var("STAGING_DIR_TARGET")
58 for l in ["0", "1", "2"]:
59 layer = os.path.join(corebase, "meta-layertest" + l)
60 self.assertFalse(os.path.exists(layer))
61 os.mkdir(layer)
62 os.mkdir(layer + "/conf")
63 with open(layer + "/conf/layer.conf", "w") as f:
64 f.write(self.layerconf.replace("INT", l))
65 os.mkdir(layer + "/recipes-test")
66 if l == "0":
67 with open(layer + "/recipes-test/layerappendtest.bb", "w") as f:
68 f.write(self.recipe)
69 elif l == "1":
70 with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f:
71 f.write(self.append)
72 os.mkdir(layer + "/recipes-test/layerappendtest")
73 with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f:
74 f.write("Layer 1 test")
75 elif l == "2":
76 with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f:
77 f.write(self.append2)
78 os.mkdir(layer + "/recipes-test/layerappendtest")
79 with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f:
80 f.write("Layer 2 test")
81 self.track_for_cleanup(layer)
82 ftools.append_file(self.builddir + "/conf/bblayers.conf", self.layerappend.replace("COREBASE", self.builddir + "/.."))
83 bitbake("layerappendtest")
84 data = ftools.read_file(stagingdir + "/appendtest.txt")
85 self.assertEqual(data, "Layer 2 test")
86 os.remove(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt")
87 bitbake("layerappendtest")
88 data = ftools.read_file(stagingdir + "/appendtest.txt")
89 self.assertEqual(data, "Layer 1 test")
90 with open(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt", "w") as f:
91 f.write("Layer 2 test")
92 bitbake("layerappendtest")
93 data = ftools.read_file(stagingdir + "/appendtest.txt")
94 self.assertEqual(data, "Layer 2 test")
95
96