xref: /qemu/tests/functional/test_aarch64_replay.py (revision 5983a20a0bca7d54846abbb36fb59c7d9b1f226b)
1 #!/usr/bin/env python3
2 #
3 # Replay test that boots a Linux kernel on an aarch64 machine
4 # and checks the console
5 #
6 # SPDX-License-Identifier: GPL-2.0-or-later
7 
8 from subprocess import check_call, DEVNULL
9 
10 from qemu_test import Asset, skipIfOperatingSystem, get_qemu_img
11 from replay_kernel import ReplayKernelBase
12 
13 
14 class Aarch64Replay(ReplayKernelBase):
15 
16     ASSET_KERNEL = Asset(
17         'https://storage.tuxboot.com/buildroot/20241119/arm64/Image',
18         'b74743c5e89e1cea0f73368d24ae0ae85c5204ff84be3b5e9610417417d2f235')
19 
20     ASSET_ROOTFS = Asset(
21         'https://storage.tuxboot.com/buildroot/20241119/arm64/rootfs.ext4.zst',
22         'a1acaaae2068df4648d04ff75f532aaa8c5edcd6b936122b6f0db4848a07b465')
23 
24     def test_aarch64_virt(self):
25         self.require_netdev('user')
26         self.set_machine('virt')
27         self.cpu = 'cortex-a57'
28         kernel_path = self.ASSET_KERNEL.fetch()
29 
30         raw_disk = self.uncompress(self.ASSET_ROOTFS)
31         disk = self.scratch_file('scratch.qcow2')
32         qemu_img = get_qemu_img(self)
33         check_call([qemu_img, 'create', '-f', 'qcow2', '-b', raw_disk,
34                     '-F', 'raw', disk], stdout=DEVNULL, stderr=DEVNULL)
35 
36         args = ('-drive', 'file=%s,snapshot=on,id=hd0,if=none' % disk,
37                 '-drive', 'driver=blkreplay,id=hd0-rr,if=none,image=hd0',
38                 '-device', 'virtio-blk-device,drive=hd0-rr',
39                 '-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22',
40                 '-device', 'virtio-net,netdev=vnet',
41                 '-object', 'filter-replay,id=replay,netdev=vnet')
42 
43         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
44                                'console=ttyAMA0 root=/dev/vda')
45         console_pattern = 'Welcome to TuxTest'
46         self.run_rr(kernel_path, kernel_command_line, console_pattern,
47                     args=args)
48 
49 
50 if __name__ == '__main__':
51     ReplayKernelBase.main()
52