xref: /qemu/tests/functional/test_aarch64_sbsaref_freebsd.py (revision d6f7642230f15c5e470a8988b31980ff570124f5)
19acd3884SThomas Huth#!/usr/bin/env python3
29acd3884SThomas Huth#
39acd3884SThomas Huth# Functional test that boots a kernel and checks the console
49acd3884SThomas Huth#
5*d6f76422SPhilippe Mathieu-Daudé# Copyright (c) 2023-2024 Linaro Ltd.
6*d6f76422SPhilippe Mathieu-Daudé#
7*d6f76422SPhilippe Mathieu-Daudé# Authors:
8*d6f76422SPhilippe Mathieu-Daudé#   Philippe Mathieu-Daudé
9*d6f76422SPhilippe Mathieu-Daudé#   Marcin Juszkiewicz
109acd3884SThomas Huth#
119acd3884SThomas Huth# SPDX-License-Identifier: GPL-2.0-or-later
129acd3884SThomas Huth
139acd3884SThomas Huthimport os
149acd3884SThomas Huth
159acd3884SThomas Huthfrom qemu_test import QemuSystemTest, Asset
169acd3884SThomas Huthfrom qemu_test import wait_for_console_pattern
179acd3884SThomas Huthfrom unittest import skipUnless
189acd3884SThomas Huthfrom test_aarch64_sbsaref import fetch_firmware
199acd3884SThomas Huth
209acd3884SThomas Huth
219acd3884SThomas Huthclass Aarch64SbsarefFreeBSD(QemuSystemTest):
229acd3884SThomas Huth
239acd3884SThomas Huth    ASSET_FREEBSD_ISO = Asset(
249acd3884SThomas Huth        ('https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/'
259acd3884SThomas Huth         '14.1/FreeBSD-14.1-RELEASE-arm64-aarch64-bootonly.iso'),
269acd3884SThomas Huth        '44cdbae275ef1bb6dab1d5fbb59473d4f741e1c8ea8a80fd9e906b531d6ad461')
279acd3884SThomas Huth
289acd3884SThomas Huth    # This tests the whole boot chain from EFI to Userspace
299acd3884SThomas Huth    # We only boot a whole OS for the current top level CPU and GIC
309acd3884SThomas Huth    # Other test profiles should use more minimal boots
319acd3884SThomas Huth    def boot_freebsd14(self, cpu=None):
329acd3884SThomas Huth        fetch_firmware(self)
339acd3884SThomas Huth
349acd3884SThomas Huth        img_path = self.ASSET_FREEBSD_ISO.fetch()
359acd3884SThomas Huth
369acd3884SThomas Huth        self.vm.set_console()
379acd3884SThomas Huth        self.vm.add_args(
389acd3884SThomas Huth            "-drive", f"file={img_path},format=raw,snapshot=on",
399acd3884SThomas Huth        )
409acd3884SThomas Huth        if cpu:
419acd3884SThomas Huth            self.vm.add_args("-cpu", cpu)
429acd3884SThomas Huth
439acd3884SThomas Huth        self.vm.launch()
449acd3884SThomas Huth        wait_for_console_pattern(self, 'Welcome to FreeBSD!')
459acd3884SThomas Huth
469acd3884SThomas Huth    def test_sbsaref_freebsd14_cortex_a57(self):
479acd3884SThomas Huth        self.boot_freebsd14("cortex-a57")
489acd3884SThomas Huth
499acd3884SThomas Huth    def test_sbsaref_freebsd14_default_cpu(self):
509acd3884SThomas Huth        self.boot_freebsd14()
519acd3884SThomas Huth
529acd3884SThomas Huth    def test_sbsaref_freebsd14_max_pauth_off(self):
539acd3884SThomas Huth        self.boot_freebsd14("max,pauth=off")
549acd3884SThomas Huth
559acd3884SThomas Huth    @skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'),
569acd3884SThomas Huth                'Test might timeout due to PAuth emulation')
579acd3884SThomas Huth    def test_sbsaref_freebsd14_max_pauth_impdef(self):
589acd3884SThomas Huth        self.boot_freebsd14("max,pauth-impdef=on")
599acd3884SThomas Huth
609acd3884SThomas Huth    @skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'),
619acd3884SThomas Huth                'Test might timeout due to PAuth emulation')
629acd3884SThomas Huth    def test_sbsaref_freebsd14_max(self):
639acd3884SThomas Huth        self.boot_freebsd14("max")
649acd3884SThomas Huth
659acd3884SThomas Huth
669acd3884SThomas Huthif __name__ == '__main__':
679acd3884SThomas Huth    QemuSystemTest.main()
68