xref: /qemu/tests/functional/test_aarch64_sbsaref_alpine.py (revision 68df8c8dba57f539d24f1a92a8699a179d9bb6fb)
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 Aarch64SbsarefAlpine(QemuSystemTest):
20
21    ASSET_ALPINE_ISO = Asset(
22        ('https://dl-cdn.alpinelinux.org/'
23         'alpine/v3.17/releases/aarch64/alpine-standard-3.17.2-aarch64.iso'),
24        '5a36304ecf039292082d92b48152a9ec21009d3a62f459de623e19c4bd9dc027')
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_alpine_linux(self, cpu=None):
30        fetch_firmware(self)
31
32        iso_path = self.ASSET_ALPINE_ISO.fetch()
33
34        self.vm.set_console()
35        self.vm.add_args(
36            "-drive", f"file={iso_path},media=cdrom,format=raw",
37        )
38        if cpu:
39            self.vm.add_args("-cpu", cpu)
40
41        self.vm.launch()
42        wait_for_console_pattern(self, "Welcome to Alpine Linux 3.17")
43
44    def test_sbsaref_alpine_linux_cortex_a57(self):
45        self.boot_alpine_linux("cortex-a57")
46
47    def test_sbsaref_alpine_linux_default_cpu(self):
48        self.boot_alpine_linux()
49
50    def test_sbsaref_alpine_linux_max_pauth_off(self):
51        self.boot_alpine_linux("max,pauth=off")
52
53    def test_sbsaref_alpine_linux_max_pauth_impdef(self):
54        self.boot_alpine_linux("max,pauth-impdef=on")
55
56    @skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'),
57                'Test might timeout due to PAuth emulation')
58    def test_sbsaref_alpine_linux_max(self):
59        self.boot_alpine_linux("max")
60
61
62if __name__ == '__main__':
63    QemuSystemTest.main()
64