Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core <openembedded-core@lists.openembedded.org>
Subject: [PATCH] oeqa: Add test for layer append and FILESPATH tracking
Date: Mon, 13 Apr 2015 17:03:42 +0100	[thread overview]
Message-ID: <1428941022.6976.77.camel@linuxfoundation.org> (raw)

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]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/meta/lib/oeqa/selftest/layerappend.py b/meta/lib/oeqa/selftest/layerappend.py
new file mode 100644
index 0000000..79b6137
--- /dev/null
+++ b/meta/lib/oeqa/selftest/layerappend.py
@@ -0,0 +1,95 @@
+import unittest
+import os
+import logging
+import re
+
+from oeqa.selftest.base import oeSelfTest
+from oeqa.selftest.buildhistory import BuildhistoryBase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var
+import oeqa.utils.ftools as ftools
+from oeqa.utils.decorators import testcase
+
+class LayerAppendTests(oeSelfTest):
+    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 = "BBLAYERS += \"COREBASE/meta-layertest0 COREBASE/meta-layertest1 COREBASE/meta-layertest2\""
+
+    def tearDownLocal(self):
+        ftools.remove_from_file(self.builddir + "/conf/bblayers.conf", self.layerappend.replace("COREBASE", self.builddir + "/.."))
+
+    def test_layer_appends(self):
+        corebase = get_bb_var("COREBASE")
+        stagingdir = get_bb_var("STAGING_DIR_TARGET")
+        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)
+        ftools.append_file(self.builddir + "/conf/bblayers.conf", self.layerappend.replace("COREBASE", self.builddir + "/.."))
+        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")
+
+




                 reply	other threads:[~2015-04-13 16:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428941022.6976.77.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox