1*624fb343SThomas Huth#!/usr/bin/env python3
2*624fb343SThomas Huth#
3*624fb343SThomas Huth# Functional test that boots a microblaze Linux kernel and checks the console
4*624fb343SThomas Huth#
5*624fb343SThomas Huth# Copyright (c) 2018, 2021 Red Hat, Inc.
6*624fb343SThomas Huth#
7*624fb343SThomas Huth# This work is licensed under the terms of the GNU GPL, version 2 or
8*624fb343SThomas Huth# later. See the COPYING file in the top-level directory.
9*624fb343SThomas Huth
10*624fb343SThomas Huthimport time
11*624fb343SThomas Huthfrom qemu_test import exec_command, exec_command_and_wait_for_pattern
12*624fb343SThomas Huthfrom qemu_test import QemuSystemTest, Asset
13*624fb343SThomas Huthfrom qemu_test import wait_for_console_pattern
14*624fb343SThomas Huthfrom qemu_test.utils import archive_extract
15*624fb343SThomas Huth
16*624fb343SThomas Huthclass MicroblazeMachine(QemuSystemTest):
17*624fb343SThomas Huth
18*624fb343SThomas Huth    timeout = 90
19*624fb343SThomas Huth
20*624fb343SThomas Huth    ASSET_IMAGE = Asset(
21*624fb343SThomas Huth        ('https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/'
22*624fb343SThomas Huth         'day17.tar.xz'),
23*624fb343SThomas Huth        '3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057')
24*624fb343SThomas Huth
25*624fb343SThomas Huth    def test_microblaze_s3adsp1800(self):
26*624fb343SThomas Huth        self.set_machine('petalogix-s3adsp1800')
27*624fb343SThomas Huth        file_path = self.ASSET_IMAGE.fetch()
28*624fb343SThomas Huth        archive_extract(file_path, self.workdir)
29*624fb343SThomas Huth        self.vm.set_console()
30*624fb343SThomas Huth        self.vm.add_args('-kernel', self.workdir + '/day17/ballerina.bin')
31*624fb343SThomas Huth        self.vm.launch()
32*624fb343SThomas Huth        wait_for_console_pattern(self, 'This architecture does not have '
33*624fb343SThomas Huth                                       'kernel memory protection')
34*624fb343SThomas Huth        # Note:
35*624fb343SThomas Huth        # The kernel sometimes gets stuck after the "This architecture ..."
36*624fb343SThomas Huth        # message, that's why we don't test for a later string here. This
37*624fb343SThomas Huth        # needs some investigation by a microblaze wizard one day...
38*624fb343SThomas Huth
39*624fb343SThomas Huthif __name__ == '__main__':
40*624fb343SThomas Huth    QemuSystemTest.main()
41