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 BootLinuxConsole(Test
):
33 Boots a Linux kernel and checks that the console is operational and the
34 kernel command line is properly passed from QEMU to the kernel
39 KERNEL_COMMON_COMMAND_LINE
= 'printk.time=0 '
41 def wait_for_console_pattern(self
, success_message
):
42 wait_for_console_pattern(self
, success_message
,
43 failure_message
='Kernel panic - not syncing')
45 def extract_from_deb(self
, deb
, path
):
47 Extracts a file from a deb package into the test workdir
49 :param deb: path to the deb archive
50 :param path: path within the deb archive of the file to be extracted
51 :returns: path of the extracted file
54 os
.chdir(self
.workdir
)
55 file_path
= process
.run("ar t %s" % deb
).stdout_text
.split()[2]
56 process
.run("ar x %s %s" % (deb
, file_path
))
57 archive
.extract(file_path
, self
.workdir
)
59 # Return complete path to extracted file. Because callers to
60 # extract_from_deb() specify 'path' with a leading slash, it is
61 # necessary to use os.path.relpath() as otherwise os.path.join()
62 # interprets it as an absolute path and drops the self.workdir part.
63 return os
.path
.normpath(os
.path
.join(self
.workdir
,
64 os
.path
.relpath(path
, '/')))
66 def extract_from_rpm(self
, rpm
, path
):
68 Extracts a file from an RPM package into the test workdir.
70 :param rpm: path to the rpm archive
71 :param path: path within the rpm archive of the file to be extracted
72 needs to be a relative path (starting with './') because
73 cpio(1), which is used to extract the file, expects that.
74 :returns: path of the extracted file
77 os
.chdir(self
.workdir
)
78 process
.run("rpm2cpio %s | cpio -id %s" % (rpm
, path
), shell
=True)
80 return os
.path
.normpath(os
.path
.join(self
.workdir
, path
))
82 def test_x86_64_pc(self
):
84 :avocado: tags=arch:x86_64
85 :avocado: tags=machine:pc
87 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
88 '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
90 kernel_hash
= '23bebd2680757891cf7adedb033532163a792495'
91 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
94 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
95 self
.vm
.add_args('-kernel', kernel_path
,
96 '-append', kernel_command_line
)
98 console_pattern
= 'Kernel command line: %s' % kernel_command_line
99 self
.wait_for_console_pattern(console_pattern
)
101 def test_mips_malta(self
):
103 :avocado: tags=arch:mips
104 :avocado: tags=machine:malta
105 :avocado: tags=endian:big
107 deb_url
= ('http://snapshot.debian.org/archive/debian/'
108 '20130217T032700Z/pool/main/l/linux-2.6/'
109 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
110 deb_hash
= 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
111 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
112 kernel_path
= self
.extract_from_deb(deb_path
,
113 '/boot/vmlinux-2.6.32-5-4kc-malta')
115 self
.vm
.set_console()
116 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
117 self
.vm
.add_args('-kernel', kernel_path
,
118 '-append', kernel_command_line
)
120 console_pattern
= 'Kernel command line: %s' % kernel_command_line
121 self
.wait_for_console_pattern(console_pattern
)
123 def test_mips64el_malta(self
):
125 This test requires the ar tool to extract "data.tar.gz" from
128 The kernel can be rebuilt using this Debian kernel source [1] and
129 following the instructions on [2].
131 [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
132 #linux-source-2.6.32_2.6.32-48
133 [2] https://kernel-team.pages.debian.net/kernel-handbook/
134 ch-common-tasks.html#s-common-official
136 :avocado: tags=arch:mips64el
137 :avocado: tags=machine:malta
139 deb_url
= ('http://snapshot.debian.org/archive/debian/'
140 '20130217T032700Z/pool/main/l/linux-2.6/'
141 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
142 deb_hash
= '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
143 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
144 kernel_path
= self
.extract_from_deb(deb_path
,
145 '/boot/vmlinux-2.6.32-5-5kc-malta')
147 self
.vm
.set_console()
148 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
149 self
.vm
.add_args('-kernel', kernel_path
,
150 '-append', kernel_command_line
)
152 console_pattern
= 'Kernel command line: %s' % kernel_command_line
153 self
.wait_for_console_pattern(console_pattern
)
155 def test_mips_malta_cpio(self
):
157 :avocado: tags=arch:mips
158 :avocado: tags=machine:malta
159 :avocado: tags=endian:big
161 deb_url
= ('http://snapshot.debian.org/archive/debian/'
162 '20160601T041800Z/pool/main/l/linux/'
163 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
164 deb_hash
= 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
165 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
166 kernel_path
= self
.extract_from_deb(deb_path
,
167 '/boot/vmlinux-4.5.0-2-4kc-malta')
168 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
169 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
170 'mips/rootfs.cpio.gz')
171 initrd_hash
= 'bf806e17009360a866bf537f6de66590de349a99'
172 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
173 initrd_path
= self
.workdir
+ "rootfs.cpio"
174 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
176 self
.vm
.set_console()
177 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
178 + 'console=ttyS0 console=tty '
179 + 'rdinit=/sbin/init noreboot')
180 self
.vm
.add_args('-kernel', kernel_path
,
181 '-initrd', initrd_path
,
182 '-append', kernel_command_line
,
185 self
.wait_for_console_pattern('Boot successful.')
187 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
189 exec_command_and_wait_for_pattern(self
, 'uname -a',
191 exec_command_and_wait_for_pattern(self
, 'reboot',
192 'reboot: Restarting system')
194 @skipUnless(os
.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
195 def test_mips64el_malta_5KEc_cpio(self
):
197 :avocado: tags=arch:mips64el
198 :avocado: tags=machine:malta
199 :avocado: tags=endian:little
201 kernel_url
= ('https://github.com/philmd/qemu-testing-blob/'
202 'raw/9ad2df38/mips/malta/mips64el/'
203 'vmlinux-3.19.3.mtoman.20150408')
204 kernel_hash
= '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
205 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
206 initrd_url
= ('https://github.com/groeck/linux-build-test/'
207 'raw/8584a59e/rootfs/'
208 'mipsel64/rootfs.mipsel64r1.cpio.gz')
209 initrd_hash
= '1dbb8a396e916847325284dbe2151167'
210 initrd_path_gz
= self
.fetch_asset(initrd_url
, algorithm
='md5',
211 asset_hash
=initrd_hash
)
212 initrd_path
= self
.workdir
+ "rootfs.cpio"
213 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
215 self
.vm
.set_console()
216 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
217 + 'console=ttyS0 console=tty '
218 + 'rdinit=/sbin/init noreboot')
219 self
.vm
.add_args('-cpu', '5KEc',
220 '-kernel', kernel_path
,
221 '-initrd', initrd_path
,
222 '-append', kernel_command_line
,
225 wait_for_console_pattern(self
, 'Boot successful.')
227 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
229 exec_command_and_wait_for_pattern(self
, 'uname -a',
230 '3.19.3.mtoman.20150408')
231 exec_command_and_wait_for_pattern(self
, 'reboot',
232 'reboot: Restarting system')
234 def do_test_mips_malta32el_nanomips(self
, kernel_url
, kernel_hash
):
235 kernel_path_xz
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
236 kernel_path
= self
.workdir
+ "kernel"
237 with lzma
.open(kernel_path_xz
, 'rb') as f_in
:
238 with
open(kernel_path
, 'wb') as f_out
:
239 shutil
.copyfileobj(f_in
, f_out
)
241 self
.vm
.set_console()
242 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
245 self
.vm
.add_args('-no-reboot',
247 '-kernel', kernel_path
,
248 '-append', kernel_command_line
)
250 console_pattern
= 'Kernel command line: %s' % kernel_command_line
251 self
.wait_for_console_pattern(console_pattern
)
253 def test_mips_malta32el_nanomips_4k(self
):
255 :avocado: tags=arch:mipsel
256 :avocado: tags=machine:malta
257 :avocado: tags=endian:little
259 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
260 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
261 'generic_nano32r6el_page4k.xz')
262 kernel_hash
= '477456aafd2a0f1ddc9482727f20fe9575565dd6'
263 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
265 def test_mips_malta32el_nanomips_16k_up(self
):
267 :avocado: tags=arch:mipsel
268 :avocado: tags=machine:malta
269 :avocado: tags=endian:little
271 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
272 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
273 'generic_nano32r6el_page16k_up.xz')
274 kernel_hash
= 'e882868f944c71c816e832e2303b7874d044a7bc'
275 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
277 def test_mips_malta32el_nanomips_64k_dbg(self
):
279 :avocado: tags=arch:mipsel
280 :avocado: tags=machine:malta
281 :avocado: tags=endian:little
283 kernel_url
= ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
284 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
285 'generic_nano32r6el_page64k_dbg.xz')
286 kernel_hash
= '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
287 self
.do_test_mips_malta32el_nanomips(kernel_url
, kernel_hash
)
289 def test_aarch64_virt(self
):
291 :avocado: tags=arch:aarch64
292 :avocado: tags=machine:virt
294 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
295 '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
297 kernel_hash
= '8c73e469fc6ea06a58dc83a628fc695b693b8493'
298 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
300 self
.vm
.set_console()
301 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
303 self
.vm
.add_args('-cpu', 'cortex-a53',
304 '-kernel', kernel_path
,
305 '-append', kernel_command_line
)
307 console_pattern
= 'Kernel command line: %s' % kernel_command_line
308 self
.wait_for_console_pattern(console_pattern
)
310 def test_arm_virt(self
):
312 :avocado: tags=arch:arm
313 :avocado: tags=machine:virt
315 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
316 '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
318 kernel_hash
= 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
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('-kernel', kernel_path
,
325 '-append', kernel_command_line
)
327 console_pattern
= 'Kernel command line: %s' % kernel_command_line
328 self
.wait_for_console_pattern(console_pattern
)
330 def test_arm_emcraft_sf2(self
):
332 :avocado: tags=arch:arm
333 :avocado: tags=machine:emcraft-sf2
334 :avocado: tags=endian:little
335 :avocado: tags=u-boot
337 uboot_url
= ('https://raw.githubusercontent.com/'
338 'Subbaraya-Sundeep/qemu-test-binaries/'
339 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot')
340 uboot_hash
= 'cbb8cbab970f594bf6523b9855be209c08374ae2'
341 uboot_path
= self
.fetch_asset(uboot_url
, asset_hash
=uboot_hash
)
342 spi_url
= ('https://raw.githubusercontent.com/'
343 'Subbaraya-Sundeep/qemu-test-binaries/'
344 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin')
345 spi_hash
= '65523a1835949b6f4553be96dec1b6a38fb05501'
346 spi_path
= self
.fetch_asset(spi_url
, asset_hash
=spi_hash
)
348 self
.vm
.set_console()
349 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
350 self
.vm
.add_args('-kernel', uboot_path
,
351 '-append', kernel_command_line
,
352 '-drive', 'file=' + spi_path
+ ',if=mtd,format=raw',
355 self
.wait_for_console_pattern('Enter \'help\' for a list')
357 exec_command_and_wait_for_pattern(self
, 'ifconfig eth0 10.0.2.15',
358 'eth0: link becomes ready')
359 exec_command_and_wait_for_pattern(self
, 'ping -c 3 10.0.2.2',
360 '3 packets transmitted, 3 packets received, 0% packet loss')
362 def do_test_arm_raspi2(self
, uart_id
):
364 The kernel can be rebuilt using the kernel source referenced
365 and following the instructions on the on:
366 https://www.raspberrypi.org/documentation/linux/kernel/building.md
368 serial_kernel_cmdline
= {
369 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
371 deb_url
= ('http://archive.raspberrypi.org/debian/'
372 'pool/main/r/raspberrypi-firmware/'
373 'raspberrypi-kernel_1.20190215-1_armhf.deb')
374 deb_hash
= 'cd284220b32128c5084037553db3c482426f3972'
375 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
376 kernel_path
= self
.extract_from_deb(deb_path
, '/boot/kernel7.img')
377 dtb_path
= self
.extract_from_deb(deb_path
, '/boot/bcm2709-rpi-2-b.dtb')
379 self
.vm
.set_console()
380 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
381 serial_kernel_cmdline
[uart_id
])
382 self
.vm
.add_args('-kernel', kernel_path
,
384 '-append', kernel_command_line
)
386 console_pattern
= 'Kernel command line: %s' % kernel_command_line
387 self
.wait_for_console_pattern(console_pattern
)
389 def test_arm_raspi2_uart0(self
):
391 :avocado: tags=arch:arm
392 :avocado: tags=machine:raspi2
393 :avocado: tags=device:pl011
395 self
.do_test_arm_raspi2(0)
397 def test_arm_exynos4210_initrd(self
):
399 :avocado: tags=arch:arm
400 :avocado: tags=machine:smdkc210
402 deb_url
= ('https://snapshot.debian.org/archive/debian/'
403 '20190928T224601Z/pool/main/l/linux/'
404 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
405 deb_hash
= 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
406 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
407 kernel_path
= self
.extract_from_deb(deb_path
,
408 '/boot/vmlinuz-4.19.0-6-armmp')
409 dtb_path
= '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
410 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
412 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
413 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
414 'arm/rootfs-armv5.cpio.gz')
415 initrd_hash
= '2b50f1873e113523967806f4da2afe385462ff9b'
416 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
417 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
418 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
420 self
.vm
.set_console()
421 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
422 'earlycon=exynos4210,0x13800000 earlyprintk ' +
423 'console=ttySAC0,115200n8 ' +
424 'random.trust_cpu=off cryptomgr.notests ' +
425 'cpuidle.off=1 panic=-1 noreboot')
427 self
.vm
.add_args('-kernel', kernel_path
,
429 '-initrd', initrd_path
,
430 '-append', kernel_command_line
,
434 self
.wait_for_console_pattern('Boot successful.')
435 # TODO user command, for now the uart is stuck
437 def test_arm_cubieboard_initrd(self
):
439 :avocado: tags=arch:arm
440 :avocado: tags=machine:cubieboard
442 deb_url
= ('https://apt.armbian.com/pool/main/l/'
443 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
444 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
445 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
446 kernel_path
= self
.extract_from_deb(deb_path
,
447 '/boot/vmlinuz-4.20.7-sunxi')
448 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
449 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
450 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
451 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
452 'arm/rootfs-armv5.cpio.gz')
453 initrd_hash
= '2b50f1873e113523967806f4da2afe385462ff9b'
454 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
455 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
456 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
458 self
.vm
.set_console()
459 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
460 'console=ttyS0,115200 '
463 self
.vm
.add_args('-kernel', kernel_path
,
465 '-initrd', initrd_path
,
466 '-append', kernel_command_line
,
469 self
.wait_for_console_pattern('Boot successful.')
471 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
472 'Allwinner sun4i/sun5i')
473 exec_command_and_wait_for_pattern(self
, 'cat /proc/iomem',
474 'system-control@1c00000')
475 exec_command_and_wait_for_pattern(self
, 'reboot',
476 'reboot: Restarting system')
478 def test_arm_cubieboard_sata(self
):
480 :avocado: tags=arch:arm
481 :avocado: tags=machine:cubieboard
483 deb_url
= ('https://apt.armbian.com/pool/main/l/'
484 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
485 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
486 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
487 kernel_path
= self
.extract_from_deb(deb_path
,
488 '/boot/vmlinuz-4.20.7-sunxi')
489 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
490 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
491 rootfs_url
= ('https://github.com/groeck/linux-build-test/raw/'
492 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
493 'arm/rootfs-armv5.ext2.gz')
494 rootfs_hash
= '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
495 rootfs_path_gz
= self
.fetch_asset(rootfs_url
, asset_hash
=rootfs_hash
)
496 rootfs_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
497 archive
.gzip_uncompress(rootfs_path_gz
, rootfs_path
)
499 self
.vm
.set_console()
500 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
501 'console=ttyS0,115200 '
505 self
.vm
.add_args('-kernel', kernel_path
,
507 '-drive', 'if=none,format=raw,id=disk0,file='
509 '-device', 'ide-hd,bus=ide.0,drive=disk0',
510 '-append', kernel_command_line
,
513 self
.wait_for_console_pattern('Boot successful.')
515 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
516 'Allwinner sun4i/sun5i')
517 exec_command_and_wait_for_pattern(self
, 'cat /proc/partitions',
519 exec_command_and_wait_for_pattern(self
, 'reboot',
520 'reboot: Restarting system')
522 def test_arm_orangepi(self
):
524 :avocado: tags=arch:arm
525 :avocado: tags=machine:orangepi-pc
527 deb_url
= ('https://apt.armbian.com/pool/main/l/'
528 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
529 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
530 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
531 kernel_path
= self
.extract_from_deb(deb_path
,
532 '/boot/vmlinuz-4.20.7-sunxi')
533 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
534 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
536 self
.vm
.set_console()
537 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
538 'console=ttyS0,115200n8 '
539 'earlycon=uart,mmio32,0x1c28000')
540 self
.vm
.add_args('-kernel', kernel_path
,
542 '-append', kernel_command_line
)
544 console_pattern
= 'Kernel command line: %s' % kernel_command_line
545 self
.wait_for_console_pattern(console_pattern
)
547 def test_arm_orangepi_initrd(self
):
549 :avocado: tags=arch:arm
550 :avocado: tags=machine:orangepi-pc
552 deb_url
= ('https://apt.armbian.com/pool/main/l/'
553 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
554 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
555 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
556 kernel_path
= self
.extract_from_deb(deb_path
,
557 '/boot/vmlinuz-4.20.7-sunxi')
558 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
559 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
560 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
561 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
562 'arm/rootfs-armv7a.cpio.gz')
563 initrd_hash
= '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
564 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
565 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
566 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
568 self
.vm
.set_console()
569 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
570 'console=ttyS0,115200 '
572 self
.vm
.add_args('-kernel', kernel_path
,
574 '-initrd', initrd_path
,
575 '-append', kernel_command_line
,
578 self
.wait_for_console_pattern('Boot successful.')
580 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
581 'Allwinner sun8i Family')
582 exec_command_and_wait_for_pattern(self
, 'cat /proc/iomem',
583 'system-control@1c00000')
584 exec_command_and_wait_for_pattern(self
, 'reboot',
585 'reboot: Restarting system')
587 def test_arm_orangepi_sd(self
):
589 :avocado: tags=arch:arm
590 :avocado: tags=machine:orangepi-pc
592 deb_url
= ('https://apt.armbian.com/pool/main/l/'
593 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
594 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
595 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
596 kernel_path
= self
.extract_from_deb(deb_path
,
597 '/boot/vmlinuz-4.20.7-sunxi')
598 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
599 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
600 rootfs_url
= ('http://storage.kernelci.org/images/rootfs/buildroot/'
601 'kci-2019.02/armel/base/rootfs.ext2.xz')
602 rootfs_hash
= '692510cb625efda31640d1de0a8d60e26040f061'
603 rootfs_path_xz
= self
.fetch_asset(rootfs_url
, asset_hash
=rootfs_hash
)
604 rootfs_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
605 archive
.lzma_uncompress(rootfs_path_xz
, rootfs_path
)
607 self
.vm
.set_console()
608 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
609 'console=ttyS0,115200 '
610 'root=/dev/mmcblk0 rootwait rw '
612 self
.vm
.add_args('-kernel', kernel_path
,
614 '-drive', 'file=' + rootfs_path
+ ',if=sd,format=raw',
615 '-append', kernel_command_line
,
618 shell_ready
= "/bin/sh: can't access tty; job control turned off"
619 self
.wait_for_console_pattern(shell_ready
)
621 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
622 'Allwinner sun8i Family')
623 exec_command_and_wait_for_pattern(self
, 'cat /proc/partitions',
625 exec_command_and_wait_for_pattern(self
, 'ifconfig eth0 up',
627 exec_command_and_wait_for_pattern(self
, 'udhcpc eth0',
628 'udhcpc: lease of 10.0.2.15 obtained')
629 exec_command_and_wait_for_pattern(self
, 'ping -c 3 10.0.2.2',
630 '3 packets transmitted, 3 packets received, 0% packet loss')
631 exec_command_and_wait_for_pattern(self
, 'reboot',
632 'reboot: Restarting system')
634 @skipUnless(os
.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
635 @skipUnless(P7ZIP_AVAILABLE
, '7z not installed')
636 def test_arm_orangepi_bionic(self
):
638 :avocado: tags=arch:arm
639 :avocado: tags=machine:orangepi-pc
642 # This test download a 196MB compressed image and expand it to 932MB...
643 image_url
= ('https://dl.armbian.com/orangepipc/archive/'
644 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
645 image_hash
= '196a8ffb72b0123d92cea4a070894813d305c71e'
646 image_path_7z
= self
.fetch_asset(image_url
, asset_hash
=image_hash
)
647 image_name
= 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
648 image_path
= os
.path
.join(self
.workdir
, image_name
)
649 process
.run("7z e -o%s %s" % (self
.workdir
, image_path_7z
))
651 self
.vm
.set_console()
652 self
.vm
.add_args('-drive', 'file=' + image_path
+ ',if=sd,format=raw',
657 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
658 'console=ttyS0,115200 '
661 'systemd.default_timeout_start_sec=9000 '
662 'systemd.mask=armbian-zram-config.service '
663 'systemd.mask=armbian-ramlog.service')
665 self
.wait_for_console_pattern('U-Boot SPL')
666 self
.wait_for_console_pattern('Autoboot in ')
667 exec_command_and_wait_for_pattern(self
, ' ', '=>')
668 exec_command_and_wait_for_pattern(self
, "setenv extraargs '" +
669 kernel_command_line
+ "'", '=>')
670 exec_command_and_wait_for_pattern(self
, 'boot', 'Starting kernel ...');
672 self
.wait_for_console_pattern('systemd[1]: Set hostname ' +
674 self
.wait_for_console_pattern('Starting Load Kernel Modules...')
676 @skipUnless(os
.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
677 def test_arm_orangepi_uboot_netbsd9(self
):
679 :avocado: tags=arch:arm
680 :avocado: tags=machine:orangepi-pc
682 # This test download a 304MB compressed image and expand it to 1.3GB...
683 deb_url
= ('http://snapshot.debian.org/archive/debian/'
684 '20200108T145233Z/pool/main/u/u-boot/'
685 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
686 deb_hash
= 'f67f404a80753ca3d1258f13e38f2b060e13db99'
687 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
688 # We use the common OrangePi PC 'plus' build of U-Boot for our secondary
689 # program loader (SPL). We will then set the path to the more specific
690 # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt,
691 # before to boot NetBSD.
692 uboot_path
= '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin'
693 uboot_path
= self
.extract_from_deb(deb_path
, uboot_path
)
694 image_url
= ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/'
695 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz')
696 image_hash
= '2babb29d36d8360adcb39c09e31060945259917a'
697 image_path_gz
= self
.fetch_asset(image_url
, asset_hash
=image_hash
)
698 image_path
= os
.path
.join(self
.workdir
, 'armv7.img')
699 image_drive_args
= 'if=sd,format=raw,snapshot=on,file=' + image_path
700 archive
.gzip_uncompress(image_path_gz
, image_path
)
702 # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
703 with
open(uboot_path
, 'rb') as f_in
:
704 with
open(image_path
, 'r+b') as f_out
:
706 shutil
.copyfileobj(f_in
, f_out
)
708 # Extend image, to avoid that NetBSD thinks the partition
709 # inside the image is larger than device size itself
711 f_out
.seek(64 * 1024 * 1024, 1)
712 f_out
.write(bytearray([0x00]))
714 self
.vm
.set_console()
715 self
.vm
.add_args('-nic', 'user',
716 '-drive', image_drive_args
,
717 '-global', 'allwinner-rtc.base-year=2000',
720 wait_for_console_pattern(self
, 'U-Boot 2020.01+dfsg-1')
721 interrupt_interactive_console_until_pattern(self
,
722 'Hit any key to stop autoboot:',
723 'switch to partitions #0, OK')
725 exec_command_and_wait_for_pattern(self
, '', '=>')
726 cmd
= 'setenv bootargs root=ld0a'
727 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
728 cmd
= 'setenv kernel netbsd-GENERIC.ub'
729 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
730 cmd
= 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb'
731 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
732 cmd
= ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; "
733 "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; "
734 "fdt addr ${fdt_addr_r}; "
735 "bootm ${kernel_addr_r} - ${fdt_addr_r}'")
736 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
738 exec_command_and_wait_for_pattern(self
, 'boot',
739 'Booting kernel from Legacy Image')
740 wait_for_console_pattern(self
, 'Starting kernel ...')
741 wait_for_console_pattern(self
, 'NetBSD 9.0 (GENERIC)')
742 # Wait for user-space
743 wait_for_console_pattern(self
, 'Starting root file system check')
745 def test_s390x_s390_ccw_virtio(self
):
747 :avocado: tags=arch:s390x
748 :avocado: tags=machine:s390-ccw-virtio
750 kernel_url
= ('https://archives.fedoraproject.org/pub/archive'
751 '/fedora-secondary/releases/29/Everything/s390x/os/images'
753 kernel_hash
= 'e8e8439103ef8053418ef062644ffd46a7919313'
754 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
756 self
.vm
.set_console()
757 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=sclp0'
758 self
.vm
.add_args('-nodefaults',
759 '-kernel', kernel_path
,
760 '-append', kernel_command_line
)
762 console_pattern
= 'Kernel command line: %s' % kernel_command_line
763 self
.wait_for_console_pattern(console_pattern
)
765 def test_alpha_clipper(self
):
767 :avocado: tags=arch:alpha
768 :avocado: tags=machine:clipper
770 kernel_url
= ('http://archive.debian.org/debian/dists/lenny/main/'
771 'installer-alpha/current/images/cdrom/vmlinuz')
772 kernel_hash
= '3a943149335529e2ed3e74d0d787b85fb5671ba3'
773 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
775 uncompressed_kernel
= archive
.uncompress(kernel_path
, self
.workdir
)
777 self
.vm
.set_console()
778 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
779 self
.vm
.add_args('-nodefaults',
780 '-kernel', uncompressed_kernel
,
781 '-append', kernel_command_line
)
783 console_pattern
= 'Kernel command line: %s' % kernel_command_line
784 self
.wait_for_console_pattern(console_pattern
)
786 def test_ppc64_pseries(self
):
788 :avocado: tags=arch:ppc64
789 :avocado: tags=machine:pseries
791 kernel_url
= ('https://archives.fedoraproject.org/pub/archive'
792 '/fedora-secondary/releases/29/Everything/ppc64le/os'
793 '/ppc/ppc64/vmlinuz')
794 kernel_hash
= '3fe04abfc852b66653b8c3c897a59a689270bc77'
795 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
797 self
.vm
.set_console()
798 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=hvc0'
799 self
.vm
.add_args('-kernel', kernel_path
,
800 '-append', kernel_command_line
)
802 console_pattern
= 'Kernel command line: %s' % kernel_command_line
803 self
.wait_for_console_pattern(console_pattern
)
805 def test_m68k_q800(self
):
807 :avocado: tags=arch:m68k
808 :avocado: tags=machine:q800
810 deb_url
= ('https://snapshot.debian.org/archive/debian-ports'
811 '/20191021T083923Z/pool-m68k/main'
812 '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
813 deb_hash
= '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
814 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
815 kernel_path
= self
.extract_from_deb(deb_path
,
816 '/boot/vmlinux-5.3.0-1-m68k')
818 self
.vm
.set_console()
819 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
820 'console=ttyS0 vga=off')
821 self
.vm
.add_args('-kernel', kernel_path
,
822 '-append', kernel_command_line
)
824 console_pattern
= 'Kernel command line: %s' % kernel_command_line
825 self
.wait_for_console_pattern(console_pattern
)
826 console_pattern
= 'No filesystem could mount root'
827 self
.wait_for_console_pattern(console_pattern
)
829 def do_test_advcal_2018(self
, day
, tar_hash
, kernel_name
):
830 tar_url
= ('https://www.qemu-advent-calendar.org'
831 '/2018/download/day' + day
+ '.tar.xz')
832 file_path
= self
.fetch_asset(tar_url
, asset_hash
=tar_hash
)
833 archive
.extract(file_path
, self
.workdir
)
834 self
.vm
.set_console()
835 self
.vm
.add_args('-kernel',
836 self
.workdir
+ '/day' + day
+ '/' + kernel_name
)
838 self
.wait_for_console_pattern('QEMU advent calendar')
840 def test_arm_vexpressa9(self
):
842 :avocado: tags=arch:arm
843 :avocado: tags=machine:vexpress-a9
845 tar_hash
= '32b7677ce8b6f1471fb0059865f451169934245b'
846 self
.vm
.add_args('-dtb', self
.workdir
+ '/day16/vexpress-v2p-ca9.dtb')
847 self
.do_test_advcal_2018('16', tar_hash
, 'winter.zImage')
849 def test_m68k_mcf5208evb(self
):
851 :avocado: tags=arch:m68k
852 :avocado: tags=machine:mcf5208evb
854 tar_hash
= 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
855 self
.do_test_advcal_2018('07', tar_hash
, 'sanity-clause.elf')
857 def test_microblaze_s3adsp1800(self
):
859 :avocado: tags=arch:microblaze
860 :avocado: tags=machine:petalogix-s3adsp1800
862 tar_hash
= '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
863 self
.do_test_advcal_2018('17', tar_hash
, 'ballerina.bin')
865 def test_or1k_sim(self
):
867 :avocado: tags=arch:or1k
868 :avocado: tags=machine:or1k-sim
870 tar_hash
= '20334cdaf386108c530ff0badaecc955693027dd'
871 self
.do_test_advcal_2018('20', tar_hash
, 'vmlinux')
873 def test_nios2_10m50(self
):
875 :avocado: tags=arch:nios2
876 :avocado: tags=machine:10m50-ghrd
878 tar_hash
= 'e4251141726c412ac0407c5a6bceefbbff018918'
879 self
.do_test_advcal_2018('14', tar_hash
, 'vmlinux.elf')
881 def test_ppc64_e500(self
):
883 :avocado: tags=arch:ppc64
884 :avocado: tags=machine:ppce500
886 tar_hash
= '6951d86d644b302898da2fd701739c9406527fe1'
887 self
.vm
.add_args('-cpu', 'e5500')
888 self
.do_test_advcal_2018('19', tar_hash
, 'uImage')
890 def test_ppc_g3beige(self
):
892 :avocado: tags=arch:ppc
893 :avocado: tags=machine:g3beige
895 tar_hash
= 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
896 self
.vm
.add_args('-M', 'graphics=off')
897 self
.do_test_advcal_2018('15', tar_hash
, 'invaders.elf')
899 def test_ppc_mac99(self
):
901 :avocado: tags=arch:ppc
902 :avocado: tags=machine:mac99
904 tar_hash
= 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
905 self
.vm
.add_args('-M', 'graphics=off')
906 self
.do_test_advcal_2018('15', tar_hash
, 'invaders.elf')
908 def test_sparc_ss20(self
):
910 :avocado: tags=arch:sparc
911 :avocado: tags=machine:SS-20
913 tar_hash
= 'b18550d5d61c7615d989a06edace051017726a9f'
914 self
.do_test_advcal_2018('11', tar_hash
, 'zImage.elf')
916 def test_xtensa_lx60(self
):
918 :avocado: tags=arch:xtensa
919 :avocado: tags=machine:lx60
921 tar_hash
= '49e88d9933742f0164b60839886c9739cb7a0d34'
922 self
.vm
.add_args('-cpu', 'dc233c')
923 self
.do_test_advcal_2018('02', tar_hash
, 'santas-sleigh-ride.elf')