xref: /qemu/tests/functional/test_microblaze_s3adsp1800.py (revision 107215089da92427c4c1644d84f5437b7b6e5e9c)
1#!/usr/bin/env python3
2#
3# Functional test that boots a microblaze Linux kernel and checks the console
4#
5# Copyright (c) 2018, 2021 Red Hat, Inc.
6#
7# This work is licensed under the terms of the GNU GPL, version 2 or
8# later. See the COPYING file in the top-level directory.
9
10from qemu_test import exec_command_and_wait_for_pattern
11from qemu_test import QemuSystemTest, Asset
12from qemu_test import wait_for_console_pattern
13
14
15class MicroblazeMachine(QemuSystemTest):
16
17    timeout = 90
18
19    ASSET_IMAGE_BE = Asset(
20        ('https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/'
21         'day17.tar.xz'),
22        '3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057')
23
24    ASSET_IMAGE_LE = Asset(
25        ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'),
26        'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22')
27
28    def do_ballerina_be_test(self, force_endianness=False):
29        self.set_machine('petalogix-s3adsp1800')
30        self.archive_extract(self.ASSET_IMAGE_BE)
31        self.vm.set_console()
32        self.vm.add_args('-kernel',
33                         self.scratch_file('day17', 'ballerina.bin'))
34        if force_endianness:
35            self.vm.add_args('-M', 'endianness=big')
36        self.vm.launch()
37        wait_for_console_pattern(self, 'This architecture does not have '
38                                       'kernel memory protection')
39        # Note:
40        # The kernel sometimes gets stuck after the "This architecture ..."
41        # message, that's why we don't test for a later string here. This
42        # needs some investigation by a microblaze wizard one day...
43
44    def do_xmaton_le_test(self, force_endianness=False):
45        self.require_netdev('user')
46        self.set_machine('petalogix-s3adsp1800')
47        self.archive_extract(self.ASSET_IMAGE_LE)
48        self.vm.set_console()
49        self.vm.add_args('-kernel', self.scratch_file('day13', 'xmaton.bin'))
50        if force_endianness:
51            self.vm.add_args('-M', 'endianness=little')
52        tftproot = self.scratch_file('day13')
53        self.vm.add_args('-nic', f'user,tftp={tftproot}')
54        self.vm.launch()
55        wait_for_console_pattern(self, 'QEMU Advent Calendar 2023')
56        wait_for_console_pattern(self, 'buildroot login:')
57        exec_command_and_wait_for_pattern(self, 'root', '#')
58        exec_command_and_wait_for_pattern(self,
59                'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png',
60                '821cd3cab8efd16ad6ee5acc3642a8ea')
61
62
63class MicroblazeBigEndianMachine(MicroblazeMachine):
64
65    ASSET_IMAGE_BE = MicroblazeMachine.ASSET_IMAGE_BE
66    ASSET_IMAGE_LE = MicroblazeMachine.ASSET_IMAGE_LE
67
68    def test_microblaze_s3adsp1800_legacy_be(self):
69        self.do_ballerina_be_test()
70
71    def test_microblaze_s3adsp1800_legacy_le(self):
72        self.do_xmaton_le_test(force_endianness=True)
73
74
75if __name__ == '__main__':
76    QemuSystemTest.main()
77