xref: /OK3568_Linux_fs/yocto/poky/meta/lib/oeqa/selftest/cases/multiconfig.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun# SPDX-License-Identifier: MIT
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun
5*4882a593Smuzhiyunimport os
6*4882a593Smuzhiyunimport textwrap
7*4882a593Smuzhiyunfrom oeqa.selftest.case import OESelftestTestCase
8*4882a593Smuzhiyunfrom oeqa.utils.commands import bitbake
9*4882a593Smuzhiyun
10*4882a593Smuzhiyunclass MultiConfig(OESelftestTestCase):
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun    def test_multiconfig(self):
13*4882a593Smuzhiyun        """
14*4882a593Smuzhiyun        Test that a simple multiconfig build works. This uses the mcextend class and the
15*4882a593Smuzhiyun        multiconfig-image-packager test recipe to build a core-image-full-cmdline image which
16*4882a593Smuzhiyun        contains a tiny core-image-minimal and a musl core-image-minimal, installed as packages.
17*4882a593Smuzhiyun        """
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun        config = """
20*4882a593SmuzhiyunIMAGE_INSTALL:append:pn-core-image-full-cmdline = " multiconfig-image-packager-tiny multiconfig-image-packager-musl"
21*4882a593SmuzhiyunBBMULTICONFIG = "tiny musl"
22*4882a593Smuzhiyun"""
23*4882a593Smuzhiyun        self.write_config(config)
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun        muslconfig = """
26*4882a593SmuzhiyunMACHINE = "qemux86-64"
27*4882a593SmuzhiyunDISTRO = "poky"
28*4882a593SmuzhiyunTCLIBC = "musl"
29*4882a593SmuzhiyunTMPDIR = "${TOPDIR}/tmp-mc-musl"
30*4882a593Smuzhiyun"""
31*4882a593Smuzhiyun        self.write_config(muslconfig, 'musl')
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun        tinyconfig = """
34*4882a593SmuzhiyunMACHINE = "qemux86"
35*4882a593SmuzhiyunDISTRO = "poky-tiny"
36*4882a593SmuzhiyunTMPDIR = "${TOPDIR}/tmp-mc-tiny"
37*4882a593Smuzhiyun"""
38*4882a593Smuzhiyun        self.write_config(tinyconfig, 'tiny')
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun        # Build a core-image-minimal
41*4882a593Smuzhiyun        bitbake('core-image-full-cmdline')
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun    def test_multiconfig_reparse(self):
44*4882a593Smuzhiyun        """
45*4882a593Smuzhiyun        Test that changes to a multiconfig conf file are correctly detected and
46*4882a593Smuzhiyun        cause a reparse/rebuild of a recipe.
47*4882a593Smuzhiyun        """
48*4882a593Smuzhiyun        config = textwrap.dedent('''\
49*4882a593Smuzhiyun                MCTESTVAR = "test"
50*4882a593Smuzhiyun                BBMULTICONFIG = "test"
51*4882a593Smuzhiyun                ''')
52*4882a593Smuzhiyun        self.write_config(config)
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun        testconfig = textwrap.dedent('''\
55*4882a593Smuzhiyun                MCTESTVAR:append = "1"
56*4882a593Smuzhiyun                ''')
57*4882a593Smuzhiyun        self.write_config(testconfig, 'test')
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun        # Check that the 1) the task executed and 2) that it output the correct
60*4882a593Smuzhiyun        # value. Note "bitbake -e" is not used because it always reparses the
61*4882a593Smuzhiyun        # recipe and we want to ensure that the automatic reparsing and parse
62*4882a593Smuzhiyun        # caching is detected.
63*4882a593Smuzhiyun        result = bitbake('mc:test:multiconfig-test-parse -c showvar')
64*4882a593Smuzhiyun        self.assertIn('MCTESTVAR=test1', result.output.splitlines())
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun        testconfig = textwrap.dedent('''\
67*4882a593Smuzhiyun                MCTESTVAR:append = "2"
68*4882a593Smuzhiyun                ''')
69*4882a593Smuzhiyun        self.write_config(testconfig, 'test')
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun        result = bitbake('mc:test:multiconfig-test-parse -c showvar')
72*4882a593Smuzhiyun        self.assertIn('MCTESTVAR=test2', result.output.splitlines())
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun    def test_multiconfig_inlayer(self):
75*4882a593Smuzhiyun        """
76*4882a593Smuzhiyun        Test that a multiconfig from meta-selftest works.
77*4882a593Smuzhiyun        """
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun        config = """
80*4882a593SmuzhiyunBBMULTICONFIG = "muslmc"
81*4882a593Smuzhiyun"""
82*4882a593Smuzhiyun        self.write_config(config)
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun        # Build a core-image-minimal, only dry run needed to check config is present
85*4882a593Smuzhiyun        bitbake('mc:muslmc:bash -n')
86