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 16from qemu_test import wait_for_console_pattern 17from unittest import skipUnless 18from test_aarch64_sbsaref import fetch_firmware 19 20 21class Aarch64SbsarefFreeBSD(QemuSystemTest): 22 23 ASSET_FREEBSD_ISO = Asset( 24 ('https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/' 25 '14.1/FreeBSD-14.1-RELEASE-arm64-aarch64-bootonly.iso'), 26 '44cdbae275ef1bb6dab1d5fbb59473d4f741e1c8ea8a80fd9e906b531d6ad461') 27 28 # This tests the whole boot chain from EFI to Userspace 29 # We only boot a whole OS for the current top level CPU and GIC 30 # Other test profiles should use more minimal boots 31 def boot_freebsd14(self, cpu=None): 32 fetch_firmware(self) 33 34 img_path = self.ASSET_FREEBSD_ISO.fetch() 35 36 self.vm.set_console() 37 self.vm.add_args( 38 "-drive", f"file={img_path},format=raw,snapshot=on", 39 ) 40 if cpu: 41 self.vm.add_args("-cpu", cpu) 42 43 self.vm.launch() 44 wait_for_console_pattern(self, 'Welcome to FreeBSD!') 45 46 def test_sbsaref_freebsd14_cortex_a57(self): 47 self.boot_freebsd14("cortex-a57") 48 49 def test_sbsaref_freebsd14_default_cpu(self): 50 self.boot_freebsd14() 51 52 def test_sbsaref_freebsd14_max_pauth_off(self): 53 self.boot_freebsd14("max,pauth=off") 54 55 @skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'), 56 'Test might timeout due to PAuth emulation') 57 def test_sbsaref_freebsd14_max_pauth_impdef(self): 58 self.boot_freebsd14("max,pauth-impdef=on") 59 60 @skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'), 61 'Test might timeout due to PAuth emulation') 62 def test_sbsaref_freebsd14_max(self): 63 self.boot_freebsd14("max") 64 65 66if __name__ == '__main__': 67 QemuSystemTest.main() 68