master
py 144 lines 6.21 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, exec_command_and_wait_for_pattern
8 from qemu_test import interrupt_interactive_console_until_pattern
9 from qemu_test import skipBigDataTest
10 from qemu_test.utils import image_pow2ceil_expand
11
12
13 class CubieboardMachine(LinuxKernelTest):
14
15 ASSET_DEB = Asset(
16 ('https://apt.armbian.com/pool/main/l/linux-6.6.16/'
17 'linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb'),
18 '3d968c15b121ede871dce49d13ee7644d6f74b6b121b84c9a40f51b0c80d6d22')
19
20 ASSET_INITRD = Asset(
21 ('https://github.com/groeck/linux-build-test/raw/'
22 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
23 'arm/rootfs-armv5.cpio.gz'),
24 '334b8d256db67a3f2b3ad070aa08b5ade39624e0e7e35b02f4359a577bc8f39b')
25
26 ASSET_SATA_ROOTFS = Asset(
27 ('https://github.com/groeck/linux-build-test/raw/'
28 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
29 'arm/rootfs-armv5.ext2.gz'),
30 '17fc750da568580b39372133051ef2f0a963c0c0b369b845614442d025701745')
31
32 ASSET_OPENWRT = Asset(
33 ('https://downloads.openwrt.org/releases/22.03.2/targets/sunxi/cortexa8/'
34 'openwrt-22.03.2-sunxi-cortexa8-cubietech_a10-cubieboard-ext4-sdcard.img.gz'),
35 '94b5ecbfbc0b3b56276e5146b899eafa2ac5dc2d08733d6705af9f144f39f554')
36
37 def test_arm_cubieboard_initrd(self):
38 self.set_machine('cubieboard')
39 kernel_path = self.archive_extract(
40 self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
41 dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/' +
42 'sun4i-a10-cubieboard.dtb')
43 dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
44 initrd_path = self.uncompress(self.ASSET_INITRD)
45
46 self.vm.set_console()
47 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
48 'console=ttyS0,115200 '
49 'usbcore.nousb '
50 'panic=-1 noreboot')
51 self.vm.add_args('-kernel', kernel_path,
52 '-dtb', dtb_path,
53 '-initrd', initrd_path,
54 '-append', kernel_command_line,
55 '-no-reboot')
56 self.vm.launch()
57 self.wait_for_console_pattern('Boot successful.')
58
59 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
60 'Allwinner sun4i/sun5i')
61 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
62 'system-control@1c00000')
63 exec_command_and_wait_for_pattern(self, 'reboot',
64 'reboot: Restarting system')
65 # Wait for VM to shut down gracefully
66 self.vm.wait()
67
68 def test_arm_cubieboard_sata(self):
69 self.set_machine('cubieboard')
70 kernel_path = self.archive_extract(
71 self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
72 dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/' +
73 'sun4i-a10-cubieboard.dtb')
74 dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
75
76 rootfs_path = self.uncompress(self.ASSET_SATA_ROOTFS)
77
78 self.vm.set_console()
79 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
80 'console=ttyS0,115200 '
81 'usbcore.nousb '
82 'root=/dev/sda ro '
83 'panic=-1 noreboot')
84 self.vm.add_args('-kernel', kernel_path,
85 '-dtb', dtb_path,
86 '-drive', 'if=none,format=raw,id=disk0,file='
87 + rootfs_path,
88 '-device', 'ide-hd,bus=ide.0,drive=disk0',
89 '-append', kernel_command_line,
90 '-no-reboot')
91 self.vm.launch()
92 self.wait_for_console_pattern('Boot successful.')
93
94 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
95 'Allwinner sun4i/sun5i')
96 exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
97 'sda')
98 exec_command_and_wait_for_pattern(self, 'reboot',
99 'reboot: Restarting system')
100 # Wait for VM to shut down gracefully
101 self.vm.wait()
102
103 @skipBigDataTest()
104 def test_arm_cubieboard_openwrt_22_03_2(self):
105 # This test download a 7.5 MiB compressed image and expand it
106 # to 126 MiB.
107 self.set_machine('cubieboard')
108 self.require_netdev('user')
109
110 image_path = self.uncompress(self.ASSET_OPENWRT)
111 image_pow2ceil_expand(image_path)
112
113 self.vm.set_console()
114 self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
115 '-nic', 'user',
116 '-no-reboot')
117 self.vm.launch()
118
119 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
120 'usbcore.nousb '
121 'noreboot')
122
123 self.wait_for_console_pattern('U-Boot SPL')
124
125 interrupt_interactive_console_until_pattern(
126 self, 'Hit any key to stop autoboot:', '=>')
127 exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
128 kernel_command_line + "'", '=>')
129 exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...')
130
131 self.wait_for_console_pattern(
132 'Please press Enter to activate this console.')
133
134 exec_command_and_wait_for_pattern(self, ' ', 'root@')
135
136 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
137 'Allwinner sun4i/sun5i')
138 exec_command_and_wait_for_pattern(self, 'reboot',
139 'reboot: Restarting system')
140 # Wait for VM to shut down gracefully
141 self.vm.wait()
142
143 if __name__ == '__main__':
144 LinuxKernelTest.main()