1 # Functional test that boots a Linux kernel and checks the console
3 # Copyright (c) 2018 Red Hat, Inc.
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.
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 interrupt_interactive_console_until_pattern
20 from avocado_qemu
import wait_for_console_pattern
21 from avocado
.utils
import process
22 from avocado
.utils
import archive
23 from avocado
.utils
.path
import find_command
, CmdNotFoundError
25 P7ZIP_AVAILABLE
= True
28 except CmdNotFoundError
:
29 P7ZIP_AVAILABLE
= False
31 class LinuxKernelTest(Test
):
32 KERNEL_COMMON_COMMAND_LINE
= 'printk.time=0 '
34 def wait_for_console_pattern(self
, success_message
, vm
=None):
35 wait_for_console_pattern(self
, success_message
,
36 failure_message
='Kernel panic - not syncing',
39 def extract_from_deb(self
, deb
, path
):
41 Extracts a file from a deb package into the test workdir
43 :param deb: path to the deb archive
44 :param path: path within the deb archive of the file to be extracted
45 :returns: path of the extracted file
48 os
.chdir(self
.workdir
)
49 file_path
= process
.run("ar t %s" % deb
).stdout_text
.split()[2]
50 process
.run("ar x %s %s" % (deb
, file_path
))
51 archive
.extract(file_path
, self
.workdir
)
53 # Return complete path to extracted file. Because callers to
54 # extract_from_deb() specify 'path' with a leading slash, it is
55 # necessary to use os.path.relpath() as otherwise os.path.join()
56 # interprets it as an absolute path and drops the self.workdir part.
57 return os
.path
.normpath(os
.path
.join(self
.workdir
,
58 os
.path
.relpath(path
, '/')))
60 def extract_from_rpm(self
, rpm
, path
):
62 Extracts a file from an RPM package into the test workdir.
64 :param rpm: path to the rpm archive
65 :param path: path within the rpm archive of the file to be extracted
66 needs to be a relative path (starting with './') because
67 cpio(1), which is used to extract the file, expects that.
68 :returns: path of the extracted file
71 os
.chdir(self
.workdir
)
72 process
.run("rpm2cpio %s | cpio -id %s" % (rpm
, path
), shell
=True)
74 return os
.path
.normpath(os
.path
.join(self
.workdir
, path
))
76 class BootLinuxConsole(LinuxKernelTest
):
78 Boots a Linux kernel and checks that the console is operational and the
79 kernel command line is properly passed from QEMU to the kernel
83 def test_x86_64_pc(self
):
85 :avocado: tags=arch:x86_64
86 :avocado: tags=machine:pc
88 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
89 '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
91 kernel_hash
= '23bebd2680757891cf7adedb033532163a792495'
92 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
95 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
96 self
.vm
.add_args('-kernel', kernel_path
,
97 '-append', kernel_command_line
)
99 console_pattern
= 'Kernel command line: %s' % kernel_command_line
100 self
.wait_for_console_pattern(console_pattern
)
102 def test_mips_malta(self
):
104 :avocado: tags=arch:mips
105 :avocado: tags=machine:malta
106 :avocado: tags=endian:big
108 deb_url
= ('http://snapshot.debian.org/archive/debian/'
109 '20130217T032700Z/pool/main/l/linux-2.6/'
110 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
111 deb_hash
= 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
112 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
113 kernel_path
= self
.extract_from_deb(deb_path
,
114 '/boot/vmlinux-2.6.32-5-4kc-malta')
116 self
.vm
.set_console()
117 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
118 self
.vm
.add_args('-kernel', kernel_path
,
119 '-append', kernel_command_line
)
121 console_pattern
= 'Kernel command line: %s' % kernel_command_line
122 self
.wait_for_console_pattern(console_pattern
)
124 def test_mips64el_malta(self
):
126 This test requires the ar tool to extract "data.tar.gz" from
129 The kernel can be rebuilt using this Debian kernel source [1] and
130 following the instructions on [2].
132 [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
133 #linux-source-2.6.32_2.6.32-48
134 [2] https://kernel-team.pages.debian.net/kernel-handbook/
135 ch-common-tasks.html#s-common-official
137 :avocado: tags=arch:mips64el
138 :avocado: tags=machine:malta
140 deb_url
= ('http://snapshot.debian.org/archive/debian/'
141 '20130217T032700Z/pool/main/l/linux-2.6/'
142 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
143 deb_hash
= '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
144 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
145 kernel_path
= self
.extract_from_deb(deb_path
,
146 '/boot/vmlinux-2.6.32-5-5kc-malta')
148 self
.vm
.set_console()
149 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
150 self
.vm
.add_args('-kernel', kernel_path
,
151 '-append', kernel_command_line
)
153 console_pattern
= 'Kernel command line: %s' % kernel_command_line
154 self
.wait_for_console_pattern(console_pattern
)
156 def test_mips_malta_cpio(self
):
158 :avocado: tags=arch:mips
159 :avocado: tags=machine:malta
160 :avocado: tags=endian:big
162 deb_url
= ('http://snapshot.debian.org/archive/debian/'
163 '20160601T041800Z/pool/main/l/linux/'
164 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
165 deb_hash
= 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
166 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
167 kernel_path
= self
.extract_from_deb(deb_path
,
168 '/boot/vmlinux-4.5.0-2-4kc-malta')
169 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
170 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
171 'mips/rootfs.cpio.gz')
172 initrd_hash
= 'bf806e17009360a866bf537f6de66590de349a99'
173 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
174 initrd_path
= self
.workdir
+ "rootfs.cpio"
175 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
177 self
.vm
.set_console()
178 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
179 + 'console=ttyS0 console=tty '
180 + 'rdinit=/sbin/init noreboot')
181 self
.vm
.add_args('-kernel', kernel_path
,
182 '-initrd', initrd_path
,
183 '-append', kernel_command_line
,
186 self
.wait_for_console_pattern('Boot successful.')
188 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
190 exec_command_and_wait_for_pattern(self
, 'uname -a',
192 exec_command_and_wait_for_pattern(self
, 'reboot',
193 'reboot: Restarting system')
195 @skipUnless(os
.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
196 def test_mips64el_malta_5KEc_cpio(self
):
198 :avocado: tags=arch:mips64el
199 :avocado: tags=machine:malta
200 :avocado: tags=endian:little
202 kernel_url
= ('https://github.com/philmd/qemu-testing-blob/'
203 'raw/9ad2df38/mips/malta/mips64el/'
204 'vmlinux-3.19.3.mtoman.20150408')
205 kernel_hash
= '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
206 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
207 initrd_url
= ('https://github.com/groeck/linux-build-test/'
208 'raw/8584a59e/rootfs/'
209 'mipsel64/rootfs.mipsel64r1.cpio.gz')
210 initrd_hash
= '1dbb8a396e916847325284dbe2151167'
211 initrd_path_gz
= self
.fetch_asset(initrd_url
, algorithm
='md5',
212 asset_hash
=initrd_hash
)
213 initrd_path
= self
.workdir
+ "rootfs.cpio"
214 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
216 self
.vm
.set_console()
217 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
218 + 'console=ttyS0 console=tty '
219 + 'rdinit=/sbin/init noreboot')
220 self
.vm
.add_args('-cpu', '5KEc',
221 '-kernel', kernel_path
,
222 '-initrd', initrd_path
,
223 '-append', kernel_command_line
,
226 wait_for_console_pattern(self
, 'Boot successful.')
228 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
230 exec_command_and_wait_for_pattern(self
, 'uname -a',
231 '3.19.3.mtoman.20150408')
232 exec_command_and_wait_for_pattern(self
, 'reboot',
233 'reboot: Restarting system')
235 def do_test_mips_malta32el_nanomips(self
, kernel_url
, kernel_hash
):
236 kernel_path_xz
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
237 kernel_path
= self
.workdir
+ "kernel"
238 with lzma
.open(kernel_path_xz
, 'rb') as f_in
:
239 with
open(kernel_path
, 'wb') as f_out
:
240 shutil
.copyfileobj(f_in
, f_out
)
242 self
.vm
.set_console()
243 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
246 self
.vm
.add_args('-no-reboot',
248 '-kernel', kernel_path
,
249 '-append', kernel_command_line
)
251 console_pattern
= 'Kernel command line: %s' % kernel_command_line
252 self
.wait_for_console_pattern(console_pattern
)
254 def test_mips_malta32el_nanomips_4k(self
):
256 :avocado: tags=arch:mipsel
257 :avocado: tags=machine:malta
258 :avocado: tags=endian:little
260 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
261 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
262 'generic_nano32r6el_page4k.xz')
263 kernel_hash
= '477456aafd2a0f1ddc9482727f20fe9575565dd6'
264 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
266 def test_mips_malta32el_nanomips_16k_up(self
):
268 :avocado: tags=arch:mipsel
269 :avocado: tags=machine:malta
270 :avocado: tags=endian:little
272 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
273 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
274 'generic_nano32r6el_page16k_up.xz')
275 kernel_hash
= 'e882868f944c71c816e832e2303b7874d044a7bc'
276 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
278 def test_mips_malta32el_nanomips_64k_dbg(self
):
280 :avocado: tags=arch:mipsel
281 :avocado: tags=machine:malta
282 :avocado: tags=endian:little
284 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
285 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
286 'generic_nano32r6el_page64k_dbg.xz')
287 kernel_hash
= '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
288 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
290 def test_aarch64_virt(self
):
292 :avocado: tags=arch:aarch64
293 :avocado: tags=machine:virt
295 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
296 '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
298 kernel_hash
= '8c73e469fc6ea06a58dc83a628fc695b693b8493'
299 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
301 self
.vm
.set_console()
302 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
304 self
.vm
.add_args('-cpu', 'cortex-a53',
305 '-kernel', kernel_path
,
306 '-append', kernel_command_line
)
308 console_pattern
= 'Kernel command line: %s' % kernel_command_line
309 self
.wait_for_console_pattern(console_pattern
)
311 def test_aarch64_xlnx_versal_virt(self
):
313 :avocado: tags=arch:aarch64
314 :avocado: tags=machine:xlnx-versal-virt
315 :avocado: tags=device:pl011
316 :avocado: tags=device:arm_gicv3
318 kernel_url
= ('http://ports.ubuntu.com/ubuntu-ports/dists/'
319 'bionic-updates/main/installer-arm64/current/images/'
320 'netboot/ubuntu-installer/arm64/linux')
321 kernel_hash
= '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50'
322 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
324 initrd_url
= ('http://ports.ubuntu.com/ubuntu-ports/dists/'
325 'bionic-updates/main/installer-arm64/current/images/'
326 'netboot/ubuntu-installer/arm64/initrd.gz')
327 initrd_hash
= 'd385d3e88d53e2004c5d43cbe668b458a094f772'
328 initrd_path
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
330 self
.vm
.set_console()
331 self
.vm
.add_args('-m', '2G',
332 '-kernel', kernel_path
,
333 '-initrd', initrd_path
)
335 self
.wait_for_console_pattern('Checked W+X mappings: passed')
337 def test_arm_virt(self
):
339 :avocado: tags=arch:arm
340 :avocado: tags=machine:virt
342 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
343 '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
345 kernel_hash
= 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
346 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
348 self
.vm
.set_console()
349 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
351 self
.vm
.add_args('-kernel', kernel_path
,
352 '-append', kernel_command_line
)
354 console_pattern
= 'Kernel command line: %s' % kernel_command_line
355 self
.wait_for_console_pattern(console_pattern
)
357 def test_arm_emcraft_sf2(self
):
359 :avocado: tags=arch:arm
360 :avocado: tags=machine:emcraft-sf2
361 :avocado: tags=endian:little
362 :avocado: tags=u-boot
364 uboot_url
= ('https://raw.githubusercontent.com/'
365 'Subbaraya-Sundeep/qemu-test-binaries/'
366 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot')
367 uboot_hash
= 'cbb8cbab970f594bf6523b9855be209c08374ae2'
368 uboot_path
= self
.fetch_asset(uboot_url
, asset_hash
=uboot_hash
)
369 spi_url
= ('https://raw.githubusercontent.com/'
370 'Subbaraya-Sundeep/qemu-test-binaries/'
371 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin')
372 spi_hash
= '65523a1835949b6f4553be96dec1b6a38fb05501'
373 spi_path
= self
.fetch_asset(spi_url
, asset_hash
=spi_hash
)
375 self
.vm
.set_console()
376 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
377 self
.vm
.add_args('-kernel', uboot_path
,
378 '-append', kernel_command_line
,
379 '-drive', 'file=' + spi_path
+ ',if=mtd,format=raw',
382 self
.wait_for_console_pattern('Enter \'help\' for a list')
384 exec_command_and_wait_for_pattern(self
, 'ifconfig eth0 10.0.2.15',
385 'eth0: link becomes ready')
386 exec_command_and_wait_for_pattern(self
, 'ping -c 3 10.0.2.2',
387 '3 packets transmitted, 3 packets received, 0% packet loss')
389 def do_test_arm_raspi2(self
, uart_id
):
391 The kernel can be rebuilt using the kernel source referenced
392 and following the instructions on the on:
393 https://www.raspberrypi.org/documentation/linux/kernel/building.md
395 serial_kernel_cmdline
= {
396 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
398 deb_url
= ('http://archive.raspberrypi.org/debian/'
399 'pool/main/r/raspberrypi-firmware/'
400 'raspberrypi-kernel_1.20190215-1_armhf.deb')
401 deb_hash
= 'cd284220b32128c5084037553db3c482426f3972'
402 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
403 kernel_path
= self
.extract_from_deb(deb_path
, '/boot/kernel7.img')
404 dtb_path
= self
.extract_from_deb(deb_path
, '/boot/bcm2709-rpi-2-b.dtb')
406 self
.vm
.set_console()
407 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
408 serial_kernel_cmdline
[uart_id
] +
409 ' root=/dev/mmcblk0p2 rootwait ' +
410 'dwc_otg.fiq_fsm_enable=0')
411 self
.vm
.add_args('-kernel', kernel_path
,
413 '-append', kernel_command_line
,
414 '-device', 'usb-kbd')
416 console_pattern
= 'Kernel command line: %s' % kernel_command_line
417 self
.wait_for_console_pattern(console_pattern
)
418 console_pattern
= 'Product: QEMU USB Keyboard'
419 self
.wait_for_console_pattern(console_pattern
)
421 def test_arm_raspi2_uart0(self
):
423 :avocado: tags=arch:arm
424 :avocado: tags=machine:raspi2
425 :avocado: tags=device:pl011
427 self
.do_test_arm_raspi2(0)
429 def test_arm_exynos4210_initrd(self
):
431 :avocado: tags=arch:arm
432 :avocado: tags=machine:smdkc210
434 deb_url
= ('https://snapshot.debian.org/archive/debian/'
435 '20190928T224601Z/pool/main/l/linux/'
436 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
437 deb_hash
= 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
438 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
439 kernel_path
= self
.extract_from_deb(deb_path
,
440 '/boot/vmlinuz-4.19.0-6-armmp')
441 dtb_path
= '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
442 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
444 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
445 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
446 'arm/rootfs-armv5.cpio.gz')
447 initrd_hash
= '2b50f1873e113523967806f4da2afe385462ff9b'
448 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
449 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
450 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
452 self
.vm
.set_console()
453 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
454 'earlycon=exynos4210,0x13800000 earlyprintk ' +
455 'console=ttySAC0,115200n8 ' +
456 'random.trust_cpu=off cryptomgr.notests ' +
457 'cpuidle.off=1 panic=-1 noreboot')
459 self
.vm
.add_args('-kernel', kernel_path
,
461 '-initrd', initrd_path
,
462 '-append', kernel_command_line
,
466 self
.wait_for_console_pattern('Boot successful.')
467 # TODO user command, for now the uart is stuck
469 def test_arm_cubieboard_initrd(self
):
471 :avocado: tags=arch:arm
472 :avocado: tags=machine:cubieboard
474 deb_url
= ('https://apt.armbian.com/pool/main/l/'
475 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
476 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
477 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
478 kernel_path
= self
.extract_from_deb(deb_path
,
479 '/boot/vmlinuz-4.20.7-sunxi')
480 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
481 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
482 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
483 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
484 'arm/rootfs-armv5.cpio.gz')
485 initrd_hash
= '2b50f1873e113523967806f4da2afe385462ff9b'
486 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
487 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
488 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
490 self
.vm
.set_console()
491 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
492 'console=ttyS0,115200 '
495 self
.vm
.add_args('-kernel', kernel_path
,
497 '-initrd', initrd_path
,
498 '-append', kernel_command_line
,
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/iomem',
506 'system-control@1c00000')
507 exec_command_and_wait_for_pattern(self
, 'reboot',
508 'reboot: Restarting system')
510 def test_arm_cubieboard_sata(self
):
512 :avocado: tags=arch:arm
513 :avocado: tags=machine:cubieboard
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/sun4i-a10-cubieboard.dtb'
522 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
523 rootfs_url
= ('https://github.com/groeck/linux-build-test/raw/'
524 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
525 'arm/rootfs-armv5.ext2.gz')
526 rootfs_hash
= '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
527 rootfs_path_gz
= self
.fetch_asset(rootfs_url
, asset_hash
=rootfs_hash
)
528 rootfs_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
529 archive
.gzip_uncompress(rootfs_path_gz
, rootfs_path
)
531 self
.vm
.set_console()
532 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
533 'console=ttyS0,115200 '
537 self
.vm
.add_args('-kernel', kernel_path
,
539 '-drive', 'if=none,format=raw,id=disk0,file='
541 '-device', 'ide-hd,bus=ide.0,drive=disk0',
542 '-append', kernel_command_line
,
545 self
.wait_for_console_pattern('Boot successful.')
547 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
548 'Allwinner sun4i/sun5i')
549 exec_command_and_wait_for_pattern(self
, 'cat /proc/partitions',
551 exec_command_and_wait_for_pattern(self
, 'reboot',
552 'reboot: Restarting system')
554 def test_arm_orangepi(self
):
556 :avocado: tags=arch:arm
557 :avocado: tags=machine:orangepi-pc
559 deb_url
= ('https://apt.armbian.com/pool/main/l/'
560 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
561 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
562 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
563 kernel_path
= self
.extract_from_deb(deb_path
,
564 '/boot/vmlinuz-4.20.7-sunxi')
565 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
566 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
568 self
.vm
.set_console()
569 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
570 'console=ttyS0,115200n8 '
571 'earlycon=uart,mmio32,0x1c28000')
572 self
.vm
.add_args('-kernel', kernel_path
,
574 '-append', kernel_command_line
)
576 console_pattern
= 'Kernel command line: %s' % kernel_command_line
577 self
.wait_for_console_pattern(console_pattern
)
579 def test_arm_orangepi_initrd(self
):
581 :avocado: tags=arch:arm
582 :avocado: tags=machine:orangepi-pc
584 deb_url
= ('https://apt.armbian.com/pool/main/l/'
585 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
586 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
587 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
588 kernel_path
= self
.extract_from_deb(deb_path
,
589 '/boot/vmlinuz-4.20.7-sunxi')
590 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
591 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
592 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
593 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
594 'arm/rootfs-armv7a.cpio.gz')
595 initrd_hash
= '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
596 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
597 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
598 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
600 self
.vm
.set_console()
601 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
602 'console=ttyS0,115200 '
604 self
.vm
.add_args('-kernel', kernel_path
,
606 '-initrd', initrd_path
,
607 '-append', kernel_command_line
,
610 self
.wait_for_console_pattern('Boot successful.')
612 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
613 'Allwinner sun8i Family')
614 exec_command_and_wait_for_pattern(self
, 'cat /proc/iomem',
615 'system-control@1c00000')
616 exec_command_and_wait_for_pattern(self
, 'reboot',
617 'reboot: Restarting system')
619 def test_arm_orangepi_sd(self
):
621 :avocado: tags=arch:arm
622 :avocado: tags=machine:orangepi-pc
624 deb_url
= ('https://apt.armbian.com/pool/main/l/'
625 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
626 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
627 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
628 kernel_path
= self
.extract_from_deb(deb_path
,
629 '/boot/vmlinuz-4.20.7-sunxi')
630 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
631 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
632 rootfs_url
= ('http://storage.kernelci.org/images/rootfs/buildroot/'
633 'kci-2019.02/armel/base/rootfs.ext2.xz')
634 rootfs_hash
= '692510cb625efda31640d1de0a8d60e26040f061'
635 rootfs_path_xz
= self
.fetch_asset(rootfs_url
, asset_hash
=rootfs_hash
)
636 rootfs_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
637 archive
.lzma_uncompress(rootfs_path_xz
, rootfs_path
)
639 self
.vm
.set_console()
640 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
641 'console=ttyS0,115200 '
642 'root=/dev/mmcblk0 rootwait rw '
644 self
.vm
.add_args('-kernel', kernel_path
,
646 '-drive', 'file=' + rootfs_path
+ ',if=sd,format=raw',
647 '-append', kernel_command_line
,
650 shell_ready
= "/bin/sh: can't access tty; job control turned off"
651 self
.wait_for_console_pattern(shell_ready
)
653 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
654 'Allwinner sun8i Family')
655 exec_command_and_wait_for_pattern(self
, 'cat /proc/partitions',
657 exec_command_and_wait_for_pattern(self
, 'ifconfig eth0 up',
659 exec_command_and_wait_for_pattern(self
, 'udhcpc eth0',
660 'udhcpc: lease of 10.0.2.15 obtained')
661 exec_command_and_wait_for_pattern(self
, 'ping -c 3 10.0.2.2',
662 '3 packets transmitted, 3 packets received, 0% packet loss')
663 exec_command_and_wait_for_pattern(self
, 'reboot',
664 'reboot: Restarting system')
666 @skipUnless(os
.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
667 @skipUnless(P7ZIP_AVAILABLE
, '7z not installed')
668 def test_arm_orangepi_bionic(self
):
670 :avocado: tags=arch:arm
671 :avocado: tags=machine:orangepi-pc
674 # This test download a 196MB compressed image and expand it to 932MB...
675 image_url
= ('https://dl.armbian.com/orangepipc/archive/'
676 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
677 image_hash
= '196a8ffb72b0123d92cea4a070894813d305c71e'
678 image_path_7z
= self
.fetch_asset(image_url
, asset_hash
=image_hash
)
679 image_name
= 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
680 image_path
= os
.path
.join(self
.workdir
, image_name
)
681 process
.run("7z e -o%s %s" % (self
.workdir
, image_path_7z
))
683 self
.vm
.set_console()
684 self
.vm
.add_args('-drive', 'file=' + image_path
+ ',if=sd,format=raw',
689 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
690 'console=ttyS0,115200 '
693 'systemd.default_timeout_start_sec=9000 '
694 'systemd.mask=armbian-zram-config.service '
695 'systemd.mask=armbian-ramlog.service')
697 self
.wait_for_console_pattern('U-Boot SPL')
698 self
.wait_for_console_pattern('Autoboot in ')
699 exec_command_and_wait_for_pattern(self
, ' ', '=>')
700 exec_command_and_wait_for_pattern(self
, "setenv extraargs '" +
701 kernel_command_line
+ "'", '=>')
702 exec_command_and_wait_for_pattern(self
, 'boot', 'Starting kernel ...');
704 self
.wait_for_console_pattern('systemd[1]: Set hostname ' +
706 self
.wait_for_console_pattern('Starting Load Kernel Modules...')
708 @skipUnless(os
.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
709 def test_arm_orangepi_uboot_netbsd9(self
):
711 :avocado: tags=arch:arm
712 :avocado: tags=machine:orangepi-pc
714 # This test download a 304MB compressed image and expand it to 1.3GB...
715 deb_url
= ('http://snapshot.debian.org/archive/debian/'
716 '20200108T145233Z/pool/main/u/u-boot/'
717 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
718 deb_hash
= 'f67f404a80753ca3d1258f13e38f2b060e13db99'
719 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
720 # We use the common OrangePi PC 'plus' build of U-Boot for our secondary
721 # program loader (SPL). We will then set the path to the more specific
722 # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt,
723 # before to boot NetBSD.
724 uboot_path
= '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin'
725 uboot_path
= self
.extract_from_deb(deb_path
, uboot_path
)
726 image_url
= ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/'
727 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz')
728 image_hash
= '2babb29d36d8360adcb39c09e31060945259917a'
729 image_path_gz
= self
.fetch_asset(image_url
, asset_hash
=image_hash
)
730 image_path
= os
.path
.join(self
.workdir
, 'armv7.img')
731 image_drive_args
= 'if=sd,format=raw,snapshot=on,file=' + image_path
732 archive
.gzip_uncompress(image_path_gz
, image_path
)
734 # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
735 with
open(uboot_path
, 'rb') as f_in
:
736 with
open(image_path
, 'r+b') as f_out
:
738 shutil
.copyfileobj(f_in
, f_out
)
740 # Extend image, to avoid that NetBSD thinks the partition
741 # inside the image is larger than device size itself
743 f_out
.seek(64 * 1024 * 1024, 1)
744 f_out
.write(bytearray([0x00]))
746 self
.vm
.set_console()
747 self
.vm
.add_args('-nic', 'user',
748 '-drive', image_drive_args
,
749 '-global', 'allwinner-rtc.base-year=2000',
752 wait_for_console_pattern(self
, 'U-Boot 2020.01+dfsg-1')
753 interrupt_interactive_console_until_pattern(self
,
754 'Hit any key to stop autoboot:',
755 'switch to partitions #0, OK')
757 exec_command_and_wait_for_pattern(self
, '', '=>')
758 cmd
= 'setenv bootargs root=ld0a'
759 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
760 cmd
= 'setenv kernel netbsd-GENERIC.ub'
761 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
762 cmd
= 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb'
763 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
764 cmd
= ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; "
765 "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; "
766 "fdt addr ${fdt_addr_r}; "
767 "bootm ${kernel_addr_r} - ${fdt_addr_r}'")
768 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
770 exec_command_and_wait_for_pattern(self
, 'boot',
771 'Booting kernel from Legacy Image')
772 wait_for_console_pattern(self
, 'Starting kernel ...')
773 wait_for_console_pattern(self
, 'NetBSD 9.0 (GENERIC)')
774 # Wait for user-space
775 wait_for_console_pattern(self
, 'Starting root file system check')
777 def test_s390x_s390_ccw_virtio(self
):
779 :avocado: tags=arch:s390x
780 :avocado: tags=machine:s390-ccw-virtio
782 kernel_url
= ('https://archives.fedoraproject.org/pub/archive'
783 '/fedora-secondary/releases/29/Everything/s390x/os/images'
785 kernel_hash
= 'e8e8439103ef8053418ef062644ffd46a7919313'
786 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
788 self
.vm
.set_console()
789 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=sclp0'
790 self
.vm
.add_args('-nodefaults',
791 '-kernel', kernel_path
,
792 '-append', kernel_command_line
)
794 console_pattern
= 'Kernel command line: %s' % kernel_command_line
795 self
.wait_for_console_pattern(console_pattern
)
797 def test_alpha_clipper(self
):
799 :avocado: tags=arch:alpha
800 :avocado: tags=machine:clipper
802 kernel_url
= ('http://archive.debian.org/debian/dists/lenny/main/'
803 'installer-alpha/current/images/cdrom/vmlinuz')
804 kernel_hash
= '3a943149335529e2ed3e74d0d787b85fb5671ba3'
805 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
807 uncompressed_kernel
= archive
.uncompress(kernel_path
, self
.workdir
)
809 self
.vm
.set_console()
810 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
811 self
.vm
.add_args('-nodefaults',
812 '-kernel', uncompressed_kernel
,
813 '-append', kernel_command_line
)
815 console_pattern
= 'Kernel command line: %s' % kernel_command_line
816 self
.wait_for_console_pattern(console_pattern
)
818 def test_ppc64_pseries(self
):
820 :avocado: tags=arch:ppc64
821 :avocado: tags=machine:pseries
823 kernel_url
= ('https://archives.fedoraproject.org/pub/archive'
824 '/fedora-secondary/releases/29/Everything/ppc64le/os'
825 '/ppc/ppc64/vmlinuz')
826 kernel_hash
= '3fe04abfc852b66653b8c3c897a59a689270bc77'
827 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
829 self
.vm
.set_console()
830 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=hvc0'
831 self
.vm
.add_args('-kernel', kernel_path
,
832 '-append', kernel_command_line
)
834 console_pattern
= 'Kernel command line: %s' % kernel_command_line
835 self
.wait_for_console_pattern(console_pattern
)
837 def test_m68k_q800(self
):
839 :avocado: tags=arch:m68k
840 :avocado: tags=machine:q800
842 deb_url
= ('https://snapshot.debian.org/archive/debian-ports'
843 '/20191021T083923Z/pool-m68k/main'
844 '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
845 deb_hash
= '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
846 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
847 kernel_path
= self
.extract_from_deb(deb_path
,
848 '/boot/vmlinux-5.3.0-1-m68k')
850 self
.vm
.set_console()
851 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
852 'console=ttyS0 vga=off')
853 self
.vm
.add_args('-kernel', kernel_path
,
854 '-append', kernel_command_line
)
856 console_pattern
= 'Kernel command line: %s' % kernel_command_line
857 self
.wait_for_console_pattern(console_pattern
)
858 console_pattern
= 'No filesystem could mount root'
859 self
.wait_for_console_pattern(console_pattern
)
861 def do_test_advcal_2018(self
, day
, tar_hash
, kernel_name
, console
=0):
862 tar_url
= ('https://www.qemu-advent-calendar.org'
863 '/2018/download/day' + day
+ '.tar.xz')
864 file_path
= self
.fetch_asset(tar_url
, asset_hash
=tar_hash
)
865 archive
.extract(file_path
, self
.workdir
)
866 self
.vm
.set_console(console_index
=console
)
867 self
.vm
.add_args('-kernel',
868 self
.workdir
+ '/day' + day
+ '/' + kernel_name
)
870 self
.wait_for_console_pattern('QEMU advent calendar')
872 def test_arm_vexpressa9(self
):
874 :avocado: tags=arch:arm
875 :avocado: tags=machine:vexpress-a9
877 tar_hash
= '32b7677ce8b6f1471fb0059865f451169934245b'
878 self
.vm
.add_args('-dtb', self
.workdir
+ '/day16/vexpress-v2p-ca9.dtb')
879 self
.do_test_advcal_2018('16', tar_hash
, 'winter.zImage')
881 def test_m68k_mcf5208evb(self
):
883 :avocado: tags=arch:m68k
884 :avocado: tags=machine:mcf5208evb
886 tar_hash
= 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
887 self
.do_test_advcal_2018('07', tar_hash
, 'sanity-clause.elf')
889 def test_microblaze_s3adsp1800(self
):
891 :avocado: tags=arch:microblaze
892 :avocado: tags=machine:petalogix-s3adsp1800
894 tar_hash
= '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
895 self
.do_test_advcal_2018('17', tar_hash
, 'ballerina.bin')
897 def test_or1k_sim(self
):
899 :avocado: tags=arch:or1k
900 :avocado: tags=machine:or1k-sim
902 tar_hash
= '20334cdaf386108c530ff0badaecc955693027dd'
903 self
.do_test_advcal_2018('20', tar_hash
, 'vmlinux')
905 def test_nios2_10m50(self
):
907 :avocado: tags=arch:nios2
908 :avocado: tags=machine:10m50-ghrd
910 tar_hash
= 'e4251141726c412ac0407c5a6bceefbbff018918'
911 self
.do_test_advcal_2018('14', tar_hash
, 'vmlinux.elf')
913 def test_ppc64_e500(self
):
915 :avocado: tags=arch:ppc64
916 :avocado: tags=machine:ppce500
918 tar_hash
= '6951d86d644b302898da2fd701739c9406527fe1'
919 self
.vm
.add_args('-cpu', 'e5500')
920 self
.do_test_advcal_2018('19', tar_hash
, 'uImage')
922 def test_ppc_g3beige(self
):
924 :avocado: tags=arch:ppc
925 :avocado: tags=machine:g3beige
927 tar_hash
= 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
928 self
.vm
.add_args('-M', 'graphics=off')
929 self
.do_test_advcal_2018('15', tar_hash
, 'invaders.elf')
931 def test_ppc_mac99(self
):
933 :avocado: tags=arch:ppc
934 :avocado: tags=machine:mac99
936 tar_hash
= 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
937 self
.vm
.add_args('-M', 'graphics=off')
938 self
.do_test_advcal_2018('15', tar_hash
, 'invaders.elf')
940 def test_sh4_r2d(self
):
942 :avocado: tags=arch:sh4
943 :avocado: tags=machine:r2d
945 tar_hash
= 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
946 self
.vm
.add_args('-append', 'console=ttySC1')
947 self
.do_test_advcal_2018('09', tar_hash
, 'zImage', console
=1)
949 def test_sparc_ss20(self
):
951 :avocado: tags=arch:sparc
952 :avocado: tags=machine:SS-20
954 tar_hash
= 'b18550d5d61c7615d989a06edace051017726a9f'
955 self
.do_test_advcal_2018('11', tar_hash
, 'zImage.elf')
957 def test_xtensa_lx60(self
):
959 :avocado: tags=arch:xtensa
960 :avocado: tags=machine:lx60
962 tar_hash
= '49e88d9933742f0164b60839886c9739cb7a0d34'
963 self
.vm
.add_args('-cpu', 'dc233c')
964 self
.do_test_advcal_2018('02', tar_hash
, 'santas-sleigh-ride.elf')