xref: /openbmc/qemu/tests/functional/test_aarch64_sbsaref_alpine.py (revision 7698afc42b5af9e55f12ab2236618e38e5a1c23f)
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
13from qemu_test import QemuSystemTest, Asset, skipSlowTest
14from qemu_test import wait_for_console_pattern
15from test_aarch64_sbsaref import fetch_firmware
16
17
18class Aarch64SbsarefAlpine(QemuSystemTest):
19
20    ASSET_ALPINE_ISO = Asset(
21        ('https://dl-cdn.alpinelinux.org/'
22         'alpine/v3.17/releases/aarch64/alpine-standard-3.17.2-aarch64.iso'),
23        '5a36304ecf039292082d92b48152a9ec21009d3a62f459de623e19c4bd9dc027')
24
25    # This tests the whole boot chain from EFI to Userspace
26    # We only boot a whole OS for the current top level CPU and GIC
27    # Other test profiles should use more minimal boots
28    def boot_alpine_linux(self, cpu=None):
29        self.set_machine('sbsa-ref')
30
31        fetch_firmware(self)
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    @skipSlowTest()  # Test might timeout due to PAuth emulation
57    def test_sbsaref_alpine_linux_max(self):
58        self.boot_alpine_linux("max")
59
60
61if __name__ == '__main__':
62    QemuSystemTest.main()
63