All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] oeqa/selftest/locales: Create selftest for locales generation
@ 2023-01-27 15:33 lrannou
  2023-02-01 13:49 ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 8+ messages in thread
From: lrannou @ 2023-01-27 15:33 UTC (permalink / raw)
  To: openembedded-core; +Cc: Louis Rannou

From: Louis Rannou <lrannou@baylibre.com>

[YOCTO #9070]

Add a new selftest to validate the locales generation. This selftest builds a
complete target with GLIBC_GENERATE_LOCALES, IMAGE_LINGUAS,
ENABLE_BINARY_LOCALE_GENERATION set.

The tests has two cases: GLIBC_GENERATE_LOCALES=1 and
GLIBC_GENERATE_LOCALES=0. When set to 1, we check that the locales exist in the
local-archive and if it does exist for the glibc. When set to 0, we check it
does not.

Signed-off-by: Louis Rannou <lrannou@baylibre.com>
---
 meta/lib/oeqa/selftest/cases/locales.py | 81 +++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/locales.py

diff --git a/meta/lib/oeqa/selftest/cases/locales.py b/meta/lib/oeqa/selftest/cases/locales.py
new file mode 100644
index 0000000000..f053cc8e31
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/locales.py
@@ -0,0 +1,81 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.core.decorator import OETestTag
+from oeqa.utils.commands import bitbake, runqemu
+
+class LocalesTest(OESelftestTestCase):
+
+    @OETestTag("runqemu")
+    def test_locales_on(self):
+        """
+        Summary: Test the locales are generated
+        Expected: 1. Check the locale exist in the locale-archive
+                  2. Check the locale exist for the glibc
+                  3. Check the locale can be generated
+        Product: oe-core
+        Author: Louis Rannou <lrannou@baylibre.com>
+        AutomatedBy: Louis Rannou <lrannou@baylibre.com>
+        """
+
+        features = []
+        features.append('EXTRA_IMAGE_FEATURES = "empty-root-password allow-empty-password allow-root-login"')
+        features.append('IMAGE_INSTALL:append = " glibc-utils localedef"')
+        features.append('GLIBC_GENERATE_LOCALES = "en_US.UTF-8 fr_FR.UTF-8"')
+        features.append('IMAGE_LINGUAS:append = " en-us fr-fr"')
+        features.append('ENABLE_BINARY_LOCALE_GENERATION = "1"')
+        self.write_config("\n".join(features))
+
+        # Build a core-image-minimal
+        bitbake('core-image-minimal')
+
+        with runqemu("core-image-minimal", ssh=False, runqemuparams='nographic') as qemu:
+            cmd = "locale -a"
+            status, output = qemu.run_serial(cmd)
+            # output must includes fr_FR or fr_FR.UTF-8
+            self.assertEqual(status, 1, msg='localedef test failed: output: %s' % output)
+            self.assertIn("fr_FR", output, msg='locale -a test failed: output: %s' % output)
+
+            cmd = "localedef --list-archive -v"
+            status, output = qemu.run_serial(cmd)
+            # output must includes fr_FR.utf8
+            self.assertEqual(status, 1, msg='localedef test failed: output: %s' % output)
+            self.assertIn("fr_FR.utf8", output, msg='locale -a test failed: output: %s' % output)
+
+    @OETestTag("runqemu")
+    def test_locales_off(self):
+        """
+        Summary: Test the locales are not generated
+        Expected: 1. Check the locale does not exist in the locale-archive
+                  2. Check the locale does not exist for the glibc
+                  3. Check the locale cannot be generated
+        Product: oe-core
+        Author: Louis Rannou <lrannou@baylibre.com>
+        AutomatedBy: Louis Rannou <lrannou@baylibre.com>
+        """
+
+        features = []
+        features.append('EXTRA_IMAGE_FEATURES = "empty-root-password allow-empty-password allow-root-login"')
+        features.append('IMAGE_INSTALL:append = " glibc-utils localedef"')
+        features.append('GLIBC_GENERATE_LOCALES = "en_US.UTF-8 fr_FR.UTF-8"')
+        features.append('IMAGE_LINGUAS:append = " en-us fr-fr"')
+        features.append('ENABLE_BINARY_LOCALE_GENERATION = "0"')
+        self.write_config("\n".join(features))
+
+        # Build a core-image-minimal
+        bitbake('core-image-minimal')
+
+        with runqemu("core-image-minimal", ssh=False, runqemuparams='nographic') as qemu:
+            cmd = "locale -a"
+            status, output = qemu.run_serial(cmd)
+            # output must not includes fr_FR or fr_FR.UTF-8
+            self.assertEqual(status, 1, msg='localedef test failed: output: %s' % output)
+            self.assertNotIn("fr_FR", output, msg='locale -a test failed: output: %s' % output)
+
+            cmd = "localedef --list-archive -v"
+            status, output = qemu.run_serial(cmd)
+            # output must not includes fr_FR.utf8
+            self.assertEqual(status, 1, msg='localedef test failed: output: %s' % output)
+            self.assertNotIn("fr_FR.utf8", output, msg='locale -a test failed: output: %s' % output)
-- 
2.39.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-02-03 16:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 15:33 [PATCH v2] oeqa/selftest/locales: Create selftest for locales generation lrannou
2023-02-01 13:49 ` [OE-core] " Richard Purdie
2023-02-01 15:02   ` Louis Rannou
2023-02-01 17:57     ` Richard Purdie
2023-02-02 10:41       ` Louis Rannou
2023-02-02 10:53         ` Richard Purdie
2023-02-02 13:58           ` Louis Rannou
2023-02-03 16:33             ` Louis Rannou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.