xref: /qemu/tests/functional/test_aarch64_replay.py (revision 55f5bf716a65f67663d0769bcb8c017764b3e53a)
14d75a374SThomas Huth#!/usr/bin/env python3
24d75a374SThomas Huth#
34d75a374SThomas Huth# Replay test that boots a Linux kernel on an aarch64 machine
44d75a374SThomas Huth# and checks the console
54d75a374SThomas Huth#
64d75a374SThomas Huth# SPDX-License-Identifier: GPL-2.0-or-later
74d75a374SThomas Huth
8*a820caf8SThomas Huthfrom subprocess import check_call, DEVNULL
9*a820caf8SThomas Huth
10*a820caf8SThomas Huthfrom qemu_test import Asset, skipIfOperatingSystem, get_qemu_img
114d75a374SThomas Huthfrom replay_kernel import ReplayKernelBase
124d75a374SThomas Huth
134d75a374SThomas Huth
144d75a374SThomas Huthclass Aarch64Replay(ReplayKernelBase):
154d75a374SThomas Huth
164d75a374SThomas Huth    ASSET_KERNEL = Asset(
17*a820caf8SThomas Huth        'https://storage.tuxboot.com/buildroot/20241119/arm64/Image',
18*a820caf8SThomas Huth        'b74743c5e89e1cea0f73368d24ae0ae85c5204ff84be3b5e9610417417d2f235')
19*a820caf8SThomas Huth
20*a820caf8SThomas Huth    ASSET_ROOTFS = Asset(
21*a820caf8SThomas Huth        'https://storage.tuxboot.com/buildroot/20241119/arm64/rootfs.ext4.zst',
22*a820caf8SThomas Huth        'a1acaaae2068df4648d04ff75f532aaa8c5edcd6b936122b6f0db4848a07b465')
234d75a374SThomas Huth
244d75a374SThomas Huth    def test_aarch64_virt(self):
25*a820caf8SThomas Huth        self.require_netdev('user')
264d75a374SThomas Huth        self.set_machine('virt')
27*a820caf8SThomas Huth        self.cpu = 'cortex-a57'
284d75a374SThomas Huth        kernel_path = self.ASSET_KERNEL.fetch()
29*a820caf8SThomas Huth
30*a820caf8SThomas Huth        raw_disk = self.uncompress(self.ASSET_ROOTFS)
31*a820caf8SThomas Huth        disk = self.scratch_file('scratch.qcow2')
32*a820caf8SThomas Huth        qemu_img = get_qemu_img(self)
33*a820caf8SThomas Huth        check_call([qemu_img, 'create', '-f', 'qcow2', '-b', raw_disk,
34*a820caf8SThomas Huth                    '-F', 'raw', disk], stdout=DEVNULL, stderr=DEVNULL)
35*a820caf8SThomas Huth
36*a820caf8SThomas Huth        args = ('-drive', 'file=%s,snapshot=on,id=hd0,if=none' % disk,
37*a820caf8SThomas Huth                '-drive', 'driver=blkreplay,id=hd0-rr,if=none,image=hd0',
38*a820caf8SThomas Huth                '-device', 'virtio-blk-device,drive=hd0-rr',
39*a820caf8SThomas Huth                '-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22',
40*a820caf8SThomas Huth                '-device', 'virtio-net,netdev=vnet',
41*a820caf8SThomas Huth                '-object', 'filter-replay,id=replay,netdev=vnet')
42*a820caf8SThomas Huth
434d75a374SThomas Huth        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
44*a820caf8SThomas Huth                               'console=ttyAMA0 root=/dev/vda')
45*a820caf8SThomas Huth        console_pattern = 'Welcome to TuxTest'
46*a820caf8SThomas Huth        self.run_rr(kernel_path, kernel_command_line, console_pattern,
47*a820caf8SThomas Huth                    args=args)
484d75a374SThomas Huth
494d75a374SThomas Huth
504d75a374SThomas Huthif __name__ == '__main__':
514d75a374SThomas Huth    ReplayKernelBase.main()
52