Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
| 5 | from oeqa.selftest.case import OESelftestTestCase |
| 6 | from oeqa.core.decorator import OETestTag |
| 7 | from oeqa.utils.commands import bitbake, runqemu |
| 8 | |
| 9 | class LocalesTest(OESelftestTestCase): |
| 10 | |
| 11 | @OETestTag("runqemu") |
| 12 | |
| 13 | def run_locales_test(self, binary_enabled): |
| 14 | features = [] |
| 15 | features.append('EXTRA_IMAGE_FEATURES = "empty-root-password allow-empty-password allow-root-login"') |
| 16 | features.append('IMAGE_INSTALL:append = " glibc-utils localedef"') |
| 17 | features.append('GLIBC_GENERATE_LOCALES = "en_US.UTF-8 fr_FR.UTF-8"') |
| 18 | features.append('IMAGE_LINGUAS:append = " en-us fr-fr"') |
| 19 | if binary_enabled: |
| 20 | features.append('ENABLE_BINARY_LOCALE_GENERATION = "1"') |
| 21 | else: |
| 22 | features.append('ENABLE_BINARY_LOCALE_GENERATION = "0"') |
| 23 | self.write_config("\n".join(features)) |
| 24 | |
| 25 | # Build a core-image-minimal |
| 26 | bitbake('core-image-minimal') |
| 27 | |
| 28 | with runqemu("core-image-minimal", ssh=False, runqemuparams='nographic') as qemu: |
| 29 | cmd = "locale -a" |
| 30 | status, output = qemu.run_serial(cmd) |
| 31 | # output must includes fr_FR or fr_FR.UTF-8 |
| 32 | self.assertEqual(status, 1, msg='locale test command failed: output: %s' % output) |
| 33 | self.assertIn("fr_FR", output, msg='locale -a test failed: output: %s' % output) |
| 34 | |
| 35 | cmd = "localedef --list-archive -v" |
| 36 | status, output = qemu.run_serial(cmd) |
| 37 | # output must includes fr_FR.utf8 |
| 38 | self.assertEqual(status, 1, msg='localedef test command failed: output: %s' % output) |
| 39 | self.assertIn("fr_FR.utf8", output, msg='localedef test failed: output: %s' % output) |
| 40 | |
| 41 | def test_locales_on(self): |
| 42 | """ |
| 43 | Summary: Test the locales are generated |
| 44 | Expected: 1. Check the locale exist in the locale-archive |
| 45 | 2. Check the locale exist for the glibc |
| 46 | 3. Check the locale can be generated |
| 47 | Product: oe-core |
| 48 | Author: Louis Rannou <lrannou@baylibre.com> |
| 49 | AutomatedBy: Louis Rannou <lrannou@baylibre.com> |
| 50 | """ |
| 51 | self.run_locales_test(True) |
| 52 | |
| 53 | def test_locales_off(self): |
| 54 | self.run_locales_test(False) |