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
32 Round up to next power of 2
35 return 1 if x
== 0 else 2**(x
- 1).bit_length()
38 Expand file size to next power of 2
40 def image_pow2ceil_expand(path
):
41 size
= os
.path
.getsize(path
)
42 size_aligned
= pow2ceil(size
)
43 if size
!= size_aligned
:
44 with
open(path
, 'ab+') as fd
:
45 fd
.truncate(size_aligned
)
47 class LinuxKernelTest(Test
):
48 KERNEL_COMMON_COMMAND_LINE
= 'printk.time=0 '
50 def wait_for_console_pattern(self
, success_message
, vm
=None):
51 wait_for_console_pattern(self
, success_message
,
52 failure_message
='Kernel panic - not syncing',
55 def extract_from_deb(self
, deb
, path
):
57 Extracts a file from a deb package into the test workdir
59 :param deb: path to the deb archive
60 :param path: path within the deb archive of the file to be extracted
61 :returns: path of the extracted file
64 os
.chdir(self
.workdir
)
65 file_path
= process
.run("ar t %s" % deb
).stdout_text
.split()[2]
66 process
.run("ar x %s %s" % (deb
, file_path
))
67 archive
.extract(file_path
, self
.workdir
)
69 # Return complete path to extracted file. Because callers to
70 # extract_from_deb() specify 'path' with a leading slash, it is
71 # necessary to use os.path.relpath() as otherwise os.path.join()
72 # interprets it as an absolute path and drops the self.workdir part.
73 return os
.path
.normpath(os
.path
.join(self
.workdir
,
74 os
.path
.relpath(path
, '/')))
76 def extract_from_rpm(self
, rpm
, path
):
78 Extracts a file from an RPM package into the test workdir.
80 :param rpm: path to the rpm archive
81 :param path: path within the rpm archive of the file to be extracted
82 needs to be a relative path (starting with './') because
83 cpio(1), which is used to extract the file, expects that.
84 :returns: path of the extracted file
87 os
.chdir(self
.workdir
)
88 process
.run("rpm2cpio %s | cpio -id %s" % (rpm
, path
), shell
=True)
90 return os
.path
.normpath(os
.path
.join(self
.workdir
, path
))
92 class BootLinuxConsole(LinuxKernelTest
):
94 Boots a Linux kernel and checks that the console is operational and the
95 kernel command line is properly passed from QEMU to the kernel
99 def test_x86_64_pc(self
):
101 :avocado: tags=arch:x86_64
102 :avocado: tags=machine:pc
104 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
105 '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
107 kernel_hash
= '23bebd2680757891cf7adedb033532163a792495'
108 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
110 self
.vm
.set_console()
111 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
112 self
.vm
.add_args('-kernel', kernel_path
,
113 '-append', kernel_command_line
)
115 console_pattern
= 'Kernel command line: %s' % kernel_command_line
116 self
.wait_for_console_pattern(console_pattern
)
118 def test_mips_malta(self
):
120 :avocado: tags=arch:mips
121 :avocado: tags=machine:malta
122 :avocado: tags=endian:big
124 deb_url
= ('http://snapshot.debian.org/archive/debian/'
125 '20130217T032700Z/pool/main/l/linux-2.6/'
126 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
127 deb_hash
= 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
128 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
129 kernel_path
= self
.extract_from_deb(deb_path
,
130 '/boot/vmlinux-2.6.32-5-4kc-malta')
132 self
.vm
.set_console()
133 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
134 self
.vm
.add_args('-kernel', kernel_path
,
135 '-append', kernel_command_line
)
137 console_pattern
= 'Kernel command line: %s' % kernel_command_line
138 self
.wait_for_console_pattern(console_pattern
)
140 def test_mips64el_malta(self
):
142 This test requires the ar tool to extract "data.tar.gz" from
145 The kernel can be rebuilt using this Debian kernel source [1] and
146 following the instructions on [2].
148 [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
149 #linux-source-2.6.32_2.6.32-48
150 [2] https://kernel-team.pages.debian.net/kernel-handbook/
151 ch-common-tasks.html#s-common-official
153 :avocado: tags=arch:mips64el
154 :avocado: tags=machine:malta
156 deb_url
= ('http://snapshot.debian.org/archive/debian/'
157 '20130217T032700Z/pool/main/l/linux-2.6/'
158 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
159 deb_hash
= '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
160 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
161 kernel_path
= self
.extract_from_deb(deb_path
,
162 '/boot/vmlinux-2.6.32-5-5kc-malta')
164 self
.vm
.set_console()
165 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
166 self
.vm
.add_args('-kernel', kernel_path
,
167 '-append', kernel_command_line
)
169 console_pattern
= 'Kernel command line: %s' % kernel_command_line
170 self
.wait_for_console_pattern(console_pattern
)
172 def test_mips_malta_cpio(self
):
174 :avocado: tags=arch:mips
175 :avocado: tags=machine:malta
176 :avocado: tags=endian:big
178 deb_url
= ('http://snapshot.debian.org/archive/debian/'
179 '20160601T041800Z/pool/main/l/linux/'
180 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
181 deb_hash
= 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
182 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
183 kernel_path
= self
.extract_from_deb(deb_path
,
184 '/boot/vmlinux-4.5.0-2-4kc-malta')
185 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
186 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
187 'mips/rootfs.cpio.gz')
188 initrd_hash
= 'bf806e17009360a866bf537f6de66590de349a99'
189 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
190 initrd_path
= self
.workdir
+ "rootfs.cpio"
191 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
193 self
.vm
.set_console()
194 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
195 + 'console=ttyS0 console=tty '
196 + 'rdinit=/sbin/init noreboot')
197 self
.vm
.add_args('-kernel', kernel_path
,
198 '-initrd', initrd_path
,
199 '-append', kernel_command_line
,
202 self
.wait_for_console_pattern('Boot successful.')
204 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
206 exec_command_and_wait_for_pattern(self
, 'uname -a',
208 exec_command_and_wait_for_pattern(self
, 'reboot',
209 'reboot: Restarting system')
210 # Wait for VM to shut down gracefully
213 @skipUnless(os
.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
214 def test_mips64el_malta_5KEc_cpio(self
):
216 :avocado: tags=arch:mips64el
217 :avocado: tags=machine:malta
218 :avocado: tags=endian:little
220 kernel_url
= ('https://github.com/philmd/qemu-testing-blob/'
221 'raw/9ad2df38/mips/malta/mips64el/'
222 'vmlinux-3.19.3.mtoman.20150408')
223 kernel_hash
= '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
224 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
225 initrd_url
= ('https://github.com/groeck/linux-build-test/'
226 'raw/8584a59e/rootfs/'
227 'mipsel64/rootfs.mipsel64r1.cpio.gz')
228 initrd_hash
= '1dbb8a396e916847325284dbe2151167'
229 initrd_path_gz
= self
.fetch_asset(initrd_url
, algorithm
='md5',
230 asset_hash
=initrd_hash
)
231 initrd_path
= self
.workdir
+ "rootfs.cpio"
232 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
234 self
.vm
.set_console()
235 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
236 + 'console=ttyS0 console=tty '
237 + 'rdinit=/sbin/init noreboot')
238 self
.vm
.add_args('-cpu', '5KEc',
239 '-kernel', kernel_path
,
240 '-initrd', initrd_path
,
241 '-append', kernel_command_line
,
244 wait_for_console_pattern(self
, 'Boot successful.')
246 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
248 exec_command_and_wait_for_pattern(self
, 'uname -a',
249 '3.19.3.mtoman.20150408')
250 exec_command_and_wait_for_pattern(self
, 'reboot',
251 'reboot: Restarting system')
252 # Wait for VM to shut down gracefully
255 def do_test_mips_malta32el_nanomips(self
, kernel_url
, kernel_hash
):
256 kernel_path_xz
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
257 kernel_path
= self
.workdir
+ "kernel"
258 with lzma
.open(kernel_path_xz
, 'rb') as f_in
:
259 with
open(kernel_path
, 'wb') as f_out
:
260 shutil
.copyfileobj(f_in
, f_out
)
262 self
.vm
.set_console()
263 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
266 self
.vm
.add_args('-no-reboot',
268 '-kernel', kernel_path
,
269 '-append', kernel_command_line
)
271 console_pattern
= 'Kernel command line: %s' % kernel_command_line
272 self
.wait_for_console_pattern(console_pattern
)
274 def test_mips_malta32el_nanomips_4k(self
):
276 :avocado: tags=arch:mipsel
277 :avocado: tags=machine:malta
278 :avocado: tags=endian:little
280 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
281 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
282 'generic_nano32r6el_page4k.xz')
283 kernel_hash
= '477456aafd2a0f1ddc9482727f20fe9575565dd6'
284 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
286 def test_mips_malta32el_nanomips_16k_up(self
):
288 :avocado: tags=arch:mipsel
289 :avocado: tags=machine:malta
290 :avocado: tags=endian:little
292 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
293 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
294 'generic_nano32r6el_page16k_up.xz')
295 kernel_hash
= 'e882868f944c71c816e832e2303b7874d044a7bc'
296 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
298 def test_mips_malta32el_nanomips_64k_dbg(self
):
300 :avocado: tags=arch:mipsel
301 :avocado: tags=machine:malta
302 :avocado: tags=endian:little
304 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
305 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
306 'generic_nano32r6el_page64k_dbg.xz')
307 kernel_hash
= '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
308 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
310 def test_aarch64_virt(self
):
312 :avocado: tags=arch:aarch64
313 :avocado: tags=machine:virt
315 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
316 '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
318 kernel_hash
= '8c73e469fc6ea06a58dc83a628fc695b693b8493'
319 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
321 self
.vm
.set_console()
322 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
324 self
.vm
.add_args('-cpu', 'cortex-a53',
325 '-kernel', kernel_path
,
326 '-append', kernel_command_line
)
328 console_pattern
= 'Kernel command line: %s' % kernel_command_line
329 self
.wait_for_console_pattern(console_pattern
)
331 def test_aarch64_xlnx_versal_virt(self
):
333 :avocado: tags=arch:aarch64
334 :avocado: tags=machine:xlnx-versal-virt
335 :avocado: tags=device:pl011
336 :avocado: tags=device:arm_gicv3
338 kernel_url
= ('http://ports.ubuntu.com/ubuntu-ports/dists/'
339 'bionic-updates/main/installer-arm64/current/images/'
340 'netboot/ubuntu-installer/arm64/linux')
341 kernel_hash
= '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50'
342 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
344 initrd_url
= ('http://ports.ubuntu.com/ubuntu-ports/dists/'
345 'bionic-updates/main/installer-arm64/current/images/'
346 'netboot/ubuntu-installer/arm64/initrd.gz')
347 initrd_hash
= 'd385d3e88d53e2004c5d43cbe668b458a094f772'
348 initrd_path
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
350 self
.vm
.set_console()
351 self
.vm
.add_args('-m', '2G',
352 '-kernel', kernel_path
,
353 '-initrd', initrd_path
)
355 self
.wait_for_console_pattern('Checked W+X mappings: passed')
357 def test_arm_virt(self
):
359 :avocado: tags=arch:arm
360 :avocado: tags=machine:virt
362 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
363 '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
365 kernel_hash
= 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
366 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
368 self
.vm
.set_console()
369 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
371 self
.vm
.add_args('-kernel', kernel_path
,
372 '-append', kernel_command_line
)
374 console_pattern
= 'Kernel command line: %s' % kernel_command_line
375 self
.wait_for_console_pattern(console_pattern
)
377 def test_arm_emcraft_sf2(self
):
379 :avocado: tags=arch:arm
380 :avocado: tags=machine:emcraft-sf2
381 :avocado: tags=endian:little
382 :avocado: tags=u-boot
384 uboot_url
= ('https://raw.githubusercontent.com/'
385 'Subbaraya-Sundeep/qemu-test-binaries/'
386 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot')
387 uboot_hash
= 'cbb8cbab970f594bf6523b9855be209c08374ae2'
388 uboot_path
= self
.fetch_asset(uboot_url
, asset_hash
=uboot_hash
)
389 spi_url
= ('https://raw.githubusercontent.com/'
390 'Subbaraya-Sundeep/qemu-test-binaries/'
391 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin')
392 spi_hash
= '65523a1835949b6f4553be96dec1b6a38fb05501'
393 spi_path
= self
.fetch_asset(spi_url
, asset_hash
=spi_hash
)
395 self
.vm
.set_console()
396 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
397 self
.vm
.add_args('-kernel', uboot_path
,
398 '-append', kernel_command_line
,
399 '-drive', 'file=' + spi_path
+ ',if=mtd,format=raw',
402 self
.wait_for_console_pattern('Enter \'help\' for a list')
404 exec_command_and_wait_for_pattern(self
, 'ifconfig eth0 10.0.2.15',
405 'eth0: link becomes ready')
406 exec_command_and_wait_for_pattern(self
, 'ping -c 3 10.0.2.2',
407 '3 packets transmitted, 3 packets received, 0% packet loss')
409 def do_test_arm_raspi2(self
, uart_id
):
411 The kernel can be rebuilt using the kernel source referenced
412 and following the instructions on the on:
413 https://www.raspberrypi.org/documentation/linux/kernel/building.md
415 serial_kernel_cmdline
= {
416 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
418 deb_url
= ('http://archive.raspberrypi.org/debian/'
419 'pool/main/r/raspberrypi-firmware/'
420 'raspberrypi-kernel_1.20190215-1_armhf.deb')
421 deb_hash
= 'cd284220b32128c5084037553db3c482426f3972'
422 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
423 kernel_path
= self
.extract_from_deb(deb_path
, '/boot/kernel7.img')
424 dtb_path
= self
.extract_from_deb(deb_path
, '/boot/bcm2709-rpi-2-b.dtb')
426 self
.vm
.set_console()
427 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
428 serial_kernel_cmdline
[uart_id
] +
429 ' root=/dev/mmcblk0p2 rootwait ' +
430 'dwc_otg.fiq_fsm_enable=0')
431 self
.vm
.add_args('-kernel', kernel_path
,
433 '-append', kernel_command_line
,
434 '-device', 'usb-kbd')
436 console_pattern
= 'Kernel command line: %s' % kernel_command_line
437 self
.wait_for_console_pattern(console_pattern
)
438 console_pattern
= 'Product: QEMU USB Keyboard'
439 self
.wait_for_console_pattern(console_pattern
)
441 def test_arm_raspi2_uart0(self
):
443 :avocado: tags=arch:arm
444 :avocado: tags=machine:raspi2
445 :avocado: tags=device:pl011
447 self
.do_test_arm_raspi2(0)
449 def test_arm_exynos4210_initrd(self
):
451 :avocado: tags=arch:arm
452 :avocado: tags=machine:smdkc210
454 deb_url
= ('https://snapshot.debian.org/archive/debian/'
455 '20190928T224601Z/pool/main/l/linux/'
456 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
457 deb_hash
= 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
458 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
459 kernel_path
= self
.extract_from_deb(deb_path
,
460 '/boot/vmlinuz-4.19.0-6-armmp')
461 dtb_path
= '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
462 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
464 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
465 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
466 'arm/rootfs-armv5.cpio.gz')
467 initrd_hash
= '2b50f1873e113523967806f4da2afe385462ff9b'
468 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
469 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
470 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
472 self
.vm
.set_console()
473 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
474 'earlycon=exynos4210,0x13800000 earlyprintk ' +
475 'console=ttySAC0,115200n8 ' +
476 'random.trust_cpu=off cryptomgr.notests ' +
477 'cpuidle.off=1 panic=-1 noreboot')
479 self
.vm
.add_args('-kernel', kernel_path
,
481 '-initrd', initrd_path
,
482 '-append', kernel_command_line
,
486 self
.wait_for_console_pattern('Boot successful.')
487 # TODO user command, for now the uart is stuck
489 def test_arm_cubieboard_initrd(self
):
491 :avocado: tags=arch:arm
492 :avocado: tags=machine:cubieboard
494 deb_url
= ('https://apt.armbian.com/pool/main/l/'
495 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
496 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
497 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
498 kernel_path
= self
.extract_from_deb(deb_path
,
499 '/boot/vmlinuz-4.20.7-sunxi')
500 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
501 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
502 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
503 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
504 'arm/rootfs-armv5.cpio.gz')
505 initrd_hash
= '2b50f1873e113523967806f4da2afe385462ff9b'
506 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
507 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
508 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
510 self
.vm
.set_console()
511 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
512 'console=ttyS0,115200 '
515 self
.vm
.add_args('-kernel', kernel_path
,
517 '-initrd', initrd_path
,
518 '-append', kernel_command_line
,
521 self
.wait_for_console_pattern('Boot successful.')
523 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
524 'Allwinner sun4i/sun5i')
525 exec_command_and_wait_for_pattern(self
, 'cat /proc/iomem',
526 'system-control@1c00000')
527 # cubieboard's reboot is not functioning; omit reboot test.
529 def test_arm_cubieboard_sata(self
):
531 :avocado: tags=arch:arm
532 :avocado: tags=machine:cubieboard
534 deb_url
= ('https://apt.armbian.com/pool/main/l/'
535 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
536 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
537 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
538 kernel_path
= self
.extract_from_deb(deb_path
,
539 '/boot/vmlinuz-4.20.7-sunxi')
540 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
541 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
542 rootfs_url
= ('https://github.com/groeck/linux-build-test/raw/'
543 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
544 'arm/rootfs-armv5.ext2.gz')
545 rootfs_hash
= '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
546 rootfs_path_gz
= self
.fetch_asset(rootfs_url
, asset_hash
=rootfs_hash
)
547 rootfs_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
548 archive
.gzip_uncompress(rootfs_path_gz
, rootfs_path
)
550 self
.vm
.set_console()
551 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
552 'console=ttyS0,115200 '
556 self
.vm
.add_args('-kernel', kernel_path
,
558 '-drive', 'if=none,format=raw,id=disk0,file='
560 '-device', 'ide-hd,bus=ide.0,drive=disk0',
561 '-append', kernel_command_line
,
564 self
.wait_for_console_pattern('Boot successful.')
566 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
567 'Allwinner sun4i/sun5i')
568 exec_command_and_wait_for_pattern(self
, 'cat /proc/partitions',
570 # cubieboard's reboot is not functioning; omit reboot test.
572 def test_arm_orangepi(self
):
574 :avocado: tags=arch:arm
575 :avocado: tags=machine:orangepi-pc
577 deb_url
= ('https://apt.armbian.com/pool/main/l/'
578 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
579 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
580 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
581 kernel_path
= self
.extract_from_deb(deb_path
,
582 '/boot/vmlinuz-4.20.7-sunxi')
583 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
584 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
586 self
.vm
.set_console()
587 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
588 'console=ttyS0,115200n8 '
589 'earlycon=uart,mmio32,0x1c28000')
590 self
.vm
.add_args('-kernel', kernel_path
,
592 '-append', kernel_command_line
)
594 console_pattern
= 'Kernel command line: %s' % kernel_command_line
595 self
.wait_for_console_pattern(console_pattern
)
597 def test_arm_orangepi_initrd(self
):
599 :avocado: tags=arch:arm
600 :avocado: tags=machine:orangepi-pc
602 deb_url
= ('https://apt.armbian.com/pool/main/l/'
603 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
604 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
605 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
606 kernel_path
= self
.extract_from_deb(deb_path
,
607 '/boot/vmlinuz-4.20.7-sunxi')
608 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
609 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
610 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
611 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
612 'arm/rootfs-armv7a.cpio.gz')
613 initrd_hash
= '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
614 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
615 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
616 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
618 self
.vm
.set_console()
619 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
620 'console=ttyS0,115200 '
622 self
.vm
.add_args('-kernel', kernel_path
,
624 '-initrd', initrd_path
,
625 '-append', kernel_command_line
,
628 self
.wait_for_console_pattern('Boot successful.')
630 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
631 'Allwinner sun8i Family')
632 exec_command_and_wait_for_pattern(self
, 'cat /proc/iomem',
633 'system-control@1c00000')
634 exec_command_and_wait_for_pattern(self
, 'reboot',
635 'reboot: Restarting system')
636 # Wait for VM to shut down gracefully
639 def test_arm_orangepi_sd(self
):
641 :avocado: tags=arch:arm
642 :avocado: tags=machine:orangepi-pc
643 :avocado: tags=device:sd
645 deb_url
= ('https://apt.armbian.com/pool/main/l/'
646 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
647 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
648 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
649 kernel_path
= self
.extract_from_deb(deb_path
,
650 '/boot/vmlinuz-4.20.7-sunxi')
651 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
652 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
653 rootfs_url
= ('http://storage.kernelci.org/images/rootfs/buildroot/'
654 'kci-2019.02/armel/base/rootfs.ext2.xz')
655 rootfs_hash
= '692510cb625efda31640d1de0a8d60e26040f061'
656 rootfs_path_xz
= self
.fetch_asset(rootfs_url
, asset_hash
=rootfs_hash
)
657 rootfs_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
658 archive
.lzma_uncompress(rootfs_path_xz
, rootfs_path
)
659 image_pow2ceil_expand(rootfs_path
)
661 self
.vm
.set_console()
662 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
663 'console=ttyS0,115200 '
664 'root=/dev/mmcblk0 rootwait rw '
666 self
.vm
.add_args('-kernel', kernel_path
,
668 '-drive', 'file=' + rootfs_path
+ ',if=sd,format=raw',
669 '-append', kernel_command_line
,
672 shell_ready
= "/bin/sh: can't access tty; job control turned off"
673 self
.wait_for_console_pattern(shell_ready
)
675 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
676 'Allwinner sun8i Family')
677 exec_command_and_wait_for_pattern(self
, 'cat /proc/partitions',
679 exec_command_and_wait_for_pattern(self
, 'ifconfig eth0 up',
681 exec_command_and_wait_for_pattern(self
, 'udhcpc eth0',
682 'udhcpc: lease of 10.0.2.15 obtained')
683 exec_command_and_wait_for_pattern(self
, 'ping -c 3 10.0.2.2',
684 '3 packets transmitted, 3 packets received, 0% packet loss')
685 exec_command_and_wait_for_pattern(self
, 'reboot',
686 'reboot: Restarting system')
687 # Wait for VM to shut down gracefully
690 @skipUnless(os
.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
691 @skipUnless(P7ZIP_AVAILABLE
, '7z not installed')
692 def test_arm_orangepi_bionic(self
):
694 :avocado: tags=arch:arm
695 :avocado: tags=machine:orangepi-pc
696 :avocado: tags=device:sd
699 # This test download a 196MB compressed image and expand it to 1GB
700 image_url
= ('https://dl.armbian.com/orangepipc/archive/'
701 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
702 image_hash
= '196a8ffb72b0123d92cea4a070894813d305c71e'
703 image_path_7z
= self
.fetch_asset(image_url
, asset_hash
=image_hash
)
704 image_name
= 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
705 image_path
= os
.path
.join(self
.workdir
, image_name
)
706 process
.run("7z e -o%s %s" % (self
.workdir
, image_path_7z
))
707 image_pow2ceil_expand(image_path
)
709 self
.vm
.set_console()
710 self
.vm
.add_args('-drive', 'file=' + image_path
+ ',if=sd,format=raw',
715 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
716 'console=ttyS0,115200 '
719 'systemd.default_timeout_start_sec=9000 '
720 'systemd.mask=armbian-zram-config.service '
721 'systemd.mask=armbian-ramlog.service')
723 self
.wait_for_console_pattern('U-Boot SPL')
724 self
.wait_for_console_pattern('Autoboot in ')
725 exec_command_and_wait_for_pattern(self
, ' ', '=>')
726 exec_command_and_wait_for_pattern(self
, "setenv extraargs '" +
727 kernel_command_line
+ "'", '=>')
728 exec_command_and_wait_for_pattern(self
, 'boot', 'Starting kernel ...');
730 self
.wait_for_console_pattern('systemd[1]: Set hostname ' +
732 self
.wait_for_console_pattern('Starting Load Kernel Modules...')
734 @skipUnless(os
.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
735 def test_arm_orangepi_uboot_netbsd9(self
):
737 :avocado: tags=arch:arm
738 :avocado: tags=machine:orangepi-pc
739 :avocado: tags=device:sd
741 # This test download a 304MB compressed image and expand it to 2GB
742 deb_url
= ('http://snapshot.debian.org/archive/debian/'
743 '20200108T145233Z/pool/main/u/u-boot/'
744 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
745 deb_hash
= 'f67f404a80753ca3d1258f13e38f2b060e13db99'
746 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
747 # We use the common OrangePi PC 'plus' build of U-Boot for our secondary
748 # program loader (SPL). We will then set the path to the more specific
749 # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt,
750 # before to boot NetBSD.
751 uboot_path
= '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin'
752 uboot_path
= self
.extract_from_deb(deb_path
, uboot_path
)
753 image_url
= ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/'
754 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz')
755 image_hash
= '2babb29d36d8360adcb39c09e31060945259917a'
756 image_path_gz
= self
.fetch_asset(image_url
, asset_hash
=image_hash
)
757 image_path
= os
.path
.join(self
.workdir
, 'armv7.img')
758 archive
.gzip_uncompress(image_path_gz
, image_path
)
759 image_pow2ceil_expand(image_path
)
760 image_drive_args
= 'if=sd,format=raw,snapshot=on,file=' + image_path
762 # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
763 with
open(uboot_path
, 'rb') as f_in
:
764 with
open(image_path
, 'r+b') as f_out
:
766 shutil
.copyfileobj(f_in
, f_out
)
768 self
.vm
.set_console()
769 self
.vm
.add_args('-nic', 'user',
770 '-drive', image_drive_args
,
771 '-global', 'allwinner-rtc.base-year=2000',
774 wait_for_console_pattern(self
, 'U-Boot 2020.01+dfsg-1')
775 interrupt_interactive_console_until_pattern(self
,
776 'Hit any key to stop autoboot:',
777 'switch to partitions #0, OK')
779 exec_command_and_wait_for_pattern(self
, '', '=>')
780 cmd
= 'setenv bootargs root=ld0a'
781 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
782 cmd
= 'setenv kernel netbsd-GENERIC.ub'
783 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
784 cmd
= 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb'
785 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
786 cmd
= ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; "
787 "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; "
788 "fdt addr ${fdt_addr_r}; "
789 "bootm ${kernel_addr_r} - ${fdt_addr_r}'")
790 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
792 exec_command_and_wait_for_pattern(self
, 'boot',
793 'Booting kernel from Legacy Image')
794 wait_for_console_pattern(self
, 'Starting kernel ...')
795 wait_for_console_pattern(self
, 'NetBSD 9.0 (GENERIC)')
796 # Wait for user-space
797 wait_for_console_pattern(self
, 'Starting root file system check')
799 def test_s390x_s390_ccw_virtio(self
):
801 :avocado: tags=arch:s390x
802 :avocado: tags=machine:s390-ccw-virtio
804 kernel_url
= ('https://archives.fedoraproject.org/pub/archive'
805 '/fedora-secondary/releases/29/Everything/s390x/os/images'
807 kernel_hash
= 'e8e8439103ef8053418ef062644ffd46a7919313'
808 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
810 self
.vm
.set_console()
811 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=sclp0'
812 self
.vm
.add_args('-nodefaults',
813 '-kernel', kernel_path
,
814 '-append', kernel_command_line
)
816 console_pattern
= 'Kernel command line: %s' % kernel_command_line
817 self
.wait_for_console_pattern(console_pattern
)
819 def test_alpha_clipper(self
):
821 :avocado: tags=arch:alpha
822 :avocado: tags=machine:clipper
824 kernel_url
= ('http://archive.debian.org/debian/dists/lenny/main/'
825 'installer-alpha/current/images/cdrom/vmlinuz')
826 kernel_hash
= '3a943149335529e2ed3e74d0d787b85fb5671ba3'
827 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
829 uncompressed_kernel
= archive
.uncompress(kernel_path
, self
.workdir
)
831 self
.vm
.set_console()
832 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
833 self
.vm
.add_args('-nodefaults',
834 '-kernel', uncompressed_kernel
,
835 '-append', kernel_command_line
)
837 console_pattern
= 'Kernel command line: %s' % kernel_command_line
838 self
.wait_for_console_pattern(console_pattern
)
840 def test_ppc64_pseries(self
):
842 :avocado: tags=arch:ppc64
843 :avocado: tags=machine:pseries
845 kernel_url
= ('https://archives.fedoraproject.org/pub/archive'
846 '/fedora-secondary/releases/29/Everything/ppc64le/os'
847 '/ppc/ppc64/vmlinuz')
848 kernel_hash
= '3fe04abfc852b66653b8c3c897a59a689270bc77'
849 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
851 self
.vm
.set_console()
852 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=hvc0'
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
)
859 def test_m68k_q800(self
):
861 :avocado: tags=arch:m68k
862 :avocado: tags=machine:q800
864 deb_url
= ('https://snapshot.debian.org/archive/debian-ports'
865 '/20191021T083923Z/pool-m68k/main'
866 '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
867 deb_hash
= '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
868 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
869 kernel_path
= self
.extract_from_deb(deb_path
,
870 '/boot/vmlinux-5.3.0-1-m68k')
872 self
.vm
.set_console()
873 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
874 'console=ttyS0 vga=off')
875 self
.vm
.add_args('-kernel', kernel_path
,
876 '-append', kernel_command_line
)
878 console_pattern
= 'Kernel command line: %s' % kernel_command_line
879 self
.wait_for_console_pattern(console_pattern
)
880 console_pattern
= 'No filesystem could mount root'
881 self
.wait_for_console_pattern(console_pattern
)
883 def do_test_advcal_2018(self
, day
, tar_hash
, kernel_name
, console
=0):
884 tar_url
= ('https://www.qemu-advent-calendar.org'
885 '/2018/download/day' + day
+ '.tar.xz')
886 file_path
= self
.fetch_asset(tar_url
, asset_hash
=tar_hash
)
887 archive
.extract(file_path
, self
.workdir
)
888 self
.vm
.set_console(console_index
=console
)
889 self
.vm
.add_args('-kernel',
890 self
.workdir
+ '/day' + day
+ '/' + kernel_name
)
892 self
.wait_for_console_pattern('QEMU advent calendar')
894 def test_arm_vexpressa9(self
):
896 :avocado: tags=arch:arm
897 :avocado: tags=machine:vexpress-a9
899 tar_hash
= '32b7677ce8b6f1471fb0059865f451169934245b'
900 self
.vm
.add_args('-dtb', self
.workdir
+ '/day16/vexpress-v2p-ca9.dtb')
901 self
.do_test_advcal_2018('16', tar_hash
, 'winter.zImage')
903 def test_m68k_mcf5208evb(self
):
905 :avocado: tags=arch:m68k
906 :avocado: tags=machine:mcf5208evb
908 tar_hash
= 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
909 self
.do_test_advcal_2018('07', tar_hash
, 'sanity-clause.elf')
911 def test_microblaze_s3adsp1800(self
):
913 :avocado: tags=arch:microblaze
914 :avocado: tags=machine:petalogix-s3adsp1800
916 tar_hash
= '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
917 self
.do_test_advcal_2018('17', tar_hash
, 'ballerina.bin')
919 def test_or1k_sim(self
):
921 :avocado: tags=arch:or1k
922 :avocado: tags=machine:or1k-sim
924 tar_hash
= '20334cdaf386108c530ff0badaecc955693027dd'
925 self
.do_test_advcal_2018('20', tar_hash
, 'vmlinux')
927 def test_nios2_10m50(self
):
929 :avocado: tags=arch:nios2
930 :avocado: tags=machine:10m50-ghrd
932 tar_hash
= 'e4251141726c412ac0407c5a6bceefbbff018918'
933 self
.do_test_advcal_2018('14', tar_hash
, 'vmlinux.elf')
935 def test_ppc64_e500(self
):
937 :avocado: tags=arch:ppc64
938 :avocado: tags=machine:ppce500
940 tar_hash
= '6951d86d644b302898da2fd701739c9406527fe1'
941 self
.vm
.add_args('-cpu', 'e5500')
942 self
.do_test_advcal_2018('19', tar_hash
, 'uImage')
944 def test_ppc_g3beige(self
):
946 :avocado: tags=arch:ppc
947 :avocado: tags=machine:g3beige
949 tar_hash
= 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
950 self
.vm
.add_args('-M', 'graphics=off')
951 self
.do_test_advcal_2018('15', tar_hash
, 'invaders.elf')
953 def test_ppc_mac99(self
):
955 :avocado: tags=arch:ppc
956 :avocado: tags=machine:mac99
958 tar_hash
= 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
959 self
.vm
.add_args('-M', 'graphics=off')
960 self
.do_test_advcal_2018('15', tar_hash
, 'invaders.elf')
962 def test_sh4_r2d(self
):
964 :avocado: tags=arch:sh4
965 :avocado: tags=machine:r2d
967 tar_hash
= 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
968 self
.vm
.add_args('-append', 'console=ttySC1')
969 self
.do_test_advcal_2018('09', tar_hash
, 'zImage', console
=1)
971 def test_sparc_ss20(self
):
973 :avocado: tags=arch:sparc
974 :avocado: tags=machine:SS-20
976 tar_hash
= 'b18550d5d61c7615d989a06edace051017726a9f'
977 self
.do_test_advcal_2018('11', tar_hash
, 'zImage.elf')
979 def test_xtensa_lx60(self
):
981 :avocado: tags=arch:xtensa
982 :avocado: tags=machine:lx60
984 tar_hash
= '49e88d9933742f0164b60839886c9739cb7a0d34'
985 self
.vm
.add_args('-cpu', 'dc233c')
986 self
.do_test_advcal_2018('02', tar_hash
, 'santas-sleigh-ride.elf')