xref: /openbmc/openbmc/poky/meta/lib/oeqa/selftest/cases/multiconfig.py (revision 92b42cb35d755f8cfe6c17d403711a536e0f0721)
1c342db35SBrad Bishop#
2*92b42cb3SPatrick Williams# Copyright OpenEmbedded Contributors
3*92b42cb3SPatrick Williams#
4c342db35SBrad Bishop# SPDX-License-Identifier: MIT
5c342db35SBrad Bishop#
6c342db35SBrad Bishop
719323693SBrad Bishopimport os
800e122a7SBrad Bishopimport textwrap
919323693SBrad Bishopfrom oeqa.selftest.case import OESelftestTestCase
1019323693SBrad Bishopfrom oeqa.utils.commands import bitbake
1119323693SBrad Bishop
1219323693SBrad Bishopclass MultiConfig(OESelftestTestCase):
1319323693SBrad Bishop
1419323693SBrad Bishop    def test_multiconfig(self):
1519323693SBrad Bishop        """
1619323693SBrad Bishop        Test that a simple multiconfig build works. This uses the mcextend class and the
1719323693SBrad Bishop        multiconfig-image-packager test recipe to build a core-image-full-cmdline image which
1819323693SBrad Bishop        contains a tiny core-image-minimal and a musl core-image-minimal, installed as packages.
1919323693SBrad Bishop        """
2019323693SBrad Bishop
2119323693SBrad Bishop        config = """
22213cb269SPatrick WilliamsIMAGE_INSTALL:append:pn-core-image-full-cmdline = " multiconfig-image-packager-tiny multiconfig-image-packager-musl"
2319323693SBrad BishopBBMULTICONFIG = "tiny musl"
2419323693SBrad Bishop"""
2519323693SBrad Bishop        self.write_config(config)
2619323693SBrad Bishop
2719323693SBrad Bishop        muslconfig = """
2819323693SBrad BishopMACHINE = "qemux86-64"
2919323693SBrad BishopDISTRO = "poky"
3019323693SBrad BishopTCLIBC = "musl"
3119323693SBrad BishopTMPDIR = "${TOPDIR}/tmp-mc-musl"
3219323693SBrad Bishop"""
3300e122a7SBrad Bishop        self.write_config(muslconfig, 'musl')
3419323693SBrad Bishop
3519323693SBrad Bishop        tinyconfig = """
3619323693SBrad BishopMACHINE = "qemux86"
3719323693SBrad BishopDISTRO = "poky-tiny"
3819323693SBrad BishopTMPDIR = "${TOPDIR}/tmp-mc-tiny"
3919323693SBrad Bishop"""
4000e122a7SBrad Bishop        self.write_config(tinyconfig, 'tiny')
4119323693SBrad Bishop
4219323693SBrad Bishop        # Build a core-image-minimal
4319323693SBrad Bishop        bitbake('core-image-full-cmdline')
4419323693SBrad Bishop
4500e122a7SBrad Bishop    def test_multiconfig_reparse(self):
4600e122a7SBrad Bishop        """
4700e122a7SBrad Bishop        Test that changes to a multiconfig conf file are correctly detected and
4800e122a7SBrad Bishop        cause a reparse/rebuild of a recipe.
4900e122a7SBrad Bishop        """
5000e122a7SBrad Bishop        config = textwrap.dedent('''\
5100e122a7SBrad Bishop                MCTESTVAR = "test"
5200e122a7SBrad Bishop                BBMULTICONFIG = "test"
5300e122a7SBrad Bishop                ''')
5400e122a7SBrad Bishop        self.write_config(config)
5500e122a7SBrad Bishop
5600e122a7SBrad Bishop        testconfig = textwrap.dedent('''\
57213cb269SPatrick Williams                MCTESTVAR:append = "1"
5800e122a7SBrad Bishop                ''')
5900e122a7SBrad Bishop        self.write_config(testconfig, 'test')
6000e122a7SBrad Bishop
6100e122a7SBrad Bishop        # Check that the 1) the task executed and 2) that it output the correct
6200e122a7SBrad Bishop        # value. Note "bitbake -e" is not used because it always reparses the
6300e122a7SBrad Bishop        # recipe and we want to ensure that the automatic reparsing and parse
6400e122a7SBrad Bishop        # caching is detected.
6500e122a7SBrad Bishop        result = bitbake('mc:test:multiconfig-test-parse -c showvar')
6600e122a7SBrad Bishop        self.assertIn('MCTESTVAR=test1', result.output.splitlines())
6700e122a7SBrad Bishop
6800e122a7SBrad Bishop        testconfig = textwrap.dedent('''\
69213cb269SPatrick Williams                MCTESTVAR:append = "2"
7000e122a7SBrad Bishop                ''')
7100e122a7SBrad Bishop        self.write_config(testconfig, 'test')
7200e122a7SBrad Bishop
7300e122a7SBrad Bishop        result = bitbake('mc:test:multiconfig-test-parse -c showvar')
7400e122a7SBrad Bishop        self.assertIn('MCTESTVAR=test2', result.output.splitlines())
7578b72798SAndrew Geissler
7678b72798SAndrew Geissler    def test_multiconfig_inlayer(self):
7778b72798SAndrew Geissler        """
7878b72798SAndrew Geissler        Test that a multiconfig from meta-selftest works.
7978b72798SAndrew Geissler        """
8078b72798SAndrew Geissler
8178b72798SAndrew Geissler        config = """
8278b72798SAndrew GeisslerBBMULTICONFIG = "muslmc"
8378b72798SAndrew Geissler"""
8478b72798SAndrew Geissler        self.write_config(config)
8578b72798SAndrew Geissler
8678b72798SAndrew Geissler        # Build a core-image-minimal, only dry run needed to check config is present
8778b72798SAndrew Geissler        bitbake('mc:muslmc:bash -n')
88