| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Replay test that boots a Linux kernel on x86_64 machines |
| 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, skipFlakyTest, get_qemu_img |
| 11 | from replay_kernel import ReplayKernelBase |
| 12 | |
| 13 | |
| 14 | class X86Replay(ReplayKernelBase): |
| 15 | |
| 16 | ASSET_KERNEL = Asset( |
| 17 | 'https://storage.tuxboot.com/buildroot/20241119/x86_64/bzImage', |
| 18 | 'f57bfc6553bcd6e0a54aab86095bf642b33b5571d14e3af1731b18c87ed5aef8') |
| 19 | |
| 20 | ASSET_ROOTFS = Asset( |
| 21 | 'https://storage.tuxboot.com/buildroot/20241119/x86_64/rootfs.ext4.zst', |
| 22 | '4b8b2a99117519c5290e1202cb36eb6c7aaba92b357b5160f5970cf5fb78a751') |
| 23 | |
| 24 | def do_test_x86(self, machine, blkdevice, devroot): |
| 25 | self.require_netdev('user') |
| 26 | self.set_machine(machine) |
| 27 | self.cpu="Nehalem" |
| 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', '%s,drive=hd0-rr' % blkdevice, |
| 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 | f"console=ttyS0 root=/dev/{devroot}") |
| 45 | console_pattern = 'Welcome to TuxTest' |
| 46 | self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5, |
| 47 | args=args) |
| 48 | |
| 49 | @skipFlakyTest('https://gitlab.com/qemu-project/qemu/-/issues/2094') |
| 50 | def test_pc(self): |
| 51 | self.do_test_x86('pc', 'virtio-blk', 'vda') |
| 52 | |
| 53 | def test_q35(self): |
| 54 | self.do_test_x86('q35', 'ide-hd', 'sda') |
| 55 | |
| 56 | |
| 57 | if __name__ == '__main__': |
| 58 | ReplayKernelBase.main() |