Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 7 | import os |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 8 | import textwrap |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 9 | from oeqa.selftest.case import OESelftestTestCase |
| 10 | from oeqa.utils.commands import bitbake |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 11 | |
| 12 | class MultiConfig(OESelftestTestCase): |
| 13 | |
| 14 | def test_multiconfig(self): |
| 15 | """ |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 16 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 18 | contains a tiny core-image-minimal and a musl core-image-minimal, installed as packages. |
| 19 | """ |
| 20 | |
| 21 | config = """ |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 22 | IMAGE_INSTALL:append:pn-core-image-full-cmdline = " multiconfig-image-packager-tiny multiconfig-image-packager-musl" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 23 | BBMULTICONFIG = "tiny musl" |
| 24 | """ |
| 25 | self.write_config(config) |
| 26 | |
| 27 | muslconfig = """ |
| 28 | MACHINE = "qemux86-64" |
| 29 | DISTRO = "poky" |
| 30 | TCLIBC = "musl" |
| 31 | TMPDIR = "${TOPDIR}/tmp-mc-musl" |
| 32 | """ |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 33 | self.write_config(muslconfig, 'musl') |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 34 | |
| 35 | tinyconfig = """ |
| 36 | MACHINE = "qemux86" |
| 37 | DISTRO = "poky-tiny" |
| 38 | TMPDIR = "${TOPDIR}/tmp-mc-tiny" |
| 39 | """ |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 40 | self.write_config(tinyconfig, 'tiny') |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 41 | |
| 42 | # Build a core-image-minimal |
| 43 | bitbake('core-image-full-cmdline') |
| 44 | |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 45 | 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 57 | MCTESTVAR:append = "1" |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 58 | ''') |
| 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 69 | MCTESTVAR:append = "2" |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 70 | ''') |
| 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 Geissler | 78b7279 | 2022-06-14 06:47:25 -0500 | [diff] [blame] | 75 | |
| 76 | def test_multiconfig_inlayer(self): |
| 77 | """ |
| 78 | Test that a multiconfig from meta-selftest works. |
| 79 | """ |
| 80 | |
| 81 | config = """ |
| 82 | BBMULTICONFIG = "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') |