xref: /qemu/tests/functional/test_microblaze_s3adsp1800.py (revision 6ff5da16000f908140723e164d33a0b51a6c4162)
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, machine):
29        self.set_machine(machine)
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        self.vm.launch()
35        wait_for_console_pattern(self, 'This architecture does not have '
36                                       'kernel memory protection')
37        # Note:
38        # The kernel sometimes gets stuck after the "This architecture ..."
39        # message, that's why we don't test for a later string here. This
40        # needs some investigation by a microblaze wizard one day...
41
42    def do_xmaton_le_test(self, machine):
43        self.require_netdev('user')
44        self.set_machine(machine)
45        self.archive_extract(self.ASSET_IMAGE_LE)
46        self.vm.set_console()
47        self.vm.add_args('-kernel', self.scratch_file('day13', 'xmaton.bin'))
48        tftproot = self.scratch_file('day13')
49        self.vm.add_args('-nic', f'user,tftp={tftproot}')
50        self.vm.launch()
51        wait_for_console_pattern(self, 'QEMU Advent Calendar 2023')
52        wait_for_console_pattern(self, 'buildroot login:')
53        exec_command_and_wait_for_pattern(self, 'root', '#')
54        exec_command_and_wait_for_pattern(self,
55                'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png',
56                '821cd3cab8efd16ad6ee5acc3642a8ea')
57
58
59class MicroblazeBigEndianMachine(MicroblazeMachine):
60
61    ASSET_IMAGE_BE = MicroblazeMachine.ASSET_IMAGE_BE
62
63    def test_microblaze_s3adsp1800_legacy_be(self):
64        self.do_ballerina_be_test('petalogix-s3adsp1800')
65
66
67if __name__ == '__main__':
68    QemuSystemTest.main()
69