tests/boot_linux_console: Add a SD card test for the OrangePi PC board
[qemu/ar7.git] / tests / acceptance / boot_linux_console.py
blob0762dbe83a5e32f9c94ffd4939d7d725c293a6ab
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 skipUnless
17 from avocado_qemu import Test
18 from avocado_qemu import exec_command_and_wait_for_pattern
19 from avocado_qemu import wait_for_console_pattern
20 from avocado.utils import process
21 from avocado.utils import archive
24 class BootLinuxConsole(Test):
25 """
26 Boots a Linux kernel and checks that the console is operational and the
27 kernel command line is properly passed from QEMU to the kernel
28 """
30 timeout = 90
32 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
34 def wait_for_console_pattern(self, success_message):
35 wait_for_console_pattern(self, success_message,
36 failure_message='Kernel panic - not syncing')
38 def extract_from_deb(self, deb, path):
39 """
40 Extracts a file from a deb package into the test workdir
42 :param deb: path to the deb archive
43 :param path: path within the deb archive of the file to be extracted
44 :returns: path of the extracted file
45 """
46 cwd = os.getcwd()
47 os.chdir(self.workdir)
48 file_path = process.run("ar t %s" % deb).stdout_text.split()[2]
49 process.run("ar x %s %s" % (deb, file_path))
50 archive.extract(file_path, self.workdir)
51 os.chdir(cwd)
52 # Return complete path to extracted file. Because callers to
53 # extract_from_deb() specify 'path' with a leading slash, it is
54 # necessary to use os.path.relpath() as otherwise os.path.join()
55 # interprets it as an absolute path and drops the self.workdir part.
56 return os.path.normpath(os.path.join(self.workdir,
57 os.path.relpath(path, '/')))
59 def extract_from_rpm(self, rpm, path):
60 """
61 Extracts a file from an RPM package into the test workdir.
63 :param rpm: path to the rpm archive
64 :param path: path within the rpm archive of the file to be extracted
65 needs to be a relative path (starting with './') because
66 cpio(1), which is used to extract the file, expects that.
67 :returns: path of the extracted file
68 """
69 cwd = os.getcwd()
70 os.chdir(self.workdir)
71 process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True)
72 os.chdir(cwd)
73 return os.path.normpath(os.path.join(self.workdir, path))
75 def test_x86_64_pc(self):
76 """
77 :avocado: tags=arch:x86_64
78 :avocado: tags=machine:pc
79 """
80 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
81 '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
82 '/vmlinuz')
83 kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
84 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
86 self.vm.set_console()
87 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
88 self.vm.add_args('-kernel', kernel_path,
89 '-append', kernel_command_line)
90 self.vm.launch()
91 console_pattern = 'Kernel command line: %s' % kernel_command_line
92 self.wait_for_console_pattern(console_pattern)
94 def test_mips_malta(self):
95 """
96 :avocado: tags=arch:mips
97 :avocado: tags=machine:malta
98 :avocado: tags=endian:big
99 """
100 deb_url = ('http://snapshot.debian.org/archive/debian/'
101 '20130217T032700Z/pool/main/l/linux-2.6/'
102 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
103 deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
104 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
105 kernel_path = self.extract_from_deb(deb_path,
106 '/boot/vmlinux-2.6.32-5-4kc-malta')
108 self.vm.set_console()
109 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
110 self.vm.add_args('-kernel', kernel_path,
111 '-append', kernel_command_line)
112 self.vm.launch()
113 console_pattern = 'Kernel command line: %s' % kernel_command_line
114 self.wait_for_console_pattern(console_pattern)
116 def test_mips64el_malta(self):
118 This test requires the ar tool to extract "data.tar.gz" from
119 the Debian package.
121 The kernel can be rebuilt using this Debian kernel source [1] and
122 following the instructions on [2].
124 [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
125 #linux-source-2.6.32_2.6.32-48
126 [2] https://kernel-team.pages.debian.net/kernel-handbook/
127 ch-common-tasks.html#s-common-official
129 :avocado: tags=arch:mips64el
130 :avocado: tags=machine:malta
132 deb_url = ('http://snapshot.debian.org/archive/debian/'
133 '20130217T032700Z/pool/main/l/linux-2.6/'
134 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
135 deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
136 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
137 kernel_path = self.extract_from_deb(deb_path,
138 '/boot/vmlinux-2.6.32-5-5kc-malta')
140 self.vm.set_console()
141 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
142 self.vm.add_args('-kernel', kernel_path,
143 '-append', kernel_command_line)
144 self.vm.launch()
145 console_pattern = 'Kernel command line: %s' % kernel_command_line
146 self.wait_for_console_pattern(console_pattern)
148 def test_mips_malta_cpio(self):
150 :avocado: tags=arch:mips
151 :avocado: tags=machine:malta
152 :avocado: tags=endian:big
154 deb_url = ('http://snapshot.debian.org/archive/debian/'
155 '20160601T041800Z/pool/main/l/linux/'
156 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
157 deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
158 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
159 kernel_path = self.extract_from_deb(deb_path,
160 '/boot/vmlinux-4.5.0-2-4kc-malta')
161 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
162 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
163 'mips/rootfs.cpio.gz')
164 initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
165 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
166 initrd_path = self.workdir + "rootfs.cpio"
167 archive.gzip_uncompress(initrd_path_gz, initrd_path)
169 self.vm.set_console()
170 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
171 + 'console=ttyS0 console=tty '
172 + 'rdinit=/sbin/init noreboot')
173 self.vm.add_args('-kernel', kernel_path,
174 '-initrd', initrd_path,
175 '-append', kernel_command_line,
176 '-no-reboot')
177 self.vm.launch()
178 self.wait_for_console_pattern('Boot successful.')
180 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
181 'BogoMIPS')
182 exec_command_and_wait_for_pattern(self, 'uname -a',
183 'Debian')
184 exec_command_and_wait_for_pattern(self, 'reboot',
185 'reboot: Restarting system')
187 @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
188 def test_mips64el_malta_5KEc_cpio(self):
190 :avocado: tags=arch:mips64el
191 :avocado: tags=machine:malta
192 :avocado: tags=endian:little
194 kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
195 'raw/9ad2df38/mips/malta/mips64el/'
196 'vmlinux-3.19.3.mtoman.20150408')
197 kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
198 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
199 initrd_url = ('https://github.com/groeck/linux-build-test/'
200 'raw/8584a59e/rootfs/'
201 'mipsel64/rootfs.mipsel64r1.cpio.gz')
202 initrd_hash = '1dbb8a396e916847325284dbe2151167'
203 initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5',
204 asset_hash=initrd_hash)
205 initrd_path = self.workdir + "rootfs.cpio"
206 archive.gzip_uncompress(initrd_path_gz, initrd_path)
208 self.vm.set_console()
209 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
210 + 'console=ttyS0 console=tty '
211 + 'rdinit=/sbin/init noreboot')
212 self.vm.add_args('-cpu', '5KEc',
213 '-kernel', kernel_path,
214 '-initrd', initrd_path,
215 '-append', kernel_command_line,
216 '-no-reboot')
217 self.vm.launch()
218 wait_for_console_pattern(self, 'Boot successful.')
220 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
221 'MIPS 5KE')
222 exec_command_and_wait_for_pattern(self, 'uname -a',
223 '3.19.3.mtoman.20150408')
224 exec_command_and_wait_for_pattern(self, 'reboot',
225 'reboot: Restarting system')
227 def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
228 kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
229 kernel_path = self.workdir + "kernel"
230 with lzma.open(kernel_path_xz, 'rb') as f_in:
231 with open(kernel_path, 'wb') as f_out:
232 shutil.copyfileobj(f_in, f_out)
234 self.vm.set_console()
235 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
236 + 'mem=256m@@0x0 '
237 + 'console=ttyS0')
238 self.vm.add_args('-no-reboot',
239 '-cpu', 'I7200',
240 '-kernel', kernel_path,
241 '-append', kernel_command_line)
242 self.vm.launch()
243 console_pattern = 'Kernel command line: %s' % kernel_command_line
244 self.wait_for_console_pattern(console_pattern)
246 def test_mips_malta32el_nanomips_4k(self):
248 :avocado: tags=arch:mipsel
249 :avocado: tags=machine:malta
250 :avocado: tags=endian:little
252 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
253 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
254 'generic_nano32r6el_page4k.xz')
255 kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6'
256 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
258 def test_mips_malta32el_nanomips_16k_up(self):
260 :avocado: tags=arch:mipsel
261 :avocado: tags=machine:malta
262 :avocado: tags=endian:little
264 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
265 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
266 'generic_nano32r6el_page16k_up.xz')
267 kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc'
268 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
270 def test_mips_malta32el_nanomips_64k_dbg(self):
272 :avocado: tags=arch:mipsel
273 :avocado: tags=machine:malta
274 :avocado: tags=endian:little
276 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
277 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
278 'generic_nano32r6el_page64k_dbg.xz')
279 kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
280 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
282 def test_aarch64_virt(self):
284 :avocado: tags=arch:aarch64
285 :avocado: tags=machine:virt
287 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
288 '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
289 '/vmlinuz')
290 kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
291 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
293 self.vm.set_console()
294 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
295 'console=ttyAMA0')
296 self.vm.add_args('-cpu', 'cortex-a53',
297 '-kernel', kernel_path,
298 '-append', kernel_command_line)
299 self.vm.launch()
300 console_pattern = 'Kernel command line: %s' % kernel_command_line
301 self.wait_for_console_pattern(console_pattern)
303 def test_arm_virt(self):
305 :avocado: tags=arch:arm
306 :avocado: tags=machine:virt
308 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
309 '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
310 '/vmlinuz')
311 kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
312 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
314 self.vm.set_console()
315 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
316 'console=ttyAMA0')
317 self.vm.add_args('-kernel', kernel_path,
318 '-append', kernel_command_line)
319 self.vm.launch()
320 console_pattern = 'Kernel command line: %s' % kernel_command_line
321 self.wait_for_console_pattern(console_pattern)
323 def test_arm_emcraft_sf2(self):
325 :avocado: tags=arch:arm
326 :avocado: tags=machine:emcraft-sf2
327 :avocado: tags=endian:little
328 :avocado: tags=u-boot
330 uboot_url = ('https://raw.githubusercontent.com/'
331 'Subbaraya-Sundeep/qemu-test-binaries/'
332 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/u-boot')
333 uboot_hash = 'abba5d9c24cdd2d49cdc2a8aa92976cf20737eff'
334 uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash)
335 spi_url = ('https://raw.githubusercontent.com/'
336 'Subbaraya-Sundeep/qemu-test-binaries/'
337 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/spi.bin')
338 spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a'
339 spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
341 self.vm.set_console()
342 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
343 self.vm.add_args('-kernel', uboot_path,
344 '-append', kernel_command_line,
345 '-drive', 'file=' + spi_path + ',if=mtd,format=raw',
346 '-no-reboot')
347 self.vm.launch()
348 self.wait_for_console_pattern('init started: BusyBox')
350 def do_test_arm_raspi2(self, uart_id):
352 The kernel can be rebuilt using the kernel source referenced
353 and following the instructions on the on:
354 https://www.raspberrypi.org/documentation/linux/kernel/building.md
356 serial_kernel_cmdline = {
357 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
359 deb_url = ('http://archive.raspberrypi.org/debian/'
360 'pool/main/r/raspberrypi-firmware/'
361 'raspberrypi-kernel_1.20190215-1_armhf.deb')
362 deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
363 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
364 kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
365 dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
367 self.vm.set_console()
368 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
369 serial_kernel_cmdline[uart_id])
370 self.vm.add_args('-kernel', kernel_path,
371 '-dtb', dtb_path,
372 '-append', kernel_command_line)
373 self.vm.launch()
374 console_pattern = 'Kernel command line: %s' % kernel_command_line
375 self.wait_for_console_pattern(console_pattern)
377 def test_arm_raspi2_uart0(self):
379 :avocado: tags=arch:arm
380 :avocado: tags=machine:raspi2
381 :avocado: tags=device:pl011
383 self.do_test_arm_raspi2(0)
385 def test_arm_exynos4210_initrd(self):
387 :avocado: tags=arch:arm
388 :avocado: tags=machine:smdkc210
390 deb_url = ('https://snapshot.debian.org/archive/debian/'
391 '20190928T224601Z/pool/main/l/linux/'
392 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
393 deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
394 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
395 kernel_path = self.extract_from_deb(deb_path,
396 '/boot/vmlinuz-4.19.0-6-armmp')
397 dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
398 dtb_path = self.extract_from_deb(deb_path, dtb_path)
400 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
401 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
402 'arm/rootfs-armv5.cpio.gz')
403 initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
404 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
405 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
406 archive.gzip_uncompress(initrd_path_gz, initrd_path)
408 self.vm.set_console()
409 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
410 'earlycon=exynos4210,0x13800000 earlyprintk ' +
411 'console=ttySAC0,115200n8 ' +
412 'random.trust_cpu=off cryptomgr.notests ' +
413 'cpuidle.off=1 panic=-1 noreboot')
415 self.vm.add_args('-kernel', kernel_path,
416 '-dtb', dtb_path,
417 '-initrd', initrd_path,
418 '-append', kernel_command_line,
419 '-no-reboot')
420 self.vm.launch()
422 self.wait_for_console_pattern('Boot successful.')
423 # TODO user command, for now the uart is stuck
425 def test_arm_cubieboard_initrd(self):
427 :avocado: tags=arch:arm
428 :avocado: tags=machine:cubieboard
430 deb_url = ('https://apt.armbian.com/pool/main/l/'
431 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
432 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
433 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
434 kernel_path = self.extract_from_deb(deb_path,
435 '/boot/vmlinuz-4.20.7-sunxi')
436 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
437 dtb_path = self.extract_from_deb(deb_path, dtb_path)
438 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
439 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
440 'arm/rootfs-armv5.cpio.gz')
441 initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
442 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
443 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
444 archive.gzip_uncompress(initrd_path_gz, initrd_path)
446 self.vm.set_console()
447 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
448 'console=ttyS0,115200 '
449 'usbcore.nousb '
450 'panic=-1 noreboot')
451 self.vm.add_args('-kernel', kernel_path,
452 '-dtb', dtb_path,
453 '-initrd', initrd_path,
454 '-append', kernel_command_line,
455 '-no-reboot')
456 self.vm.launch()
457 self.wait_for_console_pattern('Boot successful.')
459 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
460 'Allwinner sun4i/sun5i')
461 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
462 'system-control@1c00000')
463 exec_command_and_wait_for_pattern(self, 'reboot',
464 'reboot: Restarting system')
466 def test_arm_cubieboard_sata(self):
468 :avocado: tags=arch:arm
469 :avocado: tags=machine:cubieboard
471 deb_url = ('https://apt.armbian.com/pool/main/l/'
472 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
473 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
474 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
475 kernel_path = self.extract_from_deb(deb_path,
476 '/boot/vmlinuz-4.20.7-sunxi')
477 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
478 dtb_path = self.extract_from_deb(deb_path, dtb_path)
479 rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
480 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
481 'arm/rootfs-armv5.ext2.gz')
482 rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
483 rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
484 rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
485 archive.gzip_uncompress(rootfs_path_gz, rootfs_path)
487 self.vm.set_console()
488 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
489 'console=ttyS0,115200 '
490 'usbcore.nousb '
491 'root=/dev/sda ro '
492 'panic=-1 noreboot')
493 self.vm.add_args('-kernel', kernel_path,
494 '-dtb', dtb_path,
495 '-drive', 'if=none,format=raw,id=disk0,file='
496 + rootfs_path,
497 '-device', 'ide-hd,bus=ide.0,drive=disk0',
498 '-append', kernel_command_line,
499 '-no-reboot')
500 self.vm.launch()
501 self.wait_for_console_pattern('Boot successful.')
503 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
504 'Allwinner sun4i/sun5i')
505 exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
506 'sda')
507 exec_command_and_wait_for_pattern(self, 'reboot',
508 'reboot: Restarting system')
510 def test_arm_orangepi(self):
512 :avocado: tags=arch:arm
513 :avocado: tags=machine:orangepi-pc
515 deb_url = ('https://apt.armbian.com/pool/main/l/'
516 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
517 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
518 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
519 kernel_path = self.extract_from_deb(deb_path,
520 '/boot/vmlinuz-4.20.7-sunxi')
521 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
522 dtb_path = self.extract_from_deb(deb_path, dtb_path)
524 self.vm.set_console()
525 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
526 'console=ttyS0,115200n8 '
527 'earlycon=uart,mmio32,0x1c28000')
528 self.vm.add_args('-kernel', kernel_path,
529 '-dtb', dtb_path,
530 '-append', kernel_command_line)
531 self.vm.launch()
532 console_pattern = 'Kernel command line: %s' % kernel_command_line
533 self.wait_for_console_pattern(console_pattern)
535 def test_arm_orangepi_initrd(self):
537 :avocado: tags=arch:arm
538 :avocado: tags=machine:orangepi-pc
540 deb_url = ('https://apt.armbian.com/pool/main/l/'
541 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
542 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
543 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
544 kernel_path = self.extract_from_deb(deb_path,
545 '/boot/vmlinuz-4.20.7-sunxi')
546 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
547 dtb_path = self.extract_from_deb(deb_path, dtb_path)
548 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
549 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
550 'arm/rootfs-armv7a.cpio.gz')
551 initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
552 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
553 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
554 archive.gzip_uncompress(initrd_path_gz, initrd_path)
556 self.vm.set_console()
557 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
558 'console=ttyS0,115200 '
559 'panic=-1 noreboot')
560 self.vm.add_args('-kernel', kernel_path,
561 '-dtb', dtb_path,
562 '-initrd', initrd_path,
563 '-append', kernel_command_line,
564 '-no-reboot')
565 self.vm.launch()
566 self.wait_for_console_pattern('Boot successful.')
568 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
569 'Allwinner sun8i Family')
570 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
571 'system-control@1c00000')
572 exec_command_and_wait_for_pattern(self, 'reboot',
573 'reboot: Restarting system')
575 def test_arm_orangepi_sd(self):
577 :avocado: tags=arch:arm
578 :avocado: tags=machine:orangepi-pc
580 deb_url = ('https://apt.armbian.com/pool/main/l/'
581 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
582 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
583 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
584 kernel_path = self.extract_from_deb(deb_path,
585 '/boot/vmlinuz-4.20.7-sunxi')
586 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
587 dtb_path = self.extract_from_deb(deb_path, dtb_path)
588 rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/'
589 'kci-2019.02/armel/base/rootfs.ext2.xz')
590 rootfs_hash = '692510cb625efda31640d1de0a8d60e26040f061'
591 rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
592 rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
593 archive.lzma_uncompress(rootfs_path_xz, rootfs_path)
595 self.vm.set_console()
596 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
597 'console=ttyS0,115200 '
598 'root=/dev/mmcblk0 rootwait rw '
599 'panic=-1 noreboot')
600 self.vm.add_args('-kernel', kernel_path,
601 '-dtb', dtb_path,
602 '-drive', 'file=' + rootfs_path + ',if=sd,format=raw',
603 '-append', kernel_command_line,
604 '-no-reboot')
605 self.vm.launch()
606 shell_ready = "/bin/sh: can't access tty; job control turned off"
607 self.wait_for_console_pattern(shell_ready)
609 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
610 'Allwinner sun8i Family')
611 exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
612 'mmcblk0')
613 exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up',
614 'eth0: Link is Up')
615 exec_command_and_wait_for_pattern(self, 'udhcpc eth0',
616 'udhcpc: lease of 10.0.2.15 obtained')
617 exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
618 '3 packets transmitted, 3 packets received, 0% packet loss')
619 exec_command_and_wait_for_pattern(self, 'reboot',
620 'reboot: Restarting system')
622 def test_s390x_s390_ccw_virtio(self):
624 :avocado: tags=arch:s390x
625 :avocado: tags=machine:s390-ccw-virtio
627 kernel_url = ('https://archives.fedoraproject.org/pub/archive'
628 '/fedora-secondary/releases/29/Everything/s390x/os/images'
629 '/kernel.img')
630 kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
631 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
633 self.vm.set_console()
634 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
635 self.vm.add_args('-nodefaults',
636 '-kernel', kernel_path,
637 '-append', kernel_command_line)
638 self.vm.launch()
639 console_pattern = 'Kernel command line: %s' % kernel_command_line
640 self.wait_for_console_pattern(console_pattern)
642 def test_alpha_clipper(self):
644 :avocado: tags=arch:alpha
645 :avocado: tags=machine:clipper
647 kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
648 'installer-alpha/current/images/cdrom/vmlinuz')
649 kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
650 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
652 uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
654 self.vm.set_console()
655 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
656 self.vm.add_args('-nodefaults',
657 '-kernel', uncompressed_kernel,
658 '-append', kernel_command_line)
659 self.vm.launch()
660 console_pattern = 'Kernel command line: %s' % kernel_command_line
661 self.wait_for_console_pattern(console_pattern)
663 def test_ppc64_pseries(self):
665 :avocado: tags=arch:ppc64
666 :avocado: tags=machine:pseries
668 kernel_url = ('https://archives.fedoraproject.org/pub/archive'
669 '/fedora-secondary/releases/29/Everything/ppc64le/os'
670 '/ppc/ppc64/vmlinuz')
671 kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
672 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
674 self.vm.set_console()
675 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
676 self.vm.add_args('-kernel', kernel_path,
677 '-append', kernel_command_line)
678 self.vm.launch()
679 console_pattern = 'Kernel command line: %s' % kernel_command_line
680 self.wait_for_console_pattern(console_pattern)
682 def test_m68k_q800(self):
684 :avocado: tags=arch:m68k
685 :avocado: tags=machine:q800
687 deb_url = ('https://snapshot.debian.org/archive/debian-ports'
688 '/20191021T083923Z/pool-m68k/main'
689 '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
690 deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
691 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
692 kernel_path = self.extract_from_deb(deb_path,
693 '/boot/vmlinux-5.3.0-1-m68k')
695 self.vm.set_console()
696 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
697 'console=ttyS0 vga=off')
698 self.vm.add_args('-kernel', kernel_path,
699 '-append', kernel_command_line)
700 self.vm.launch()
701 console_pattern = 'Kernel command line: %s' % kernel_command_line
702 self.wait_for_console_pattern(console_pattern)
703 console_pattern = 'No filesystem could mount root'
704 self.wait_for_console_pattern(console_pattern)
706 def do_test_advcal_2018(self, day, tar_hash, kernel_name):
707 tar_url = ('https://www.qemu-advent-calendar.org'
708 '/2018/download/day' + day + '.tar.xz')
709 file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
710 archive.extract(file_path, self.workdir)
711 self.vm.set_console()
712 self.vm.add_args('-kernel',
713 self.workdir + '/day' + day + '/' + kernel_name)
714 self.vm.launch()
715 self.wait_for_console_pattern('QEMU advent calendar')
717 def test_arm_vexpressa9(self):
719 :avocado: tags=arch:arm
720 :avocado: tags=machine:vexpress-a9
722 tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
723 self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb')
724 self.do_test_advcal_2018('16', tar_hash, 'winter.zImage')
726 def test_m68k_mcf5208evb(self):
728 :avocado: tags=arch:m68k
729 :avocado: tags=machine:mcf5208evb
731 tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
732 self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf')
734 def test_microblaze_s3adsp1800(self):
736 :avocado: tags=arch:microblaze
737 :avocado: tags=machine:petalogix-s3adsp1800
739 tar_hash = '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
740 self.do_test_advcal_2018('17', tar_hash, 'ballerina.bin')
742 def test_or1k_sim(self):
744 :avocado: tags=arch:or1k
745 :avocado: tags=machine:or1k-sim
747 tar_hash = '20334cdaf386108c530ff0badaecc955693027dd'
748 self.do_test_advcal_2018('20', tar_hash, 'vmlinux')
750 def test_nios2_10m50(self):
752 :avocado: tags=arch:nios2
753 :avocado: tags=machine:10m50-ghrd
755 tar_hash = 'e4251141726c412ac0407c5a6bceefbbff018918'
756 self.do_test_advcal_2018('14', tar_hash, 'vmlinux.elf')
758 def test_ppc64_e500(self):
760 :avocado: tags=arch:ppc64
761 :avocado: tags=machine:ppce500
763 tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
764 self.vm.add_args('-cpu', 'e5500')
765 self.do_test_advcal_2018('19', tar_hash, 'uImage')
767 def test_ppc_g3beige(self):
769 :avocado: tags=arch:ppc
770 :avocado: tags=machine:g3beige
772 tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
773 self.vm.add_args('-M', 'graphics=off')
774 self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
776 def test_ppc_mac99(self):
778 :avocado: tags=arch:ppc
779 :avocado: tags=machine:mac99
781 tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
782 self.vm.add_args('-M', 'graphics=off')
783 self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
785 def test_sparc_ss20(self):
787 :avocado: tags=arch:sparc
788 :avocado: tags=machine:SS-20
790 tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
791 self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
793 def test_xtensa_lx60(self):
795 :avocado: tags=arch:xtensa
796 :avocado: tags=machine:lx60
798 tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
799 self.vm.add_args('-cpu', 'dc233c')
800 self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')