master
py 31 lines 1.06 KB
Raw
1 #!/usr/bin/env python3
2 #
3 # SPDX-License-Identifier: GPL-2.0-or-later
4 #
5 # Copyright 2025, The QEMU Project Developers.
6 #
7 # A functional test that runs MicroPython on the arm microbit machine.
8
9 from qemu_test import QemuSystemTest, Asset, exec_command_and_wait_for_pattern
10 from qemu_test import wait_for_console_pattern
11
12
13 class MicrobitMachine(QemuSystemTest):
14
15 ASSET_MICRO = Asset('https://ozlabs.org/~joel/microbit-micropython.hex',
16 '021641f93dfb11767d4978dbb3ca7f475d1b13c69e7f4aec3382f212636bffd6')
17
18 def test_arm_microbit(self):
19 self.set_machine('microbit')
20
21 micropython = self.ASSET_MICRO.fetch()
22 self.vm.set_console()
23 self.vm.add_args('-device', f'loader,file={micropython}')
24 self.vm.launch()
25 wait_for_console_pattern(self, 'Type "help()" for more information.')
26 exec_command_and_wait_for_pattern(self, 'import machine as mch', '>>>')
27 exec_command_and_wait_for_pattern(self, 'mch.reset()', 'MicroPython')
28 wait_for_console_pattern(self, '>>>')
29
30 if __name__ == '__main__':
31 QemuSystemTest.main()