1#!/usr/bin/env python3
2#
3# Functional test that boots a Linux kernel and checks the console
4#
5# Copyright (c) 2020 Red Hat, Inc.
6#
7# Author:
8#  Thomas Huth <thuth@redhat.com>
9#
10# This work is licensed under the terms of the GNU GPL, version 2 or
11# later. See the COPYING file in the top-level directory.
12
13import os
14
15from qemu_test import QemuSystemTest, Asset
16from qemu_test import wait_for_console_pattern
17from qemu_test.utils import archive_extract
18
19class Sun4uMachine(QemuSystemTest):
20    """Boots the Linux kernel and checks that the console is operational"""
21
22    timeout = 90
23
24    ASSET_IMAGE = Asset(
25        ('https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/'
26         'day23.tar.xz'),
27        'a3ed92450704af244178351afd0e769776e7decb298e95a63abfd9a6e3f6c854')
28
29    def test_sparc64_sun4u(self):
30        self.set_machine('sun4u')
31        file_path = self.ASSET_IMAGE.fetch()
32        kernel_name = 'day23/vmlinux'
33        archive_extract(file_path, self.workdir, kernel_name)
34        self.vm.set_console()
35        self.vm.add_args('-kernel', os.path.join(self.workdir, kernel_name),
36                         '-append', 'printk.time=0')
37        self.vm.launch()
38        wait_for_console_pattern(self, 'Starting logging: OK')
39
40if __name__ == '__main__':
41    QemuSystemTest.main()
42