blob: f509cbf607f1609d232640eb2cead791b040354c [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishop19323692019-04-05 15:28:33 -04007import os
Brad Bishop00e122a2019-10-05 11:10:57 -04008import textwrap
Brad Bishop19323692019-04-05 15:28:33 -04009from oeqa.selftest.case import OESelftestTestCase
10from oeqa.utils.commands import bitbake
Brad Bishop19323692019-04-05 15:28:33 -040011
12class MultiConfig(OESelftestTestCase):
13
14 def test_multiconfig(self):
15 """
Brad Bishop00e122a2019-10-05 11:10:57 -040016 Test that a simple multiconfig build works. This uses the mcextend class and the
17 multiconfig-image-packager test recipe to build a core-image-full-cmdline image which
Brad Bishop19323692019-04-05 15:28:33 -040018 contains a tiny core-image-minimal and a musl core-image-minimal, installed as packages.
19 """
20
21 config = """
Patrick Williams213cb262021-08-07 19:21:33 -050022IMAGE_INSTALL:append:pn-core-image-full-cmdline = " multiconfig-image-packager-tiny multiconfig-image-packager-musl"
Brad Bishop19323692019-04-05 15:28:33 -040023BBMULTICONFIG = "tiny musl"
24"""
25 self.write_config(config)
26
27 muslconfig = """
28MACHINE = "qemux86-64"
29DISTRO = "poky"
30TCLIBC = "musl"
31TMPDIR = "${TOPDIR}/tmp-mc-musl"
32"""
Brad Bishop00e122a2019-10-05 11:10:57 -040033 self.write_config(muslconfig, 'musl')
Brad Bishop19323692019-04-05 15:28:33 -040034
35 tinyconfig = """
36MACHINE = "qemux86"
37DISTRO = "poky-tiny"
38TMPDIR = "${TOPDIR}/tmp-mc-tiny"
39"""
Brad Bishop00e122a2019-10-05 11:10:57 -040040 self.write_config(tinyconfig, 'tiny')
Brad Bishop19323692019-04-05 15:28:33 -040041
42 # Build a core-image-minimal
43 bitbake('core-image-full-cmdline')
44
Brad Bishop00e122a2019-10-05 11:10:57 -040045 def test_multiconfig_reparse(self):
46 """
47 Test that changes to a multiconfig conf file are correctly detected and
48 cause a reparse/rebuild of a recipe.
49 """
50 config = textwrap.dedent('''\
51 MCTESTVAR = "test"
52 BBMULTICONFIG = "test"
53 ''')
54 self.write_config(config)
55
56 testconfig = textwrap.dedent('''\
Patrick Williams213cb262021-08-07 19:21:33 -050057 MCTESTVAR:append = "1"
Brad Bishop00e122a2019-10-05 11:10:57 -040058 ''')
59 self.write_config(testconfig, 'test')
60
61 # Check that the 1) the task executed and 2) that it output the correct
62 # value. Note "bitbake -e" is not used because it always reparses the
63 # recipe and we want to ensure that the automatic reparsing and parse
64 # caching is detected.
65 result = bitbake('mc:test:multiconfig-test-parse -c showvar')
66 self.assertIn('MCTESTVAR=test1', result.output.splitlines())
67
68 testconfig = textwrap.dedent('''\
Patrick Williams213cb262021-08-07 19:21:33 -050069 MCTESTVAR:append = "2"
Brad Bishop00e122a2019-10-05 11:10:57 -040070 ''')
71 self.write_config(testconfig, 'test')
72
73 result = bitbake('mc:test:multiconfig-test-parse -c showvar')
74 self.assertIn('MCTESTVAR=test2', result.output.splitlines())
Andrew Geissler78b72792022-06-14 06:47:25 -050075
76 def test_multiconfig_inlayer(self):
77 """
78 Test that a multiconfig from meta-selftest works.
79 """
80
81 config = """
82BBMULTICONFIG = "muslmc"
83"""
84 self.write_config(config)
85
86 # Build a core-image-minimal, only dry run needed to check config is present
87 bitbake('mc:muslmc:bash -n')