xref: /qemu/tests/functional/test_microblazeel_s3adsp1800.py (revision fe52b090c03bfb93a76883b8234fd42e975cb930)
1624fb343SThomas Huth#!/usr/bin/env python3
2624fb343SThomas Huth#
3624fb343SThomas Huth# Functional test that boots a microblaze Linux kernel and checks the console
4624fb343SThomas Huth#
5624fb343SThomas Huth# Copyright (c) 2018, 2021 Red Hat, Inc.
6624fb343SThomas Huth#
7624fb343SThomas Huth# This work is licensed under the terms of the GNU GPL, version 2 or
8624fb343SThomas Huth# later. See the COPYING file in the top-level directory.
9624fb343SThomas Huth
10624fb343SThomas Huthimport time
11624fb343SThomas Huthfrom qemu_test import exec_command, exec_command_and_wait_for_pattern
12624fb343SThomas Huthfrom qemu_test import QemuSystemTest, Asset
13624fb343SThomas Huthfrom qemu_test import wait_for_console_pattern
145831ed84SDaniel P. Berrangé
15624fb343SThomas Huth
16624fb343SThomas Huthclass MicroblazeelMachine(QemuSystemTest):
17624fb343SThomas Huth
18624fb343SThomas Huth    timeout = 90
19624fb343SThomas Huth
20a029fe84SPhilippe Mathieu-Daudé    ASSET_IMAGE_LE = Asset(
21624fb343SThomas Huth        ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'),
22624fb343SThomas Huth        'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22')
23624fb343SThomas Huth
24*fe52b090SPhilippe Mathieu-Daudé    def do_xmaton_le_test(self, machine):
25624fb343SThomas Huth        self.require_netdev('user')
26*fe52b090SPhilippe Mathieu-Daudé        self.set_machine(machine)
27a029fe84SPhilippe Mathieu-Daudé        self.archive_extract(self.ASSET_IMAGE_LE)
28624fb343SThomas Huth        self.vm.set_console()
29beaf88c8SDaniel P. Berrangé        self.vm.add_args('-kernel', self.scratch_file('day13', 'xmaton.bin'))
30beaf88c8SDaniel P. Berrangé        tftproot = self.scratch_file('day13')
31beaf88c8SDaniel P. Berrangé        self.vm.add_args('-nic', f'user,tftp={tftproot}')
32624fb343SThomas Huth        self.vm.launch()
33624fb343SThomas Huth        wait_for_console_pattern(self, 'QEMU Advent Calendar 2023')
34624fb343SThomas Huth        time.sleep(0.1)
35624fb343SThomas Huth        exec_command(self, 'root')
36624fb343SThomas Huth        time.sleep(0.1)
37624fb343SThomas Huth        exec_command_and_wait_for_pattern(self,
38624fb343SThomas Huth                'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png',
39624fb343SThomas Huth                '821cd3cab8efd16ad6ee5acc3642a8ea')
40624fb343SThomas Huth
41*fe52b090SPhilippe Mathieu-Daudé    def test_microblaze_s3adsp1800_legacy_le(self):
42*fe52b090SPhilippe Mathieu-Daudé        self.do_xmaton_le_test('petalogix-s3adsp1800')
43*fe52b090SPhilippe Mathieu-Daudé
44624fb343SThomas Huthif __name__ == '__main__':
45624fb343SThomas Huth    QemuSystemTest.main()
46