xref: /qemu/tests/functional/test_ppc64_pseries.py (revision bcfee4938f8d4e8bf5f49981d3c8a78cf267cb4e)
1407a6883SThomas Huth#!/usr/bin/env python3
2407a6883SThomas Huth#
3c5f0a816SDavid Gibson# Test that Linux kernel boots on ppc machines and check the console
4c5f0a816SDavid Gibson#
5c5f0a816SDavid Gibson# Copyright (c) 2018, 2020 Red Hat, Inc.
6c5f0a816SDavid Gibson#
7c5f0a816SDavid Gibson# This work is licensed under the terms of the GNU GPL, version 2 or
8c5f0a816SDavid Gibson# later.  See the COPYING file in the top-level directory.
9c5f0a816SDavid Gibson
10407a6883SThomas Huthfrom qemu_test import QemuSystemTest, Asset
11407a6883SThomas Huthfrom qemu_test import wait_for_console_pattern
12c5f0a816SDavid Gibson
132283b627SPhilippe Mathieu-Daudéclass pseriesMachine(QemuSystemTest):
14c5f0a816SDavid Gibson
15c5f0a816SDavid Gibson    timeout = 90
168d07a8aeSNicholas Piggin    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 '
17c5f0a816SDavid Gibson    panic_message = 'Kernel panic - not syncing'
18242e8b4dSNicholas Piggin    good_message = 'VFS: Cannot open root device'
19c5f0a816SDavid Gibson
20407a6883SThomas Huth    ASSET_KERNEL = Asset(
21407a6883SThomas Huth        ('https://archives.fedoraproject.org/pub/archive/fedora-secondary/'
22407a6883SThomas Huth         'releases/29/Everything/ppc64le/os/ppc/ppc64/vmlinuz'),
23407a6883SThomas Huth        '383c2f5c23bc0d9d32680c3924d3fd7ee25cc5ef97091ac1aa5e1d853422fc5f')
24407a6883SThomas Huth
258d07a8aeSNicholas Piggin    def do_test_ppc64_linux_boot(self, kernel_command_line = KERNEL_COMMON_COMMAND_LINE):
26407a6883SThomas Huth        kernel_path = self.ASSET_KERNEL.fetch()
27c5f0a816SDavid Gibson
28c5f0a816SDavid Gibson        self.vm.set_console()
29c5f0a816SDavid Gibson        self.vm.add_args('-kernel', kernel_path,
30c5f0a816SDavid Gibson                         '-append', kernel_command_line)
31c5f0a816SDavid Gibson        self.vm.launch()
32242e8b4dSNicholas Piggin
335eb63b88SNicholas Piggin    def test_ppc64_vof_linux_boot(self):
34407a6883SThomas Huth        self.set_machine('pseries')
355eb63b88SNicholas Piggin        self.vm.add_args('-machine', 'x-vof=on')
365eb63b88SNicholas Piggin        self.do_test_ppc64_linux_boot()
375eb63b88SNicholas Piggin        console_pattern = 'VFS: Cannot open root device'
385eb63b88SNicholas Piggin        wait_for_console_pattern(self, console_pattern, self.panic_message)
395eb63b88SNicholas Piggin
40242e8b4dSNicholas Piggin    def test_ppc64_linux_boot(self):
41407a6883SThomas Huth        self.set_machine('pseries')
42242e8b4dSNicholas Piggin        self.do_test_ppc64_linux_boot()
438f4c627bSNicholas Piggin        console_pattern = 'VFS: Cannot open root device'
44c5f0a816SDavid Gibson        wait_for_console_pattern(self, console_pattern, self.panic_message)
45242e8b4dSNicholas Piggin
46242e8b4dSNicholas Piggin    def test_ppc64_linux_smp_boot(self):
47407a6883SThomas Huth        self.set_machine('pseries')
48242e8b4dSNicholas Piggin        self.vm.add_args('-smp', '4')
49242e8b4dSNicholas Piggin        self.do_test_ppc64_linux_boot()
50242e8b4dSNicholas Piggin        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
51242e8b4dSNicholas Piggin        wait_for_console_pattern(self, console_pattern, self.panic_message)
52242e8b4dSNicholas Piggin        wait_for_console_pattern(self, self.good_message, self.panic_message)
53242e8b4dSNicholas Piggin
548d07a8aeSNicholas Piggin    def test_ppc64_linux_hpt_smp_boot(self):
55407a6883SThomas Huth        self.set_machine('pseries')
568d07a8aeSNicholas Piggin        self.vm.add_args('-smp', '4')
578d07a8aeSNicholas Piggin        self.do_test_ppc64_linux_boot(self.KERNEL_COMMON_COMMAND_LINE +
588d07a8aeSNicholas Piggin                                      'disable_radix')
598d07a8aeSNicholas Piggin        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
608d07a8aeSNicholas Piggin        wait_for_console_pattern(self, 'hash-mmu: Initializing hash mmu',
618d07a8aeSNicholas Piggin                                 self.panic_message)
628d07a8aeSNicholas Piggin        wait_for_console_pattern(self, console_pattern, self.panic_message)
638d07a8aeSNicholas Piggin        wait_for_console_pattern(self, self.good_message, self.panic_message)
648d07a8aeSNicholas Piggin
65242e8b4dSNicholas Piggin    def test_ppc64_linux_smt_boot(self):
66*bcfee493SThomas Huth        self.set_machine('pseries')
67242e8b4dSNicholas Piggin        self.vm.add_args('-smp', '4,threads=4')
68242e8b4dSNicholas Piggin        self.do_test_ppc64_linux_boot()
69242e8b4dSNicholas Piggin        console_pattern = 'CPU maps initialized for 4 threads per core'
70242e8b4dSNicholas Piggin        wait_for_console_pattern(self, console_pattern, self.panic_message)
71242e8b4dSNicholas Piggin        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
72242e8b4dSNicholas Piggin        wait_for_console_pattern(self, console_pattern, self.panic_message)
73242e8b4dSNicholas Piggin        wait_for_console_pattern(self, self.good_message, self.panic_message)
74242e8b4dSNicholas Piggin
75242e8b4dSNicholas Piggin    def test_ppc64_linux_big_boot(self):
76407a6883SThomas Huth        self.set_machine('pseries')
77242e8b4dSNicholas Piggin        self.vm.add_args('-smp', '16,threads=4,cores=2,sockets=2')
78242e8b4dSNicholas Piggin        self.vm.add_args('-m', '512M',
79242e8b4dSNicholas Piggin                         '-object', 'memory-backend-ram,size=256M,id=m0',
80242e8b4dSNicholas Piggin                         '-object', 'memory-backend-ram,size=256M,id=m1')
81242e8b4dSNicholas Piggin        self.vm.add_args('-numa', 'node,nodeid=0,memdev=m0')
82242e8b4dSNicholas Piggin        self.vm.add_args('-numa', 'node,nodeid=1,memdev=m1')
83242e8b4dSNicholas Piggin        self.do_test_ppc64_linux_boot()
84242e8b4dSNicholas Piggin        console_pattern = 'CPU maps initialized for 4 threads per core'
85242e8b4dSNicholas Piggin        wait_for_console_pattern(self, console_pattern, self.panic_message)
86242e8b4dSNicholas Piggin        console_pattern = 'smp: Brought up 2 nodes, 16 CPUs'
87242e8b4dSNicholas Piggin        wait_for_console_pattern(self, console_pattern, self.panic_message)
88242e8b4dSNicholas Piggin        wait_for_console_pattern(self, self.good_message, self.panic_message)
89407a6883SThomas Huth
90407a6883SThomas Huthif __name__ == '__main__':
91407a6883SThomas Huth    QemuSystemTest.main()
92