xref: /qemu/tests/functional/test_aarch64_sbsaref_freebsd.py (revision 9acd38845416088d395a8aefb07b9c99d24ea784)
1*9acd3884SThomas Huth#!/usr/bin/env python3
2*9acd3884SThomas Huth#
3*9acd3884SThomas Huth# Functional test that boots a kernel and checks the console
4*9acd3884SThomas Huth#
5*9acd3884SThomas Huth# SPDX-FileCopyrightText: 2023-2024 Linaro Ltd.
6*9acd3884SThomas Huth# SPDX-FileContributor: Philippe Mathieu-Daudé <philmd@linaro.org>
7*9acd3884SThomas Huth# SPDX-FileContributor: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
8*9acd3884SThomas Huth#
9*9acd3884SThomas Huth# SPDX-License-Identifier: GPL-2.0-or-later
10*9acd3884SThomas Huth
11*9acd3884SThomas Huthimport os
12*9acd3884SThomas Huth
13*9acd3884SThomas Huthfrom qemu_test import QemuSystemTest, Asset
14*9acd3884SThomas Huthfrom qemu_test import wait_for_console_pattern
15*9acd3884SThomas Huthfrom qemu_test import interrupt_interactive_console_until_pattern
16*9acd3884SThomas Huthfrom unittest import skipUnless
17*9acd3884SThomas Huthfrom test_aarch64_sbsaref import fetch_firmware
18*9acd3884SThomas Huth
19*9acd3884SThomas Huth
20*9acd3884SThomas Huthclass Aarch64SbsarefFreeBSD(QemuSystemTest):
21*9acd3884SThomas Huth
22*9acd3884SThomas Huth    ASSET_FREEBSD_ISO = Asset(
23*9acd3884SThomas Huth        ('https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/'
24*9acd3884SThomas Huth         '14.1/FreeBSD-14.1-RELEASE-arm64-aarch64-bootonly.iso'),
25*9acd3884SThomas Huth        '44cdbae275ef1bb6dab1d5fbb59473d4f741e1c8ea8a80fd9e906b531d6ad461')
26*9acd3884SThomas Huth
27*9acd3884SThomas Huth    # This tests the whole boot chain from EFI to Userspace
28*9acd3884SThomas Huth    # We only boot a whole OS for the current top level CPU and GIC
29*9acd3884SThomas Huth    # Other test profiles should use more minimal boots
30*9acd3884SThomas Huth    def boot_freebsd14(self, cpu=None):
31*9acd3884SThomas Huth        fetch_firmware(self)
32*9acd3884SThomas Huth
33*9acd3884SThomas Huth        img_path = self.ASSET_FREEBSD_ISO.fetch()
34*9acd3884SThomas Huth
35*9acd3884SThomas Huth        self.vm.set_console()
36*9acd3884SThomas Huth        self.vm.add_args(
37*9acd3884SThomas Huth            "-drive", f"file={img_path},format=raw,snapshot=on",
38*9acd3884SThomas Huth        )
39*9acd3884SThomas Huth        if cpu:
40*9acd3884SThomas Huth            self.vm.add_args("-cpu", cpu)
41*9acd3884SThomas Huth
42*9acd3884SThomas Huth        self.vm.launch()
43*9acd3884SThomas Huth        wait_for_console_pattern(self, 'Welcome to FreeBSD!')
44*9acd3884SThomas Huth
45*9acd3884SThomas Huth    def test_sbsaref_freebsd14_cortex_a57(self):
46*9acd3884SThomas Huth        self.boot_freebsd14("cortex-a57")
47*9acd3884SThomas Huth
48*9acd3884SThomas Huth    def test_sbsaref_freebsd14_default_cpu(self):
49*9acd3884SThomas Huth        self.boot_freebsd14()
50*9acd3884SThomas Huth
51*9acd3884SThomas Huth    def test_sbsaref_freebsd14_max_pauth_off(self):
52*9acd3884SThomas Huth        self.boot_freebsd14("max,pauth=off")
53*9acd3884SThomas Huth
54*9acd3884SThomas Huth    @skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'),
55*9acd3884SThomas Huth                'Test might timeout due to PAuth emulation')
56*9acd3884SThomas Huth    def test_sbsaref_freebsd14_max_pauth_impdef(self):
57*9acd3884SThomas Huth        self.boot_freebsd14("max,pauth-impdef=on")
58*9acd3884SThomas Huth
59*9acd3884SThomas Huth    @skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'),
60*9acd3884SThomas Huth                'Test might timeout due to PAuth emulation')
61*9acd3884SThomas Huth    def test_sbsaref_freebsd14_max(self):
62*9acd3884SThomas Huth        self.boot_freebsd14("max")
63*9acd3884SThomas Huth
64*9acd3884SThomas Huth
65*9acd3884SThomas Huthif __name__ == '__main__':
66*9acd3884SThomas Huth    QemuSystemTest.main()
67