summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-selftest/recipes-test/multiconfig/multiconfig-test-parse.bb11
-rw-r--r--meta/lib/oeqa/selftest/case.py17
-rw-r--r--meta/lib/oeqa/selftest/cases/multiconfig.py45
3 files changed, 58 insertions, 15 deletions
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 0000000000..6236697453
--- /dev/null
+++ b/meta-selftest/recipes-test/multiconfig/multiconfig-test-parse.bb
@@ -0,0 +1,11 @@
1SUMMARY = "Test Multiconfig Parsing"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4
5INHIBIT_DEFAULT_DEPS = "1"
6
7do_showvar() {
8 bbplain "MCTESTVAR=${MCTESTVAR}"
9}
10addtask do_showvar
11
diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py
index d207a0af0c..ac3308d8a4 100644
--- a/meta/lib/oeqa/selftest/case.py
+++ b/meta/lib/oeqa/selftest/case.py
@@ -193,13 +193,20 @@ to ensure accurate results.")
193 self.logger.debug("Adding path '%s' to be cleaned up when test is over" % path) 193 self.logger.debug("Adding path '%s' to be cleaned up when test is over" % path)
194 self._track_for_cleanup.append(path) 194 self._track_for_cleanup.append(path)
195 195
196 def write_config(self, data): 196 def write_config(self, data, multiconfig=None):
197 """Write to <builddir>/conf/selftest.inc""" 197 """Write to config file"""
198 if multiconfig:
199 multiconfigdir = "%s/conf/multiconfig" % self.builddir
200 os.makedirs(multiconfigdir, exist_ok=True)
201 dest_path = '%s/%s.conf' % (multiconfigdir, multiconfig)
202 self.track_for_cleanup(dest_path)
203 else:
204 dest_path = self.testinc_path
198 205
199 self.logger.debug("Writing to: %s\n%s\n" % (self.testinc_path, data)) 206 self.logger.debug("Writing to: %s\n%s\n" % (dest_path, data))
200 ftools.write_file(self.testinc_path, data) 207 ftools.write_file(dest_path, data)
201 208
202 if self.tc.custommachine and 'MACHINE' in data: 209 if not multiconfig and self.tc.custommachine and 'MACHINE' in data:
203 machine = get_bb_var('MACHINE') 210 machine = get_bb_var('MACHINE')
204 self.logger.warning('MACHINE overridden: %s' % machine) 211 self.logger.warning('MACHINE overridden: %s' % machine)
205 212
diff --git a/meta/lib/oeqa/selftest/cases/multiconfig.py b/meta/lib/oeqa/selftest/cases/multiconfig.py
index d21bf0a411..39b92f2439 100644
--- a/meta/lib/oeqa/selftest/cases/multiconfig.py
+++ b/meta/lib/oeqa/selftest/cases/multiconfig.py
@@ -3,16 +3,16 @@
3# 3#
4 4
5import os 5import os
6import textwrap
6from oeqa.selftest.case import OESelftestTestCase 7from oeqa.selftest.case import OESelftestTestCase
7from oeqa.utils.commands import bitbake 8from oeqa.utils.commands import bitbake
8import oeqa.utils.ftools as ftools
9 9
10class MultiConfig(OESelftestTestCase): 10class MultiConfig(OESelftestTestCase):
11 11
12 def test_multiconfig(self): 12 def test_multiconfig(self):
13 """ 13 """
14 Test that a simple multiconfig build works. This uses the mcextend class and the 14 Test that a simple multiconfig build works. This uses the mcextend class and the
15 multiconfig-image-packager test recipe to build a core-image-full-cmdline image which 15 multiconfig-image-packager test recipe to build a core-image-full-cmdline image which
16 contains a tiny core-image-minimal and a musl core-image-minimal, installed as packages. 16 contains a tiny core-image-minimal and a musl core-image-minimal, installed as packages.
17 """ 17 """
18 18
@@ -28,20 +28,45 @@ DISTRO = "poky"
28TCLIBC = "musl" 28TCLIBC = "musl"
29TMPDIR = "${TOPDIR}/tmp-mc-musl" 29TMPDIR = "${TOPDIR}/tmp-mc-musl"
30""" 30"""
31 self.write_config(muslconfig, 'musl')
31 32
32 tinyconfig = """ 33 tinyconfig = """
33MACHINE = "qemux86" 34MACHINE = "qemux86"
34DISTRO = "poky-tiny" 35DISTRO = "poky-tiny"
35TMPDIR = "${TOPDIR}/tmp-mc-tiny" 36TMPDIR = "${TOPDIR}/tmp-mc-tiny"
36""" 37"""
37 38 self.write_config(tinyconfig, 'tiny')
38 multiconfigdir = self.builddir + "/conf/multiconfig"
39 os.makedirs(multiconfigdir, exist_ok=True)
40 self.track_for_cleanup(multiconfigdir + "/musl.conf")
41 ftools.write_file(multiconfigdir + "/musl.conf", muslconfig)
42 self.track_for_cleanup(multiconfigdir + "/tiny.conf")
43 ftools.write_file(multiconfigdir + "/tiny.conf", tinyconfig)
44 39
45 # Build a core-image-minimal 40 # Build a core-image-minimal
46 bitbake('core-image-full-cmdline') 41 bitbake('core-image-full-cmdline')
47 42
43 def test_multiconfig_reparse(self):
44 """
45 Test that changes to a multiconfig conf file are correctly detected and
46 cause a reparse/rebuild of a recipe.
47 """
48 config = textwrap.dedent('''\
49 MCTESTVAR = "test"
50 BBMULTICONFIG = "test"
51 ''')
52 self.write_config(config)
53
54 testconfig = textwrap.dedent('''\
55 MCTESTVAR_append = "1"
56 ''')
57 self.write_config(testconfig, 'test')
58
59 # Check that the 1) the task executed and 2) that it output the correct
60 # value. Note "bitbake -e" is not used because it always reparses the
61 # recipe and we want to ensure that the automatic reparsing and parse
62 # caching is detected.
63 result = bitbake('mc:test:multiconfig-test-parse -c showvar')
64 self.assertIn('MCTESTVAR=test1', result.output.splitlines())
65
66 testconfig = textwrap.dedent('''\
67 MCTESTVAR_append = "2"
68 ''')
69 self.write_config(testconfig, 'test')
70
71 result = bitbake('mc:test:multiconfig-test-parse -c showvar')
72 self.assertIn('MCTESTVAR=test2', result.output.splitlines())