xref: /OK3568_Linux_fs/yocto/poky/meta/lib/oeqa/selftest/cases/multiconfig.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#
2# SPDX-License-Identifier: MIT
3#
4
5import os
6import textwrap
7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import bitbake
9
10class MultiConfig(OESelftestTestCase):
11
12    def test_multiconfig(self):
13        """
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
16        contains a tiny core-image-minimal and a musl core-image-minimal, installed as packages.
17        """
18
19        config = """
20IMAGE_INSTALL:append:pn-core-image-full-cmdline = " multiconfig-image-packager-tiny multiconfig-image-packager-musl"
21BBMULTICONFIG = "tiny musl"
22"""
23        self.write_config(config)
24
25        muslconfig = """
26MACHINE = "qemux86-64"
27DISTRO = "poky"
28TCLIBC = "musl"
29TMPDIR = "${TOPDIR}/tmp-mc-musl"
30"""
31        self.write_config(muslconfig, 'musl')
32
33        tinyconfig = """
34MACHINE = "qemux86"
35DISTRO = "poky-tiny"
36TMPDIR = "${TOPDIR}/tmp-mc-tiny"
37"""
38        self.write_config(tinyconfig, 'tiny')
39
40        # Build a core-image-minimal
41        bitbake('core-image-full-cmdline')
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())
73
74    def test_multiconfig_inlayer(self):
75        """
76        Test that a multiconfig from meta-selftest works.
77        """
78
79        config = """
80BBMULTICONFIG = "muslmc"
81"""
82        self.write_config(config)
83
84        # Build a core-image-minimal, only dry run needed to check config is present
85        bitbake('mc:muslmc:bash -n')
86