locales.py 2.2 KB

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