master
py 69 lines 2.38 KB
Raw
1 #!/usr/bin/env python3
2 #
3 # Functional test that boots a Linux kernel and checks the console
4 #
5 # SPDX-License-Identifier: GPL-2.0-or-later
6
7 from qemu_test import LinuxKernelTest, Asset
8
9
10 class Imx8mmEvkMachine(LinuxKernelTest):
11
12 ASSET_IMAGE = Asset(
13 ('https://cloud.debian.org/images/cloud/bookworm/20231210-1590/'
14 'debian-12-generic-arm64-20231210-1590.tar.xz'),
15 '7ebf1577b32d5af6204df74b54ca2e4675de9b5a9fa14f3ff70b88eeb7b3b359')
16
17 KERNEL_OFFSET = 0x51000000
18 KERNEL_SIZE = 32622528
19 INITRD_OFFSET = 0x76000000
20 INITRD_SIZE = 30987766
21 DTB_OFFSET = 0x64DB5000
22 DTB_SIZE = 36812
23
24 def extract(self, in_path, out_path, offset, size):
25 try:
26 with open(in_path, "rb") as source:
27 source.seek(offset)
28 data = source.read(size)
29 with open(out_path, "wb") as target:
30 target.write(data)
31 except (IOError, ValueError) as e:
32 self.log.error(f"Failed to extract {out_path}: {e}")
33 raise
34
35 def setUp(self):
36 super().setUp()
37
38 self.image_path = self.scratch_file("disk.raw")
39 self.kernel_path = self.scratch_file("linux")
40 self.initrd_path = self.scratch_file("initrd.zstd")
41 self.dtb_path = self.scratch_file("imx8mm-evk.dtb")
42
43 self.archive_extract(self.ASSET_IMAGE)
44 self.extract(self.image_path, self.kernel_path,
45 self.KERNEL_OFFSET, self.KERNEL_SIZE)
46 self.extract(self.image_path, self.initrd_path,
47 self.INITRD_OFFSET, self.INITRD_SIZE)
48 self.extract(self.image_path, self.dtb_path,
49 self.DTB_OFFSET, self.DTB_SIZE)
50
51 def test_aarch64_imx8mm_evk_usdhc(self):
52 self.require_accelerator("tcg")
53 self.set_machine('imx8mm-evk')
54 self.vm.set_console(console_index=1)
55 self.vm.add_args('-m', '2G',
56 '-smp', '4',
57 '-kernel', self.kernel_path,
58 '-initrd', self.initrd_path,
59 '-dtb', self.dtb_path,
60 '-append', 'root=/dev/mmcblk2p1',
61 '-drive', f'file={self.image_path},if=sd,bus=2,'
62 'format=raw,id=mmcblk2,snapshot=on')
63
64 self.vm.launch()
65 self.wait_for_console_pattern('Welcome to ')
66
67
68 if __name__ == '__main__':
69 LinuxKernelTest.main()