aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/layerappend.py
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2017-05-12 14:40:21 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-05 17:59:40 +0100
commitddbbefdd124604d10bd47dd0266b55a764fcc0ab (patch)
treebf787bf3a23a035b472a42c0b899758ded848c28 /meta/lib/oeqa/selftest/cases/layerappend.py
parent3b2a20eee4a39f40287bf67545839eaa09fc892d (diff)
downloadopenembedded-core-contrib-ddbbefdd124604d10bd47dd0266b55a764fcc0ab.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. Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/layerappend.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/layerappend.py95
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 @@
+import os
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var
+import oeqa.utils.ftools as ftools
+from oeqa.core.decorator.oeid import OETestID
+
+class LayerAppendTests(OESelftestTestCase):
+ layerconf = """
+# We have a conf and classes directory, append to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+# We have a recipes directory, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes*/*.bb ${LAYERDIR}/recipes*/*.bbappend"
+
+BBFILE_COLLECTIONS += "meta-layerINT"
+BBFILE_PATTERN_meta-layerINT := "^${LAYERDIR}/"
+BBFILE_PRIORITY_meta-layerINT = "6"
+"""
+ recipe = """
+LICENSE="CLOSED"
+INHIBIT_DEFAULT_DEPS = "1"
+
+python do_build() {
+ bb.plain('Building ...')
+}
+addtask build
+"""
+ append = """
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append = " file://appendtest.txt"
+
+sysroot_stage_all_append() {
+ install -m 644 ${WORKDIR}/appendtest.txt ${SYSROOT_DESTDIR}/
+}
+
+"""
+
+ append2 = """
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append += "file://appendtest.txt"
+"""
+ layerappend = ''
+
+ def tearDownLocal(self):
+ if self.layerappend:
+ ftools.remove_from_file(self.builddir + "/conf/bblayers.conf", self.layerappend)
+ super(LayerAppendTests, self).tearDownLocal()
+
+ @OETestID(1196)
+ def test_layer_appends(self):
+ corebase = get_bb_var("COREBASE")
+
+ for l in ["0", "1", "2"]:
+ layer = os.path.join(corebase, "meta-layertest" + l)
+ self.assertFalse(os.path.exists(layer))
+ os.mkdir(layer)
+ os.mkdir(layer + "/conf")
+ with open(layer + "/conf/layer.conf", "w") as f:
+ f.write(self.layerconf.replace("INT", l))
+ os.mkdir(layer + "/recipes-test")
+ if l == "0":
+ with open(layer + "/recipes-test/layerappendtest.bb", "w") as f:
+ f.write(self.recipe)
+ elif l == "1":
+ with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f:
+ f.write(self.append)
+ os.mkdir(layer + "/recipes-test/layerappendtest")
+ with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f:
+ f.write("Layer 1 test")
+ elif l == "2":
+ with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f:
+ f.write(self.append2)
+ os.mkdir(layer + "/recipes-test/layerappendtest")
+ with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f:
+ f.write("Layer 2 test")
+ self.track_for_cleanup(layer)
+
+ self.layerappend = "BBLAYERS += \"{0}/meta-layertest0 {0}/meta-layertest1 {0}/meta-layertest2\"".format(corebase)
+ ftools.append_file(self.builddir + "/conf/bblayers.conf", self.layerappend)
+ stagingdir = get_bb_var("SYSROOT_DESTDIR", "layerappendtest")
+ bitbake("layerappendtest")
+ data = ftools.read_file(stagingdir + "/appendtest.txt")
+ self.assertEqual(data, "Layer 2 test")
+ os.remove(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt")
+ bitbake("layerappendtest")
+ data = ftools.read_file(stagingdir + "/appendtest.txt")
+ self.assertEqual(data, "Layer 1 test")
+ with open(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt", "w") as f:
+ f.write("Layer 2 test")
+ bitbake("layerappendtest")
+ data = ftools.read_file(stagingdir + "/appendtest.txt")
+ self.assertEqual(data, "Layer 2 test")