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