xref: /OK3568_Linux_fs/yocto/poky/meta/lib/oeqa/selftest/cases/locales.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun# SPDX-License-Identifier: MIT
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun
5*4882a593Smuzhiyunfrom oeqa.selftest.case import OESelftestTestCase
6*4882a593Smuzhiyunfrom oeqa.core.decorator import OETestTag
7*4882a593Smuzhiyunfrom oeqa.utils.commands import bitbake, runqemu
8*4882a593Smuzhiyun
9*4882a593Smuzhiyunclass LocalesTest(OESelftestTestCase):
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun    @OETestTag("runqemu")
12*4882a593Smuzhiyun    def test_locales_on(self):
13*4882a593Smuzhiyun        """
14*4882a593Smuzhiyun        Summary: Test the locales are generated
15*4882a593Smuzhiyun        Expected: 1. Check the locale exist in the locale-archive
16*4882a593Smuzhiyun                  2. Check the locale exist for the glibc
17*4882a593Smuzhiyun                  3. Check the locale can be generated
18*4882a593Smuzhiyun        Product: oe-core
19*4882a593Smuzhiyun        Author: Louis Rannou <lrannou@baylibre.com>
20*4882a593Smuzhiyun        AutomatedBy: Louis Rannou <lrannou@baylibre.com>
21*4882a593Smuzhiyun        """
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun        features = []
24*4882a593Smuzhiyun        features.append('EXTRA_IMAGE_FEATURES = "empty-root-password allow-empty-password allow-root-login"')
25*4882a593Smuzhiyun        features.append('IMAGE_INSTALL:append = " glibc-utils localedef"')
26*4882a593Smuzhiyun        features.append('GLIBC_GENERATE_LOCALES = "en_US.UTF-8 fr_FR.UTF-8"')
27*4882a593Smuzhiyun        features.append('IMAGE_LINGUAS:append = " en-us fr-fr"')
28*4882a593Smuzhiyun        features.append('ENABLE_BINARY_LOCALE_GENERATION = "1"')
29*4882a593Smuzhiyun        self.write_config("\n".join(features))
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun        # Build a core-image-minimal
32*4882a593Smuzhiyun        bitbake('core-image-minimal')
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun        with runqemu("core-image-minimal", ssh=False, runqemuparams='nographic') as qemu:
35*4882a593Smuzhiyun            cmd = "locale -a"
36*4882a593Smuzhiyun            status, output = qemu.run_serial(cmd)
37*4882a593Smuzhiyun            # output must includes fr_FR or fr_FR.UTF-8
38*4882a593Smuzhiyun            self.assertEqual(status, 1, msg='locale test command failed: output: %s' % output)
39*4882a593Smuzhiyun            self.assertIn("fr_FR", output, msg='locale -a test failed: output: %s' % output)
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun            cmd = "localedef --list-archive -v"
42*4882a593Smuzhiyun            status, output = qemu.run_serial(cmd)
43*4882a593Smuzhiyun            # output must includes fr_FR.utf8
44*4882a593Smuzhiyun            self.assertEqual(status, 1, msg='localedef test command failed: output: %s' % output)
45*4882a593Smuzhiyun            self.assertIn("fr_FR.utf8", output, msg='localedef test failed: output: %s' % output)
46