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
10import time
11from qemu_test import exec_command, exec_command_and_wait_for_pattern
12from qemu_test import QemuSystemTest, Asset
13from qemu_test import wait_for_console_pattern
14from qemu_test.utils import archive_extract
15
16class MicroblazeMachine(QemuSystemTest):
17
18    timeout = 90
19
20    ASSET_IMAGE = Asset(
21        ('https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/'
22         'day17.tar.xz'),
23        '3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057')
24
25    def test_microblaze_s3adsp1800(self):
26        self.set_machine('petalogix-s3adsp1800')
27        file_path = self.ASSET_IMAGE.fetch()
28        archive_extract(file_path, self.workdir)
29        self.vm.set_console()
30        self.vm.add_args('-kernel', self.workdir + '/day17/ballerina.bin')
31        self.vm.launch()
32        wait_for_console_pattern(self, 'This architecture does not have '
33                                       'kernel memory protection')
34        # Note:
35        # The kernel sometimes gets stuck after the "This architecture ..."
36        # message, that's why we don't test for a later string here. This
37        # needs some investigation by a microblaze wizard one day...
38
39if __name__ == '__main__':
40    QemuSystemTest.main()
41