Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Joshua Watt <jpewhacker@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] oeqa: Test multiconfig parsing
Date: Mon, 23 Sep 2019 13:21:37 -0500	[thread overview]
Message-ID: <20190923182137.30292-1-JPEWhacker@gmail.com> (raw)

Add a test to verify that when multiconfig conf files changed, recipes
are correctly reparsed.

[YOCTO #13541]

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 .../multiconfig/multiconfig-test-parse.bb     | 11 +++++
 meta/lib/oeqa/selftest/case.py                | 17 ++++---
 meta/lib/oeqa/selftest/cases/multiconfig.py   | 45 ++++++++++++++-----
 3 files changed, 58 insertions(+), 15 deletions(-)
 create mode 100644 meta-selftest/recipes-test/multiconfig/multiconfig-test-parse.bb

diff --git a/meta-selftest/recipes-test/multiconfig/multiconfig-test-parse.bb b/meta-selftest/recipes-test/multiconfig/multiconfig-test-parse.bb
new file mode 100644
index 00000000000..6236697453f
--- /dev/null
+++ b/meta-selftest/recipes-test/multiconfig/multiconfig-test-parse.bb
@@ -0,0 +1,11 @@
+SUMMARY = "Test Multiconfig Parsing"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+do_showvar() {
+    bbplain "MCTESTVAR=${MCTESTVAR}"
+}
+addtask do_showvar
+
diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py
index d207a0af0c0..ac3308d8a44 100644
--- a/meta/lib/oeqa/selftest/case.py
+++ b/meta/lib/oeqa/selftest/case.py
@@ -193,13 +193,20 @@ to ensure accurate results.")
         self.logger.debug("Adding path '%s' to be cleaned up when test is over" % path)
         self._track_for_cleanup.append(path)
 
-    def write_config(self, data):
-        """Write to <builddir>/conf/selftest.inc"""
+    def write_config(self, data, multiconfig=None):
+        """Write to config file"""
+        if multiconfig:
+            multiconfigdir = "%s/conf/multiconfig" % self.builddir
+            os.makedirs(multiconfigdir, exist_ok=True)
+            dest_path = '%s/%s.conf' % (multiconfigdir, multiconfig)
+            self.track_for_cleanup(dest_path)
+        else:
+            dest_path = self.testinc_path
 
-        self.logger.debug("Writing to: %s\n%s\n" % (self.testinc_path, data))
-        ftools.write_file(self.testinc_path, data)
+        self.logger.debug("Writing to: %s\n%s\n" % (dest_path, data))
+        ftools.write_file(dest_path, data)
 
-        if self.tc.custommachine and 'MACHINE' in data:
+        if not multiconfig and self.tc.custommachine and 'MACHINE' in data:
             machine = get_bb_var('MACHINE')
             self.logger.warning('MACHINE overridden: %s' % machine)
 
diff --git a/meta/lib/oeqa/selftest/cases/multiconfig.py b/meta/lib/oeqa/selftest/cases/multiconfig.py
index d21bf0a4110..39b92f24391 100644
--- a/meta/lib/oeqa/selftest/cases/multiconfig.py
+++ b/meta/lib/oeqa/selftest/cases/multiconfig.py
@@ -3,16 +3,16 @@
 #
 
 import os
+import textwrap
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.utils.commands import bitbake
-import oeqa.utils.ftools as ftools
 
 class MultiConfig(OESelftestTestCase):
 
     def test_multiconfig(self):
         """
-        Test that a simple multiconfig build works. This uses the mcextend class and the 
-        multiconfig-image-packager test recipe to build a core-image-full-cmdline image which 
+        Test that a simple multiconfig build works. This uses the mcextend class and the
+        multiconfig-image-packager test recipe to build a core-image-full-cmdline image which
         contains a tiny core-image-minimal and a musl core-image-minimal, installed as packages.
         """
 
@@ -28,20 +28,45 @@ DISTRO = "poky"
 TCLIBC = "musl"
 TMPDIR = "${TOPDIR}/tmp-mc-musl"
 """
+        self.write_config(muslconfig, 'musl')
 
         tinyconfig = """
 MACHINE = "qemux86"
 DISTRO = "poky-tiny"
 TMPDIR = "${TOPDIR}/tmp-mc-tiny"
 """
-
-        multiconfigdir = self.builddir + "/conf/multiconfig"
-        os.makedirs(multiconfigdir, exist_ok=True)
-        self.track_for_cleanup(multiconfigdir + "/musl.conf")
-        ftools.write_file(multiconfigdir + "/musl.conf", muslconfig)
-        self.track_for_cleanup(multiconfigdir + "/tiny.conf")
-        ftools.write_file(multiconfigdir + "/tiny.conf", tinyconfig)
+        self.write_config(tinyconfig, 'tiny')
 
         # Build a core-image-minimal
         bitbake('core-image-full-cmdline')
 
+    def test_multiconfig_reparse(self):
+        """
+        Test that changes to a multiconfig conf file are correctly detected and
+        cause a reparse/rebuild of a recipe.
+        """
+        config = textwrap.dedent('''\
+                MCTESTVAR = "test"
+                BBMULTICONFIG = "test"
+                ''')
+        self.write_config(config)
+
+        testconfig = textwrap.dedent('''\
+                MCTESTVAR_append = "1"
+                ''')
+        self.write_config(testconfig, 'test')
+
+        # Check that the 1) the task executed and 2) that it output the correct
+        # value. Note "bitbake -e" is not used because it always reparses the
+        # recipe and we want to ensure that the automatic reparsing and parse
+        # caching is detected.
+        result = bitbake('mc:test:multiconfig-test-parse -c showvar')
+        self.assertIn('MCTESTVAR=test1', result.output.splitlines())
+
+        testconfig = textwrap.dedent('''\
+                MCTESTVAR_append = "2"
+                ''')
+        self.write_config(testconfig, 'test')
+
+        result = bitbake('mc:test:multiconfig-test-parse -c showvar')
+        self.assertIn('MCTESTVAR=test2', result.output.splitlines())
-- 
2.21.0



                 reply	other threads:[~2019-09-23 18:21 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=20190923182137.30292-1-JPEWhacker@gmail.com \
    --to=jpewhacker@gmail.com \
    --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