xref: /openbmc/qemu/tests/avocado/ppc_powernv.py (revision 339d13ce)
1# Test that Linux kernel boots on ppc powernv machines and check the console
2#
3# Copyright (c) 2018, 2020 Red Hat, Inc.
4#
5# This work is licensed under the terms of the GNU GPL, version 2 or
6# later.  See the COPYING file in the top-level directory.
7
8from avocado.utils import archive
9from avocado_qemu import QemuSystemTest
10from avocado_qemu import wait_for_console_pattern
11
12class powernvMachine(QemuSystemTest):
13
14    timeout = 90
15    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
16    panic_message = 'Kernel panic - not syncing'
17    good_message = 'VFS: Cannot open root device'
18
19    def do_test_linux_boot(self):
20        self.require_accelerator("tcg")
21        kernel_url = ('https://archives.fedoraproject.org/pub/archive'
22                      '/fedora-secondary/releases/29/Everything/ppc64le/os'
23                      '/ppc/ppc64/vmlinuz')
24        kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
25        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
26
27        self.vm.set_console()
28        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
29        self.vm.add_args('-kernel', kernel_path,
30                         '-append', kernel_command_line)
31        self.vm.launch()
32
33    def test_linux_boot(self):
34        """
35        :avocado: tags=arch:ppc64
36        :avocado: tags=machine:powernv
37        :avocado: tags=accel:tcg
38        """
39
40        self.do_test_linux_boot()
41        console_pattern = 'VFS: Cannot open root device'
42        wait_for_console_pattern(self, console_pattern, self.panic_message)
43
44    def test_linux_smp_boot(self):
45        """
46        :avocado: tags=arch:ppc64
47        :avocado: tags=machine:powernv
48        :avocado: tags=accel:tcg
49        """
50
51        self.vm.add_args('-smp', '4')
52        self.do_test_linux_boot()
53        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
54        wait_for_console_pattern(self, console_pattern, self.panic_message)
55        wait_for_console_pattern(self, self.good_message, self.panic_message)
56
57    def test_linux_smt_boot(self):
58        """
59        :avocado: tags=arch:ppc64
60        :avocado: tags=machine:powernv
61        :avocado: tags=accel:tcg
62        """
63
64        self.vm.add_args('-smp', '4,threads=4')
65        self.do_test_linux_boot()
66        console_pattern = 'CPU maps initialized for 4 threads per core'
67        wait_for_console_pattern(self, console_pattern, self.panic_message)
68        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
69        wait_for_console_pattern(self, console_pattern, self.panic_message)
70        wait_for_console_pattern(self, self.good_message, self.panic_message)
71
72    def test_linux_big_boot(self):
73        """
74        :avocado: tags=arch:ppc64
75        :avocado: tags=machine:powernv
76        :avocado: tags=accel:tcg
77        """
78
79        self.vm.add_args('-smp', '16,threads=4,cores=2,sockets=2')
80
81        # powernv does not support NUMA
82        self.do_test_linux_boot()
83        console_pattern = 'CPU maps initialized for 4 threads per core'
84        wait_for_console_pattern(self, console_pattern, self.panic_message)
85        console_pattern = 'smp: Brought up 2 nodes, 16 CPUs'
86        wait_for_console_pattern(self, console_pattern, self.panic_message)
87        wait_for_console_pattern(self, self.good_message, self.panic_message)
88