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