tests/avocado: Introduce file_truncate()
[qemu/kevin.git] / tests / avocado / boot_linux_console.py
blob13e66886243460368bd7db894466508c889a75d3
1 # Functional test that boots a Linux kernel and checks the console
3 # Copyright (c) 2018 Red Hat, Inc.
5 # Author:
6 # Cleber Rosa <crosa@redhat.com>
8 # This work is licensed under the terms of the GNU GPL, version 2 or
9 # later. See the COPYING file in the top-level directory.
11 import os
12 import lzma
13 import gzip
14 import shutil
16 from avocado import skip
17 from avocado import skipUnless
18 from avocado import skipIf
19 from avocado_qemu import QemuSystemTest
20 from avocado_qemu import exec_command
21 from avocado_qemu import exec_command_and_wait_for_pattern
22 from avocado_qemu import interrupt_interactive_console_until_pattern
23 from avocado_qemu import wait_for_console_pattern
24 from avocado.utils import process
25 from avocado.utils import archive
27 """
28 Round up to next power of 2
29 """
30 def pow2ceil(x):
31 return 1 if x == 0 else 2**(x - 1).bit_length()
33 def file_truncate(path, size):
34 if size != os.path.getsize(path):
35 with open(path, 'ab+') as fd:
36 fd.truncate(size)
38 """
39 Expand file size to next power of 2
40 """
41 def image_pow2ceil_expand(path):
42 size = os.path.getsize(path)
43 size_aligned = pow2ceil(size)
44 if size != size_aligned:
45 with open(path, 'ab+') as fd:
46 fd.truncate(size_aligned)
48 class LinuxKernelTest(QemuSystemTest):
49 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
51 def wait_for_console_pattern(self, success_message, vm=None):
52 wait_for_console_pattern(self, success_message,
53 failure_message='Kernel panic - not syncing',
54 vm=vm)
56 def extract_from_deb(self, deb, path):
57 """
58 Extracts a file from a deb package into the test workdir
60 :param deb: path to the deb archive
61 :param path: path within the deb archive of the file to be extracted
62 :returns: path of the extracted file
63 """
64 cwd = os.getcwd()
65 os.chdir(self.workdir)
66 file_path = process.run("ar t %s" % deb).stdout_text.split()[2]
67 process.run("ar x %s %s" % (deb, file_path))
68 archive.extract(file_path, self.workdir)
69 os.chdir(cwd)
70 # Return complete path to extracted file. Because callers to
71 # extract_from_deb() specify 'path' with a leading slash, it is
72 # necessary to use os.path.relpath() as otherwise os.path.join()
73 # interprets it as an absolute path and drops the self.workdir part.
74 return os.path.normpath(os.path.join(self.workdir,
75 os.path.relpath(path, '/')))
77 def extract_from_rpm(self, rpm, path):
78 """
79 Extracts a file from an RPM package into the test workdir.
81 :param rpm: path to the rpm archive
82 :param path: path within the rpm archive of the file to be extracted
83 needs to be a relative path (starting with './') because
84 cpio(1), which is used to extract the file, expects that.
85 :returns: path of the extracted file
86 """
87 cwd = os.getcwd()
88 os.chdir(self.workdir)
89 process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True)
90 os.chdir(cwd)
91 return os.path.normpath(os.path.join(self.workdir, path))
93 class BootLinuxConsole(LinuxKernelTest):
94 """
95 Boots a Linux kernel and checks that the console is operational and the
96 kernel command line is properly passed from QEMU to the kernel
97 """
98 timeout = 90
100 def test_x86_64_pc(self):
102 :avocado: tags=arch:x86_64
103 :avocado: tags=machine:pc
105 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
106 '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
107 '/vmlinuz')
108 kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
109 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
111 self.vm.set_console()
112 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
113 self.vm.add_args('-kernel', kernel_path,
114 '-append', kernel_command_line)
115 self.vm.launch()
116 console_pattern = 'Kernel command line: %s' % kernel_command_line
117 self.wait_for_console_pattern(console_pattern)
119 def test_mips_malta(self):
121 :avocado: tags=arch:mips
122 :avocado: tags=machine:malta
123 :avocado: tags=endian:big
125 deb_url = ('http://snapshot.debian.org/archive/debian/'
126 '20130217T032700Z/pool/main/l/linux-2.6/'
127 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
128 deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
129 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
130 kernel_path = self.extract_from_deb(deb_path,
131 '/boot/vmlinux-2.6.32-5-4kc-malta')
133 self.vm.set_console()
134 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
135 self.vm.add_args('-kernel', kernel_path,
136 '-append', kernel_command_line)
137 self.vm.launch()
138 console_pattern = 'Kernel command line: %s' % kernel_command_line
139 self.wait_for_console_pattern(console_pattern)
141 def test_mips64el_malta(self):
143 This test requires the ar tool to extract "data.tar.gz" from
144 the Debian package.
146 The kernel can be rebuilt using this Debian kernel source [1] and
147 following the instructions on [2].
149 [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
150 #linux-source-2.6.32_2.6.32-48
151 [2] https://kernel-team.pages.debian.net/kernel-handbook/
152 ch-common-tasks.html#s-common-official
154 :avocado: tags=arch:mips64el
155 :avocado: tags=machine:malta
157 deb_url = ('http://snapshot.debian.org/archive/debian/'
158 '20130217T032700Z/pool/main/l/linux-2.6/'
159 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
160 deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
161 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
162 kernel_path = self.extract_from_deb(deb_path,
163 '/boot/vmlinux-2.6.32-5-5kc-malta')
165 self.vm.set_console()
166 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
167 self.vm.add_args('-kernel', kernel_path,
168 '-append', kernel_command_line)
169 self.vm.launch()
170 console_pattern = 'Kernel command line: %s' % kernel_command_line
171 self.wait_for_console_pattern(console_pattern)
173 def test_mips64el_fuloong2e(self):
175 :avocado: tags=arch:mips64el
176 :avocado: tags=machine:fuloong2e
177 :avocado: tags=endian:little
179 deb_url = ('http://archive.debian.org/debian/pool/main/l/linux/'
180 'linux-image-3.16.0-6-loongson-2e_3.16.56-1+deb8u1_mipsel.deb')
181 deb_hash = 'd04d446045deecf7b755ef576551de0c4184dd44'
182 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
183 kernel_path = self.extract_from_deb(deb_path,
184 '/boot/vmlinux-3.16.0-6-loongson-2e')
186 self.vm.set_console()
187 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
188 self.vm.add_args('-kernel', kernel_path,
189 '-append', kernel_command_line)
190 self.vm.launch()
191 console_pattern = 'Kernel command line: %s' % kernel_command_line
192 self.wait_for_console_pattern(console_pattern)
194 def test_mips_malta_cpio(self):
196 :avocado: tags=arch:mips
197 :avocado: tags=machine:malta
198 :avocado: tags=endian:big
200 deb_url = ('http://snapshot.debian.org/archive/debian/'
201 '20160601T041800Z/pool/main/l/linux/'
202 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
203 deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
204 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
205 kernel_path = self.extract_from_deb(deb_path,
206 '/boot/vmlinux-4.5.0-2-4kc-malta')
207 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
208 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
209 'mips/rootfs.cpio.gz')
210 initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
211 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
212 initrd_path = self.workdir + "rootfs.cpio"
213 archive.gzip_uncompress(initrd_path_gz, initrd_path)
215 self.vm.set_console()
216 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
217 + 'console=ttyS0 console=tty '
218 + 'rdinit=/sbin/init noreboot')
219 self.vm.add_args('-kernel', kernel_path,
220 '-initrd', initrd_path,
221 '-append', kernel_command_line,
222 '-no-reboot')
223 self.vm.launch()
224 self.wait_for_console_pattern('Boot successful.')
226 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
227 'BogoMIPS')
228 exec_command_and_wait_for_pattern(self, 'uname -a',
229 'Debian')
230 exec_command_and_wait_for_pattern(self, 'reboot',
231 'reboot: Restarting system')
232 # Wait for VM to shut down gracefully
233 self.vm.wait()
235 @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
236 def test_mips64el_malta_5KEc_cpio(self):
238 :avocado: tags=arch:mips64el
239 :avocado: tags=machine:malta
240 :avocado: tags=endian:little
241 :avocado: tags=cpu:5KEc
243 kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
244 'raw/9ad2df38/mips/malta/mips64el/'
245 'vmlinux-3.19.3.mtoman.20150408')
246 kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
247 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
248 initrd_url = ('https://github.com/groeck/linux-build-test/'
249 'raw/8584a59e/rootfs/'
250 'mipsel64/rootfs.mipsel64r1.cpio.gz')
251 initrd_hash = '1dbb8a396e916847325284dbe2151167'
252 initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5',
253 asset_hash=initrd_hash)
254 initrd_path = self.workdir + "rootfs.cpio"
255 archive.gzip_uncompress(initrd_path_gz, initrd_path)
257 self.vm.set_console()
258 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
259 + 'console=ttyS0 console=tty '
260 + 'rdinit=/sbin/init noreboot')
261 self.vm.add_args('-kernel', kernel_path,
262 '-initrd', initrd_path,
263 '-append', kernel_command_line,
264 '-no-reboot')
265 self.vm.launch()
266 wait_for_console_pattern(self, 'Boot successful.')
268 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
269 'MIPS 5KE')
270 exec_command_and_wait_for_pattern(self, 'uname -a',
271 '3.19.3.mtoman.20150408')
272 exec_command_and_wait_for_pattern(self, 'reboot',
273 'reboot: Restarting system')
274 # Wait for VM to shut down gracefully
275 self.vm.wait()
277 def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
278 kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
279 kernel_path = self.workdir + "kernel"
280 with lzma.open(kernel_path_xz, 'rb') as f_in:
281 with open(kernel_path, 'wb') as f_out:
282 shutil.copyfileobj(f_in, f_out)
284 self.vm.set_console()
285 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
286 + 'mem=256m@@0x0 '
287 + 'console=ttyS0')
288 self.vm.add_args('-no-reboot',
289 '-kernel', kernel_path,
290 '-append', kernel_command_line)
291 self.vm.launch()
292 console_pattern = 'Kernel command line: %s' % kernel_command_line
293 self.wait_for_console_pattern(console_pattern)
295 def test_mips_malta32el_nanomips_4k(self):
297 :avocado: tags=arch:mipsel
298 :avocado: tags=machine:malta
299 :avocado: tags=endian:little
300 :avocado: tags=cpu:I7200
302 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
303 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
304 'generic_nano32r6el_page4k.xz')
305 kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6'
306 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
308 def test_mips_malta32el_nanomips_16k_up(self):
310 :avocado: tags=arch:mipsel
311 :avocado: tags=machine:malta
312 :avocado: tags=endian:little
313 :avocado: tags=cpu:I7200
315 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
316 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
317 'generic_nano32r6el_page16k_up.xz')
318 kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc'
319 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
321 def test_mips_malta32el_nanomips_64k_dbg(self):
323 :avocado: tags=arch:mipsel
324 :avocado: tags=machine:malta
325 :avocado: tags=endian:little
326 :avocado: tags=cpu:I7200
328 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
329 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
330 'generic_nano32r6el_page64k_dbg.xz')
331 kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
332 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
334 def test_aarch64_xlnx_versal_virt(self):
336 :avocado: tags=arch:aarch64
337 :avocado: tags=machine:xlnx-versal-virt
338 :avocado: tags=device:pl011
339 :avocado: tags=device:arm_gicv3
340 :avocado: tags=accel:tcg
342 images_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/'
343 'bionic-updates/main/installer-arm64/'
344 '20101020ubuntu543.19/images/')
345 kernel_url = images_url + 'netboot/ubuntu-installer/arm64/linux'
346 kernel_hash = 'e167757620640eb26de0972f578741924abb3a82'
347 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
349 initrd_url = images_url + 'netboot/ubuntu-installer/arm64/initrd.gz'
350 initrd_hash = 'cab5cb3fcefca8408aa5aae57f24574bfce8bdb9'
351 initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
353 self.vm.set_console()
354 self.vm.add_args('-m', '2G',
355 '-accel', 'tcg',
356 '-kernel', kernel_path,
357 '-initrd', initrd_path)
358 self.vm.launch()
359 self.wait_for_console_pattern('Checked W+X mappings: passed')
361 def test_arm_virt(self):
363 :avocado: tags=arch:arm
364 :avocado: tags=machine:virt
365 :avocado: tags=accel:tcg
367 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
368 '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
369 '/vmlinuz')
370 kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
371 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
373 self.vm.set_console()
374 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
375 'console=ttyAMA0')
376 self.vm.add_args('-kernel', kernel_path,
377 '-append', kernel_command_line)
378 self.vm.launch()
379 console_pattern = 'Kernel command line: %s' % kernel_command_line
380 self.wait_for_console_pattern(console_pattern)
382 def test_arm_emcraft_sf2(self):
384 :avocado: tags=arch:arm
385 :avocado: tags=machine:emcraft-sf2
386 :avocado: tags=endian:little
387 :avocado: tags=u-boot
388 :avocado: tags=accel:tcg
390 self.require_netdev('user')
392 uboot_url = ('https://raw.githubusercontent.com/'
393 'Subbaraya-Sundeep/qemu-test-binaries/'
394 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot')
395 uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2'
396 uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash)
397 spi_url = ('https://raw.githubusercontent.com/'
398 'Subbaraya-Sundeep/qemu-test-binaries/'
399 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin')
400 spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501'
401 spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
403 self.vm.set_console()
404 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
405 self.vm.add_args('-kernel', uboot_path,
406 '-append', kernel_command_line,
407 '-drive', 'file=' + spi_path + ',if=mtd,format=raw',
408 '-no-reboot')
409 self.vm.launch()
410 self.wait_for_console_pattern('Enter \'help\' for a list')
412 exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15',
413 'eth0: link becomes ready')
414 exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
415 '3 packets transmitted, 3 packets received, 0% packet loss')
417 def do_test_arm_raspi2(self, uart_id):
419 :avocado: tags=accel:tcg
421 The kernel can be rebuilt using the kernel source referenced
422 and following the instructions on the on:
423 https://www.raspberrypi.org/documentation/linux/kernel/building.md
425 serial_kernel_cmdline = {
426 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
428 deb_url = ('http://archive.raspberrypi.org/debian/'
429 'pool/main/r/raspberrypi-firmware/'
430 'raspberrypi-kernel_1.20190215-1_armhf.deb')
431 deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
432 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
433 kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
434 dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
436 self.vm.set_console()
437 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
438 serial_kernel_cmdline[uart_id] +
439 ' root=/dev/mmcblk0p2 rootwait ' +
440 'dwc_otg.fiq_fsm_enable=0')
441 self.vm.add_args('-kernel', kernel_path,
442 '-dtb', dtb_path,
443 '-append', kernel_command_line,
444 '-device', 'usb-kbd')
445 self.vm.launch()
446 console_pattern = 'Kernel command line: %s' % kernel_command_line
447 self.wait_for_console_pattern(console_pattern)
448 console_pattern = 'Product: QEMU USB Keyboard'
449 self.wait_for_console_pattern(console_pattern)
451 def test_arm_raspi2_uart0(self):
453 :avocado: tags=arch:arm
454 :avocado: tags=machine:raspi2b
455 :avocado: tags=device:pl011
456 :avocado: tags=accel:tcg
458 self.do_test_arm_raspi2(0)
460 def test_arm_raspi2_initrd(self):
462 :avocado: tags=arch:arm
463 :avocado: tags=machine:raspi2b
465 deb_url = ('http://archive.raspberrypi.org/debian/'
466 'pool/main/r/raspberrypi-firmware/'
467 'raspberrypi-kernel_1.20190215-1_armhf.deb')
468 deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
469 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
470 kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
471 dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
473 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
474 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
475 'arm/rootfs-armv7a.cpio.gz')
476 initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
477 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
478 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
479 archive.gzip_uncompress(initrd_path_gz, initrd_path)
481 self.vm.set_console()
482 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
483 'earlycon=pl011,0x3f201000 console=ttyAMA0 '
484 'panic=-1 noreboot ' +
485 'dwc_otg.fiq_fsm_enable=0')
486 self.vm.add_args('-kernel', kernel_path,
487 '-dtb', dtb_path,
488 '-initrd', initrd_path,
489 '-append', kernel_command_line,
490 '-no-reboot')
491 self.vm.launch()
492 self.wait_for_console_pattern('Boot successful.')
494 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
495 'BCM2835')
496 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
497 '/soc/cprman@7e101000')
498 exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System halted')
499 # Wait for VM to shut down gracefully
500 self.vm.wait()
502 def test_arm_exynos4210_initrd(self):
504 :avocado: tags=arch:arm
505 :avocado: tags=machine:smdkc210
506 :avocado: tags=accel:tcg
508 deb_url = ('https://snapshot.debian.org/archive/debian/'
509 '20190928T224601Z/pool/main/l/linux/'
510 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
511 deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
512 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
513 kernel_path = self.extract_from_deb(deb_path,
514 '/boot/vmlinuz-4.19.0-6-armmp')
515 dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
516 dtb_path = self.extract_from_deb(deb_path, dtb_path)
518 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
519 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
520 'arm/rootfs-armv5.cpio.gz')
521 initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
522 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
523 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
524 archive.gzip_uncompress(initrd_path_gz, initrd_path)
526 self.vm.set_console()
527 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
528 'earlycon=exynos4210,0x13800000 earlyprintk ' +
529 'console=ttySAC0,115200n8 ' +
530 'random.trust_cpu=off cryptomgr.notests ' +
531 'cpuidle.off=1 panic=-1 noreboot')
533 self.vm.add_args('-kernel', kernel_path,
534 '-dtb', dtb_path,
535 '-initrd', initrd_path,
536 '-append', kernel_command_line,
537 '-no-reboot')
538 self.vm.launch()
540 self.wait_for_console_pattern('Boot successful.')
541 # TODO user command, for now the uart is stuck
543 def test_arm_cubieboard_initrd(self):
545 :avocado: tags=arch:arm
546 :avocado: tags=machine:cubieboard
547 :avocado: tags=accel:tcg
549 deb_url = ('https://apt.armbian.com/pool/main/l/'
550 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
551 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
552 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
553 kernel_path = self.extract_from_deb(deb_path,
554 '/boot/vmlinuz-5.10.16-sunxi')
555 dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
556 dtb_path = self.extract_from_deb(deb_path, dtb_path)
557 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
558 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
559 'arm/rootfs-armv5.cpio.gz')
560 initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
561 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
562 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
563 archive.gzip_uncompress(initrd_path_gz, initrd_path)
565 self.vm.set_console()
566 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
567 'console=ttyS0,115200 '
568 'usbcore.nousb '
569 'panic=-1 noreboot')
570 self.vm.add_args('-kernel', kernel_path,
571 '-dtb', dtb_path,
572 '-initrd', initrd_path,
573 '-append', kernel_command_line,
574 '-no-reboot')
575 self.vm.launch()
576 self.wait_for_console_pattern('Boot successful.')
578 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
579 'Allwinner sun4i/sun5i')
580 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
581 'system-control@1c00000')
582 # cubieboard's reboot is not functioning; omit reboot test.
584 def test_arm_cubieboard_sata(self):
586 :avocado: tags=arch:arm
587 :avocado: tags=machine:cubieboard
588 :avocado: tags=accel:tcg
590 deb_url = ('https://apt.armbian.com/pool/main/l/'
591 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
592 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
593 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
594 kernel_path = self.extract_from_deb(deb_path,
595 '/boot/vmlinuz-5.10.16-sunxi')
596 dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
597 dtb_path = self.extract_from_deb(deb_path, dtb_path)
598 rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
599 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
600 'arm/rootfs-armv5.ext2.gz')
601 rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
602 rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
603 rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
604 archive.gzip_uncompress(rootfs_path_gz, rootfs_path)
606 self.vm.set_console()
607 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
608 'console=ttyS0,115200 '
609 'usbcore.nousb '
610 'root=/dev/sda ro '
611 'panic=-1 noreboot')
612 self.vm.add_args('-kernel', kernel_path,
613 '-dtb', dtb_path,
614 '-drive', 'if=none,format=raw,id=disk0,file='
615 + rootfs_path,
616 '-device', 'ide-hd,bus=ide.0,drive=disk0',
617 '-append', kernel_command_line,
618 '-no-reboot')
619 self.vm.launch()
620 self.wait_for_console_pattern('Boot successful.')
622 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
623 'Allwinner sun4i/sun5i')
624 exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
625 'sda')
626 # cubieboard's reboot is not functioning; omit reboot test.
628 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
629 def test_arm_cubieboard_openwrt_22_03_2(self):
631 :avocado: tags=arch:arm
632 :avocado: tags=machine:cubieboard
633 :avocado: tags=device:sd
636 # This test download a 7.5 MiB compressed image and expand it
637 # to 126 MiB.
638 image_url = ('https://downloads.openwrt.org/releases/22.03.2/targets/'
639 'sunxi/cortexa8/openwrt-22.03.2-sunxi-cortexa8-'
640 'cubietech_a10-cubieboard-ext4-sdcard.img.gz')
641 image_hash = ('94b5ecbfbc0b3b56276e5146b899eafa'
642 '2ac5dc2d08733d6705af9f144f39f554')
643 image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash,
644 algorithm='sha256')
645 image_path = archive.extract(image_path_gz, self.workdir)
646 image_pow2ceil_expand(image_path)
648 self.vm.set_console()
649 self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
650 '-nic', 'user',
651 '-no-reboot')
652 self.vm.launch()
654 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
655 'usbcore.nousb '
656 'noreboot')
658 self.wait_for_console_pattern('U-Boot SPL')
660 interrupt_interactive_console_until_pattern(
661 self, 'Hit any key to stop autoboot:', '=>')
662 exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
663 kernel_command_line + "'", '=>')
664 exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...');
666 self.wait_for_console_pattern(
667 'Please press Enter to activate this console.')
669 exec_command_and_wait_for_pattern(self, ' ', 'root@')
671 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
672 'Allwinner sun4i/sun5i')
673 # cubieboard's reboot is not functioning; omit reboot test.
675 @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
676 def test_arm_quanta_gsj(self):
678 :avocado: tags=arch:arm
679 :avocado: tags=machine:quanta-gsj
680 :avocado: tags=accel:tcg
682 # 25 MiB compressed, 32 MiB uncompressed.
683 image_url = (
684 'https://github.com/hskinnemoen/openbmc/releases/download/'
685 '20200711-gsj-qemu-0/obmc-phosphor-image-gsj.static.mtd.gz')
686 image_hash = '14895e634923345cb5c8776037ff7876df96f6b1'
687 image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash)
688 image_name = 'obmc.mtd'
689 image_path = os.path.join(self.workdir, image_name)
690 archive.gzip_uncompress(image_path_gz, image_path)
692 self.vm.set_console()
693 drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0'
694 self.vm.add_args('-drive', drive_args)
695 self.vm.launch()
697 # Disable drivers and services that stall for a long time during boot,
698 # to avoid running past the 90-second timeout. These may be removed
699 # as the corresponding device support is added.
700 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + (
701 'console=${console} '
702 'mem=${mem} '
703 'initcall_blacklist=npcm_i2c_bus_driver_init '
704 'systemd.mask=systemd-random-seed.service '
705 'systemd.mask=dropbearkey.service '
708 self.wait_for_console_pattern('> BootBlock by Nuvoton')
709 self.wait_for_console_pattern('>Device: Poleg BMC NPCM730')
710 self.wait_for_console_pattern('>Skip DDR init.')
711 self.wait_for_console_pattern('U-Boot ')
712 interrupt_interactive_console_until_pattern(
713 self, 'Hit any key to stop autoboot:', 'U-Boot>')
714 exec_command_and_wait_for_pattern(
715 self, "setenv bootargs ${bootargs} " + kernel_command_line,
716 'U-Boot>')
717 exec_command_and_wait_for_pattern(
718 self, 'run romboot', 'Booting Kernel from flash')
719 self.wait_for_console_pattern('Booting Linux on physical CPU 0x0')
720 self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0')
721 self.wait_for_console_pattern('OpenBMC Project Reference Distro')
722 self.wait_for_console_pattern('gsj login:')
724 def test_arm_quanta_gsj_initrd(self):
726 :avocado: tags=arch:arm
727 :avocado: tags=machine:quanta-gsj
728 :avocado: tags=accel:tcg
730 initrd_url = (
731 'https://github.com/hskinnemoen/openbmc/releases/download/'
732 '20200711-gsj-qemu-0/obmc-phosphor-initramfs-gsj.cpio.xz')
733 initrd_hash = '98fefe5d7e56727b1eb17d5c00311b1b5c945300'
734 initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
735 kernel_url = (
736 'https://github.com/hskinnemoen/openbmc/releases/download/'
737 '20200711-gsj-qemu-0/uImage-gsj.bin')
738 kernel_hash = 'fa67b2f141d56d39b3c54305c0e8a899c99eb2c7'
739 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
740 dtb_url = (
741 'https://github.com/hskinnemoen/openbmc/releases/download/'
742 '20200711-gsj-qemu-0/nuvoton-npcm730-gsj.dtb')
743 dtb_hash = '18315f7006d7b688d8312d5c727eecd819aa36a4'
744 dtb_path = self.fetch_asset(dtb_url, asset_hash=dtb_hash)
746 self.vm.set_console()
747 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
748 'console=ttyS0,115200n8 '
749 'earlycon=uart8250,mmio32,0xf0001000')
750 self.vm.add_args('-kernel', kernel_path,
751 '-initrd', initrd_path,
752 '-dtb', dtb_path,
753 '-append', kernel_command_line)
754 self.vm.launch()
756 self.wait_for_console_pattern('Booting Linux on physical CPU 0x0')
757 self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0')
758 self.wait_for_console_pattern(
759 'Give root password for system maintenance')
761 def test_arm_orangepi(self):
763 :avocado: tags=arch:arm
764 :avocado: tags=machine:orangepi-pc
765 :avocado: tags=accel:tcg
767 deb_url = ('https://apt.armbian.com/pool/main/l/'
768 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
769 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
770 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
771 kernel_path = self.extract_from_deb(deb_path,
772 '/boot/vmlinuz-5.10.16-sunxi')
773 dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
774 dtb_path = self.extract_from_deb(deb_path, dtb_path)
776 self.vm.set_console()
777 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
778 'console=ttyS0,115200n8 '
779 'earlycon=uart,mmio32,0x1c28000')
780 self.vm.add_args('-kernel', kernel_path,
781 '-dtb', dtb_path,
782 '-append', kernel_command_line)
783 self.vm.launch()
784 console_pattern = 'Kernel command line: %s' % kernel_command_line
785 self.wait_for_console_pattern(console_pattern)
787 def test_arm_orangepi_initrd(self):
789 :avocado: tags=arch:arm
790 :avocado: tags=accel:tcg
791 :avocado: tags=machine:orangepi-pc
793 deb_url = ('https://apt.armbian.com/pool/main/l/'
794 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
795 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
796 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
797 kernel_path = self.extract_from_deb(deb_path,
798 '/boot/vmlinuz-5.10.16-sunxi')
799 dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
800 dtb_path = self.extract_from_deb(deb_path, dtb_path)
801 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
802 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
803 'arm/rootfs-armv7a.cpio.gz')
804 initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
805 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
806 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
807 archive.gzip_uncompress(initrd_path_gz, initrd_path)
809 self.vm.set_console()
810 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
811 'console=ttyS0,115200 '
812 'panic=-1 noreboot')
813 self.vm.add_args('-kernel', kernel_path,
814 '-dtb', dtb_path,
815 '-initrd', initrd_path,
816 '-append', kernel_command_line,
817 '-no-reboot')
818 self.vm.launch()
819 self.wait_for_console_pattern('Boot successful.')
821 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
822 'Allwinner sun8i Family')
823 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
824 'system-control@1c00000')
825 exec_command_and_wait_for_pattern(self, 'reboot',
826 'reboot: Restarting system')
827 # Wait for VM to shut down gracefully
828 self.vm.wait()
830 def test_arm_orangepi_sd(self):
832 :avocado: tags=arch:arm
833 :avocado: tags=accel:tcg
834 :avocado: tags=machine:orangepi-pc
835 :avocado: tags=device:sd
837 self.require_netdev('user')
839 deb_url = ('https://apt.armbian.com/pool/main/l/'
840 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
841 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
842 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
843 kernel_path = self.extract_from_deb(deb_path,
844 '/boot/vmlinuz-5.10.16-sunxi')
845 dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
846 dtb_path = self.extract_from_deb(deb_path, dtb_path)
847 rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/'
848 'buildroot-baseline/20221116.0/armel/rootfs.ext2.xz')
849 rootfs_hash = 'fae32f337c7b87547b10f42599acf109da8b6d9a'
850 rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
851 rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
852 archive.lzma_uncompress(rootfs_path_xz, rootfs_path)
853 image_pow2ceil_expand(rootfs_path)
855 self.vm.set_console()
856 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
857 'console=ttyS0,115200 '
858 'root=/dev/mmcblk0 rootwait rw '
859 'panic=-1 noreboot')
860 self.vm.add_args('-kernel', kernel_path,
861 '-dtb', dtb_path,
862 '-drive', 'file=' + rootfs_path + ',if=sd,format=raw',
863 '-append', kernel_command_line,
864 '-no-reboot')
865 self.vm.launch()
866 shell_ready = "/bin/sh: can't access tty; job control turned off"
867 self.wait_for_console_pattern(shell_ready)
869 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
870 'Allwinner sun8i Family')
871 exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
872 'mmcblk0')
873 exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up',
874 'eth0: Link is Up')
875 exec_command_and_wait_for_pattern(self, 'udhcpc eth0',
876 'udhcpc: lease of 10.0.2.15 obtained')
877 exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
878 '3 packets transmitted, 3 packets received, 0% packet loss')
879 exec_command_and_wait_for_pattern(self, 'reboot',
880 'reboot: Restarting system')
881 # Wait for VM to shut down gracefully
882 self.vm.wait()
884 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
885 def test_arm_orangepi_bionic_20_08(self):
887 :avocado: tags=arch:arm
888 :avocado: tags=machine:orangepi-pc
889 :avocado: tags=device:sd
892 # This test download a 275 MiB compressed image and expand it
893 # to 1036 MiB, but the underlying filesystem is 1552 MiB...
894 # As we expand it to 2 GiB we are safe.
896 image_url = ('https://archive.armbian.com/orangepipc/archive/'
897 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
898 image_hash = ('b4d6775f5673486329e45a0586bf06b6'
899 'dbe792199fd182ac6b9c7bb6c7d3e6dd')
900 image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
901 algorithm='sha256')
902 image_path = archive.extract(image_path_xz, self.workdir)
903 image_pow2ceil_expand(image_path)
905 self.vm.set_console()
906 self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
907 '-nic', 'user',
908 '-no-reboot')
909 self.vm.launch()
911 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
912 'console=ttyS0,115200 '
913 'loglevel=7 '
914 'nosmp '
915 'systemd.default_timeout_start_sec=9000 '
916 'systemd.mask=armbian-zram-config.service '
917 'systemd.mask=armbian-ramlog.service')
919 self.wait_for_console_pattern('U-Boot SPL')
920 self.wait_for_console_pattern('Autoboot in ')
921 exec_command_and_wait_for_pattern(self, ' ', '=>')
922 exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
923 kernel_command_line + "'", '=>')
924 exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...');
926 self.wait_for_console_pattern('systemd[1]: Set hostname ' +
927 'to <orangepipc>')
928 self.wait_for_console_pattern('Starting Load Kernel Modules...')
930 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
931 def test_arm_orangepi_uboot_netbsd9(self):
933 :avocado: tags=arch:arm
934 :avocado: tags=machine:orangepi-pc
935 :avocado: tags=device:sd
936 :avocado: tags=os:netbsd
938 # This test download a 304MB compressed image and expand it to 2GB
939 deb_url = ('http://snapshot.debian.org/archive/debian/'
940 '20200108T145233Z/pool/main/u/u-boot/'
941 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
942 deb_hash = 'f67f404a80753ca3d1258f13e38f2b060e13db99'
943 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
944 # We use the common OrangePi PC 'plus' build of U-Boot for our secondary
945 # program loader (SPL). We will then set the path to the more specific
946 # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt,
947 # before to boot NetBSD.
948 uboot_path = '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin'
949 uboot_path = self.extract_from_deb(deb_path, uboot_path)
950 image_url = ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/'
951 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz')
952 image_hash = '2babb29d36d8360adcb39c09e31060945259917a'
953 image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash)
954 image_path = os.path.join(self.workdir, 'armv7.img')
955 archive.gzip_uncompress(image_path_gz, image_path)
956 image_pow2ceil_expand(image_path)
957 image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path
959 # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
960 with open(uboot_path, 'rb') as f_in:
961 with open(image_path, 'r+b') as f_out:
962 f_out.seek(8 * 1024)
963 shutil.copyfileobj(f_in, f_out)
965 self.vm.set_console()
966 self.vm.add_args('-nic', 'user',
967 '-drive', image_drive_args,
968 '-global', 'allwinner-rtc.base-year=2000',
969 '-no-reboot')
970 self.vm.launch()
971 wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1')
972 interrupt_interactive_console_until_pattern(self,
973 'Hit any key to stop autoboot:',
974 'switch to partitions #0, OK')
976 exec_command_and_wait_for_pattern(self, '', '=>')
977 cmd = 'setenv bootargs root=ld0a'
978 exec_command_and_wait_for_pattern(self, cmd, '=>')
979 cmd = 'setenv kernel netbsd-GENERIC.ub'
980 exec_command_and_wait_for_pattern(self, cmd, '=>')
981 cmd = 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb'
982 exec_command_and_wait_for_pattern(self, cmd, '=>')
983 cmd = ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; "
984 "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; "
985 "fdt addr ${fdt_addr_r}; "
986 "bootm ${kernel_addr_r} - ${fdt_addr_r}'")
987 exec_command_and_wait_for_pattern(self, cmd, '=>')
989 exec_command_and_wait_for_pattern(self, 'boot',
990 'Booting kernel from Legacy Image')
991 wait_for_console_pattern(self, 'Starting kernel ...')
992 wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)')
993 # Wait for user-space
994 wait_for_console_pattern(self, 'Starting root file system check')
996 def test_aarch64_raspi3_atf(self):
998 :avocado: tags=arch:aarch64
999 :avocado: tags=machine:raspi3b
1000 :avocado: tags=cpu:cortex-a53
1001 :avocado: tags=device:pl011
1002 :avocado: tags=atf
1004 zip_url = ('https://github.com/pbatard/RPi3/releases/download/'
1005 'v1.15/RPi3_UEFI_Firmware_v1.15.zip')
1006 zip_hash = '74b3bd0de92683cadb14e008a7575e1d0c3cafb9'
1007 zip_path = self.fetch_asset(zip_url, asset_hash=zip_hash)
1009 archive.extract(zip_path, self.workdir)
1010 efi_fd = os.path.join(self.workdir, 'RPI_EFI.fd')
1012 self.vm.set_console(console_index=1)
1013 self.vm.add_args('-nodefaults',
1014 '-device', 'loader,file=%s,force-raw=true' % efi_fd)
1015 self.vm.launch()
1016 self.wait_for_console_pattern('version UEFI Firmware v1.15')
1018 def test_s390x_s390_ccw_virtio(self):
1020 :avocado: tags=arch:s390x
1021 :avocado: tags=machine:s390-ccw-virtio
1023 kernel_url = ('https://archives.fedoraproject.org/pub/archive'
1024 '/fedora-secondary/releases/29/Everything/s390x/os/images'
1025 '/kernel.img')
1026 kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
1027 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
1029 self.vm.set_console()
1030 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
1031 self.vm.add_args('-nodefaults',
1032 '-kernel', kernel_path,
1033 '-append', kernel_command_line)
1034 self.vm.launch()
1035 console_pattern = 'Kernel command line: %s' % kernel_command_line
1036 self.wait_for_console_pattern(console_pattern)
1038 def test_alpha_clipper(self):
1040 :avocado: tags=arch:alpha
1041 :avocado: tags=machine:clipper
1043 kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
1044 'installer-alpha/20090123lenny10/images/cdrom/vmlinuz')
1045 kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
1046 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
1048 uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
1050 self.vm.set_console()
1051 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
1052 self.vm.add_args('-nodefaults',
1053 '-kernel', uncompressed_kernel,
1054 '-append', kernel_command_line)
1055 self.vm.launch()
1056 console_pattern = 'Kernel command line: %s' % kernel_command_line
1057 self.wait_for_console_pattern(console_pattern)
1059 def test_m68k_q800(self):
1061 :avocado: tags=arch:m68k
1062 :avocado: tags=machine:q800
1064 deb_url = ('https://snapshot.debian.org/archive/debian-ports'
1065 '/20191021T083923Z/pool-m68k/main'
1066 '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
1067 deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
1068 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
1069 kernel_path = self.extract_from_deb(deb_path,
1070 '/boot/vmlinux-5.3.0-1-m68k')
1072 self.vm.set_console()
1073 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
1074 'console=ttyS0 vga=off')
1075 self.vm.add_args('-kernel', kernel_path,
1076 '-append', kernel_command_line)
1077 self.vm.launch()
1078 console_pattern = 'Kernel command line: %s' % kernel_command_line
1079 self.wait_for_console_pattern(console_pattern)
1080 console_pattern = 'No filesystem could mount root'
1081 self.wait_for_console_pattern(console_pattern)
1083 def do_test_advcal_2018(self, day, tar_hash, kernel_name, console=0):
1084 tar_url = ('https://qemu-advcal.gitlab.io'
1085 '/qac-best-of-multiarch/download/day' + day + '.tar.xz')
1086 file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
1087 archive.extract(file_path, self.workdir)
1088 self.vm.set_console(console_index=console)
1089 self.vm.add_args('-kernel',
1090 self.workdir + '/day' + day + '/' + kernel_name)
1091 self.vm.launch()
1092 self.wait_for_console_pattern('QEMU advent calendar')
1094 def test_arm_vexpressa9(self):
1096 :avocado: tags=arch:arm
1097 :avocado: tags=machine:vexpress-a9
1099 tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
1100 self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb')
1101 self.do_test_advcal_2018('16', tar_hash, 'winter.zImage')
1103 def test_arm_ast2600_debian(self):
1105 :avocado: tags=arch:arm
1106 :avocado: tags=machine:tacoma-bmc
1108 deb_url = ('http://snapshot.debian.org/archive/debian/'
1109 '20210302T203551Z/'
1110 'pool/main/l/linux/'
1111 'linux-image-5.10.0-3-armmp_5.10.13-1_armhf.deb')
1112 deb_hash = 'db40d32fe39255d05482bea48d72467b67d6225bb2a2a4d6f618cb8976f1e09e'
1113 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash,
1114 algorithm='sha256')
1115 kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.10.0-3-armmp')
1116 dtb_path = self.extract_from_deb(deb_path,
1117 '/usr/lib/linux-image-5.10.0-3-armmp/aspeed-bmc-opp-tacoma.dtb')
1119 self.vm.set_console()
1120 self.vm.add_args('-kernel', kernel_path,
1121 '-dtb', dtb_path,
1122 '-net', 'nic')
1123 self.vm.launch()
1124 self.wait_for_console_pattern("Booting Linux on physical CPU 0xf00")
1125 self.wait_for_console_pattern("SMP: Total of 2 processors activated")
1126 self.wait_for_console_pattern("No filesystem could mount root")
1128 def test_m68k_mcf5208evb(self):
1130 :avocado: tags=arch:m68k
1131 :avocado: tags=machine:mcf5208evb
1133 tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
1134 self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf')
1136 def test_or1k_sim(self):
1138 :avocado: tags=arch:or1k
1139 :avocado: tags=machine:or1k-sim
1141 tar_hash = '20334cdaf386108c530ff0badaecc955693027dd'
1142 self.do_test_advcal_2018('20', tar_hash, 'vmlinux')
1144 def test_nios2_10m50(self):
1146 :avocado: tags=arch:nios2
1147 :avocado: tags=machine:10m50-ghrd
1149 tar_hash = 'e4251141726c412ac0407c5a6bceefbbff018918'
1150 self.do_test_advcal_2018('14', tar_hash, 'vmlinux.elf')
1152 def test_ppc64_e500(self):
1154 :avocado: tags=arch:ppc64
1155 :avocado: tags=machine:ppce500
1156 :avocado: tags=cpu:e5500
1157 :avocado: tags=accel:tcg
1159 self.require_accelerator("tcg")
1160 tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
1161 self.do_test_advcal_2018('19', tar_hash, 'uImage')
1163 def do_test_ppc64_powernv(self, proc):
1164 self.require_accelerator("tcg")
1165 images_url = ('https://github.com/open-power/op-build/releases/download/v2.7/')
1167 kernel_url = images_url + 'zImage.epapr'
1168 kernel_hash = '0ab237df661727e5392cee97460e8674057a883c5f74381a128fa772588d45cd'
1169 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash,
1170 algorithm='sha256')
1171 self.vm.set_console()
1172 self.vm.add_args('-kernel', kernel_path,
1173 '-append', 'console=tty0 console=hvc0',
1174 '-device', 'pcie-pci-bridge,id=bridge1,bus=pcie.1,addr=0x0',
1175 '-device', 'nvme,bus=pcie.2,addr=0x0,serial=1234',
1176 '-device', 'e1000e,bus=bridge1,addr=0x3',
1177 '-device', 'nec-usb-xhci,bus=bridge1,addr=0x2')
1178 self.vm.launch()
1180 self.wait_for_console_pattern("CPU: " + proc + " generation processor")
1181 self.wait_for_console_pattern("zImage starting: loaded")
1182 self.wait_for_console_pattern("Run /init as init process")
1183 self.wait_for_console_pattern("Creating 1 MTD partitions")
1185 def test_ppc_powernv8(self):
1187 :avocado: tags=arch:ppc64
1188 :avocado: tags=machine:powernv8
1189 :avocado: tags=accel:tcg
1191 self.do_test_ppc64_powernv('P8')
1193 def test_ppc_powernv9(self):
1195 :avocado: tags=arch:ppc64
1196 :avocado: tags=machine:powernv9
1197 :avocado: tags=accel:tcg
1199 self.do_test_ppc64_powernv('P9')
1201 def test_ppc_g3beige(self):
1203 :avocado: tags=arch:ppc
1204 :avocado: tags=machine:g3beige
1205 :avocado: tags=accel:tcg
1207 # TODO: g3beige works with kvm_pr but we don't have a
1208 # reliable way ATM (e.g. looking at /proc/modules) to detect
1209 # whether we're running kvm_hv or kvm_pr. For now let's
1210 # disable this test if we don't have TCG support.
1211 self.require_accelerator("tcg")
1212 tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
1213 self.vm.add_args('-M', 'graphics=off')
1214 self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
1216 def test_ppc_mac99(self):
1218 :avocado: tags=arch:ppc
1219 :avocado: tags=machine:mac99
1220 :avocado: tags=accel:tcg
1222 # TODO: mac99 works with kvm_pr but we don't have a
1223 # reliable way ATM (e.g. looking at /proc/modules) to detect
1224 # whether we're running kvm_hv or kvm_pr. For now let's
1225 # disable this test if we don't have TCG support.
1226 self.require_accelerator("tcg")
1227 tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
1228 self.vm.add_args('-M', 'graphics=off')
1229 self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
1231 # This test has a 6-10% failure rate on various hosts that look
1232 # like issues with a buggy kernel. As a result we don't want it
1233 # gating releases on Gitlab.
1234 @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
1235 def test_sh4_r2d(self):
1237 :avocado: tags=arch:sh4
1238 :avocado: tags=machine:r2d
1240 tar_hash = 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
1241 self.vm.add_args('-append', 'console=ttySC1')
1242 self.do_test_advcal_2018('09', tar_hash, 'zImage', console=1)
1244 def test_sparc_ss20(self):
1246 :avocado: tags=arch:sparc
1247 :avocado: tags=machine:SS-20
1249 tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
1250 self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
1252 def test_xtensa_lx60(self):
1254 :avocado: tags=arch:xtensa
1255 :avocado: tags=machine:lx60
1256 :avocado: tags=cpu:dc233c
1258 tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
1259 self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')