xref: /openbmc/qemu/tests/avocado/ppc_powernv.py (revision 542b10bd)
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 console=hvc0 '
16    panic_message = 'Kernel panic - not syncing'
17    good_message = 'VFS: Cannot open root device'
18
19    def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE):
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        self.vm.add_args('-kernel', kernel_path,
29                         '-append', command_line)
30        self.vm.launch()
31
32    def test_linux_boot(self):
33        """
34        :avocado: tags=arch:ppc64
35        :avocado: tags=machine:powernv
36        :avocado: tags=accel:tcg
37        """
38
39        self.do_test_linux_boot()
40        console_pattern = 'VFS: Cannot open root device'
41        wait_for_console_pattern(self, console_pattern, self.panic_message)
42
43    def test_linux_smp_boot(self):
44        """
45        :avocado: tags=arch:ppc64
46        :avocado: tags=machine:powernv
47        :avocado: tags=accel:tcg
48        """
49
50        self.vm.add_args('-smp', '4')
51        self.do_test_linux_boot()
52        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
53        wait_for_console_pattern(self, console_pattern, self.panic_message)
54        wait_for_console_pattern(self, self.good_message, self.panic_message)
55
56    def test_linux_smp_hpt_boot(self):
57        """
58        :avocado: tags=arch:ppc64
59        :avocado: tags=machine:powernv
60        :avocado: tags=accel:tcg
61        """
62
63        self.vm.add_args('-smp', '4')
64        self.do_test_linux_boot(self.KERNEL_COMMON_COMMAND_LINE +
65                                'disable_radix')
66        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
67        wait_for_console_pattern(self, 'hash-mmu: Initializing hash mmu',
68                                 self.panic_message)
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_smt_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', '4,threads=4')
80        self.do_test_linux_boot()
81        console_pattern = 'CPU maps initialized for 4 threads per core'
82        wait_for_console_pattern(self, console_pattern, self.panic_message)
83        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
84        wait_for_console_pattern(self, console_pattern, self.panic_message)
85        wait_for_console_pattern(self, self.good_message, self.panic_message)
86
87    def test_linux_big_boot(self):
88        """
89        :avocado: tags=arch:ppc64
90        :avocado: tags=machine:powernv
91        :avocado: tags=accel:tcg
92        """
93
94        self.vm.add_args('-smp', '16,threads=4,cores=2,sockets=2')
95
96        # powernv does not support NUMA
97        self.do_test_linux_boot()
98        console_pattern = 'CPU maps initialized for 4 threads per core'
99        wait_for_console_pattern(self, console_pattern, self.panic_message)
100        console_pattern = 'smp: Brought up 2 nodes, 16 CPUs'
101        wait_for_console_pattern(self, console_pattern, self.panic_message)
102        wait_for_console_pattern(self, self.good_message, self.panic_message)
103