barebox.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Qemu-based barebox bootloader integration testing
  2. #
  3. # Copyright OpenEmbedded Contributors
  4. #
  5. # SPDX-License-Identifier: MIT
  6. #
  7. from oeqa.selftest.case import OESelftestTestCase
  8. from oeqa.utils.commands import bitbake, runqemu
  9. from oeqa.core.decorator.data import skipIfNotArch
  10. from oeqa.core.decorator import OETestTag
  11. barebox_boot_patterns = {
  12. 'search_reached_prompt': r"stop autoboot",
  13. 'search_login_succeeded': r"barebox@[^:]+:[^ ]+ ",
  14. 'search_cmd_finished': r"barebox@[a-zA-Z0-9\-\s]+:/"
  15. }
  16. class BareboxTest(OESelftestTestCase):
  17. @skipIfNotArch(['arm', 'aarch64'])
  18. @OETestTag("runqemu")
  19. def test_boot_barebox(self):
  20. """
  21. Tests building barebox and booting it with QEMU
  22. """
  23. self.write_config("""
  24. QB_DEFAULT_KERNEL = "barebox-dt-2nd.img"
  25. PREFERRED_PROVIDER_virtual/bootloader = "barebox"
  26. QEMU_USE_KVM = "False"
  27. """)
  28. bitbake("virtual/bootloader core-image-minimal")
  29. with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic',
  30. boot_patterns=barebox_boot_patterns) as qemu:
  31. # test if barebox console works
  32. cmd = "version"
  33. status, output = qemu.run_serial(cmd)
  34. self.assertEqual(status, 1, msg=output)
  35. self.assertTrue("barebox" in output, msg=output)