xref: /qemu/tests/functional/test_ppc64_mac99.py (revision e60938852ff051ab0afeb178af01bba0d63b3bbc)
1*5e654086SCédric Le Goater#!/usr/bin/env python3
2*5e654086SCédric Le Goater#
3*5e654086SCédric Le Goater# Functional test that boots a mac99 machine with a PPC970 CPU
4*5e654086SCédric Le Goater#
5*5e654086SCédric Le Goater# SPDX-License-Identifier: GPL-2.0-or-later
6*5e654086SCédric Le Goater
7*5e654086SCédric Le Goaterfrom qemu_test import LinuxKernelTest, Asset
8*5e654086SCédric Le Goaterfrom qemu_test import exec_command_and_wait_for_pattern
9*5e654086SCédric Le Goater
10*5e654086SCédric Le Goaterclass mac99Test(LinuxKernelTest):
11*5e654086SCédric Le Goater
12*5e654086SCédric Le Goater    ASSET_BR2_MAC99_LINUX = Asset(
13*5e654086SCédric Le Goater        'https://github.com/legoater/qemu-ppc-boot/raw/refs/heads/main/buildroot/qemu_ppc64_mac99-2023.11-8-gdcd9f0f6eb-20240105/vmlinux',
14*5e654086SCédric Le Goater        'd59307437e4365f2cced0bbd1b04949f7397b282ef349b7cafd894d74aadfbff')
15*5e654086SCédric Le Goater
16*5e654086SCédric Le Goater    ASSET_BR2_MAC99_ROOTFS = Asset(
17*5e654086SCédric Le Goater        'https://github.com/legoater/qemu-ppc-boot/raw/refs/heads/main//buildroot/qemu_ppc64_mac99-2023.11-8-gdcd9f0f6eb-20240105/rootfs.ext2',
18*5e654086SCédric Le Goater        'bbd5fd8af62f580bc4e585f326fe584e22856572633a8333178ea6d4ed4955a4')
19*5e654086SCédric Le Goater
20*5e654086SCédric Le Goater    def test_ppc64_mac99_buildroot(self):
21*5e654086SCédric Le Goater        self.set_machine('mac99')
22*5e654086SCédric Le Goater
23*5e654086SCédric Le Goater        linux_path = self.ASSET_BR2_MAC99_LINUX.fetch()
24*5e654086SCédric Le Goater        rootfs_path = self.ASSET_BR2_MAC99_ROOTFS.fetch()
25*5e654086SCédric Le Goater
26*5e654086SCédric Le Goater        self.vm.set_console()
27*5e654086SCédric Le Goater
28*5e654086SCédric Le Goater        # Note: We need '-nographic' to get a serial console
29*5e654086SCédric Le Goater        self.vm.add_args('-kernel', linux_path,
30*5e654086SCédric Le Goater                         '-append', 'root=/dev/sda',
31*5e654086SCédric Le Goater                         '-drive', f'file={rootfs_path},format=raw',
32*5e654086SCédric Le Goater                         '-snapshot', '-nographic')
33*5e654086SCédric Le Goater        self.vm.launch()
34*5e654086SCédric Le Goater
35*5e654086SCédric Le Goater        self.wait_for_console_pattern('>> OpenBIOS')
36*5e654086SCédric Le Goater        self.wait_for_console_pattern('Linux version')
37*5e654086SCédric Le Goater        self.wait_for_console_pattern('/init as init process')
38*5e654086SCédric Le Goater        self.wait_for_console_pattern('gem 0000:f0:0e.0 eth0: Link is up at 100 Mbps')
39*5e654086SCédric Le Goater        self.wait_for_console_pattern('buildroot login:')
40*5e654086SCédric Le Goater        exec_command_and_wait_for_pattern(self, 'root', '#')
41*5e654086SCédric Le Goater        exec_command_and_wait_for_pattern(self, 'poweroff', 'Power down')
42*5e654086SCédric Le Goater
43*5e654086SCédric Le Goaterif __name__ == '__main__':
44*5e654086SCédric Le Goater    LinuxKernelTest.main()
45