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 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/u-boot')
340 uboot_hash
= 'abba5d9c24cdd2d49cdc2a8aa92976cf20737eff'
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 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/spi.bin')
345 spi_hash
= '85f698329d38de63aea6e884a86fbde70890a78a'
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('init started: BusyBox')
357 def do_test_arm_raspi2(self
, uart_id
):
359 The kernel can be rebuilt using the kernel source referenced
360 and following the instructions on the on:
361 https://www.raspberrypi.org/documentation/linux/kernel/building.md
363 serial_kernel_cmdline
= {
364 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
366 deb_url
= ('http://archive.raspberrypi.org/debian/'
367 'pool/main/r/raspberrypi-firmware/'
368 'raspberrypi-kernel_1.20190215-1_armhf.deb')
369 deb_hash
= 'cd284220b32128c5084037553db3c482426f3972'
370 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
371 kernel_path
= self
.extract_from_deb(deb_path
, '/boot/kernel7.img')
372 dtb_path
= self
.extract_from_deb(deb_path
, '/boot/bcm2709-rpi-2-b.dtb')
374 self
.vm
.set_console()
375 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
376 serial_kernel_cmdline
[uart_id
])
377 self
.vm
.add_args('-kernel', kernel_path
,
379 '-append', kernel_command_line
)
381 console_pattern
= 'Kernel command line: %s' % kernel_command_line
382 self
.wait_for_console_pattern(console_pattern
)
384 def test_arm_raspi2_uart0(self
):
386 :avocado: tags=arch:arm
387 :avocado: tags=machine:raspi2
388 :avocado: tags=device:pl011
390 self
.do_test_arm_raspi2(0)
392 def test_arm_exynos4210_initrd(self
):
394 :avocado: tags=arch:arm
395 :avocado: tags=machine:smdkc210
397 deb_url
= ('https://snapshot.debian.org/archive/debian/'
398 '20190928T224601Z/pool/main/l/linux/'
399 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
400 deb_hash
= 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
401 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
402 kernel_path
= self
.extract_from_deb(deb_path
,
403 '/boot/vmlinuz-4.19.0-6-armmp')
404 dtb_path
= '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
405 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
407 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
408 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
409 'arm/rootfs-armv5.cpio.gz')
410 initrd_hash
= '2b50f1873e113523967806f4da2afe385462ff9b'
411 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
412 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
413 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
415 self
.vm
.set_console()
416 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
417 'earlycon=exynos4210,0x13800000 earlyprintk ' +
418 'console=ttySAC0,115200n8 ' +
419 'random.trust_cpu=off cryptomgr.notests ' +
420 'cpuidle.off=1 panic=-1 noreboot')
422 self
.vm
.add_args('-kernel', kernel_path
,
424 '-initrd', initrd_path
,
425 '-append', kernel_command_line
,
429 self
.wait_for_console_pattern('Boot successful.')
430 # TODO user command, for now the uart is stuck
432 def test_arm_cubieboard_initrd(self
):
434 :avocado: tags=arch:arm
435 :avocado: tags=machine:cubieboard
437 deb_url
= ('https://apt.armbian.com/pool/main/l/'
438 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
439 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
440 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
441 kernel_path
= self
.extract_from_deb(deb_path
,
442 '/boot/vmlinuz-4.20.7-sunxi')
443 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
444 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
445 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
446 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
447 'arm/rootfs-armv5.cpio.gz')
448 initrd_hash
= '2b50f1873e113523967806f4da2afe385462ff9b'
449 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
450 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
451 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
453 self
.vm
.set_console()
454 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
455 'console=ttyS0,115200 '
458 self
.vm
.add_args('-kernel', kernel_path
,
460 '-initrd', initrd_path
,
461 '-append', kernel_command_line
,
464 self
.wait_for_console_pattern('Boot successful.')
466 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
467 'Allwinner sun4i/sun5i')
468 exec_command_and_wait_for_pattern(self
, 'cat /proc/iomem',
469 'system-control@1c00000')
470 exec_command_and_wait_for_pattern(self
, 'reboot',
471 'reboot: Restarting system')
473 def test_arm_cubieboard_sata(self
):
475 :avocado: tags=arch:arm
476 :avocado: tags=machine:cubieboard
478 deb_url
= ('https://apt.armbian.com/pool/main/l/'
479 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
480 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
481 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
482 kernel_path
= self
.extract_from_deb(deb_path
,
483 '/boot/vmlinuz-4.20.7-sunxi')
484 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
485 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
486 rootfs_url
= ('https://github.com/groeck/linux-build-test/raw/'
487 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
488 'arm/rootfs-armv5.ext2.gz')
489 rootfs_hash
= '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
490 rootfs_path_gz
= self
.fetch_asset(rootfs_url
, asset_hash
=rootfs_hash
)
491 rootfs_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
492 archive
.gzip_uncompress(rootfs_path_gz
, rootfs_path
)
494 self
.vm
.set_console()
495 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
496 'console=ttyS0,115200 '
500 self
.vm
.add_args('-kernel', kernel_path
,
502 '-drive', 'if=none,format=raw,id=disk0,file='
504 '-device', 'ide-hd,bus=ide.0,drive=disk0',
505 '-append', kernel_command_line
,
508 self
.wait_for_console_pattern('Boot successful.')
510 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
511 'Allwinner sun4i/sun5i')
512 exec_command_and_wait_for_pattern(self
, 'cat /proc/partitions',
514 exec_command_and_wait_for_pattern(self
, 'reboot',
515 'reboot: Restarting system')
517 def test_arm_orangepi(self
):
519 :avocado: tags=arch:arm
520 :avocado: tags=machine:orangepi-pc
522 deb_url
= ('https://apt.armbian.com/pool/main/l/'
523 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
524 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
525 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
526 kernel_path
= self
.extract_from_deb(deb_path
,
527 '/boot/vmlinuz-4.20.7-sunxi')
528 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
529 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
531 self
.vm
.set_console()
532 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
533 'console=ttyS0,115200n8 '
534 'earlycon=uart,mmio32,0x1c28000')
535 self
.vm
.add_args('-kernel', kernel_path
,
537 '-append', kernel_command_line
)
539 console_pattern
= 'Kernel command line: %s' % kernel_command_line
540 self
.wait_for_console_pattern(console_pattern
)
542 def test_arm_orangepi_initrd(self
):
544 :avocado: tags=arch:arm
545 :avocado: tags=machine:orangepi-pc
547 deb_url
= ('https://apt.armbian.com/pool/main/l/'
548 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
549 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
550 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
551 kernel_path
= self
.extract_from_deb(deb_path
,
552 '/boot/vmlinuz-4.20.7-sunxi')
553 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
554 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
555 initrd_url
= ('https://github.com/groeck/linux-build-test/raw/'
556 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
557 'arm/rootfs-armv7a.cpio.gz')
558 initrd_hash
= '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
559 initrd_path_gz
= self
.fetch_asset(initrd_url
, asset_hash
=initrd_hash
)
560 initrd_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
561 archive
.gzip_uncompress(initrd_path_gz
, initrd_path
)
563 self
.vm
.set_console()
564 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
565 'console=ttyS0,115200 '
567 self
.vm
.add_args('-kernel', kernel_path
,
569 '-initrd', initrd_path
,
570 '-append', kernel_command_line
,
573 self
.wait_for_console_pattern('Boot successful.')
575 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
576 'Allwinner sun8i Family')
577 exec_command_and_wait_for_pattern(self
, 'cat /proc/iomem',
578 'system-control@1c00000')
579 exec_command_and_wait_for_pattern(self
, 'reboot',
580 'reboot: Restarting system')
582 def test_arm_orangepi_sd(self
):
584 :avocado: tags=arch:arm
585 :avocado: tags=machine:orangepi-pc
587 deb_url
= ('https://apt.armbian.com/pool/main/l/'
588 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
589 deb_hash
= '1334c29c44d984ffa05ed10de8c3361f33d78315'
590 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
591 kernel_path
= self
.extract_from_deb(deb_path
,
592 '/boot/vmlinuz-4.20.7-sunxi')
593 dtb_path
= '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
594 dtb_path
= self
.extract_from_deb(deb_path
, dtb_path
)
595 rootfs_url
= ('http://storage.kernelci.org/images/rootfs/buildroot/'
596 'kci-2019.02/armel/base/rootfs.ext2.xz')
597 rootfs_hash
= '692510cb625efda31640d1de0a8d60e26040f061'
598 rootfs_path_xz
= self
.fetch_asset(rootfs_url
, asset_hash
=rootfs_hash
)
599 rootfs_path
= os
.path
.join(self
.workdir
, 'rootfs.cpio')
600 archive
.lzma_uncompress(rootfs_path_xz
, rootfs_path
)
602 self
.vm
.set_console()
603 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
604 'console=ttyS0,115200 '
605 'root=/dev/mmcblk0 rootwait rw '
607 self
.vm
.add_args('-kernel', kernel_path
,
609 '-drive', 'file=' + rootfs_path
+ ',if=sd,format=raw',
610 '-append', kernel_command_line
,
613 shell_ready
= "/bin/sh: can't access tty; job control turned off"
614 self
.wait_for_console_pattern(shell_ready
)
616 exec_command_and_wait_for_pattern(self
, 'cat /proc/cpuinfo',
617 'Allwinner sun8i Family')
618 exec_command_and_wait_for_pattern(self
, 'cat /proc/partitions',
620 exec_command_and_wait_for_pattern(self
, 'ifconfig eth0 up',
622 exec_command_and_wait_for_pattern(self
, 'udhcpc eth0',
623 'udhcpc: lease of 10.0.2.15 obtained')
624 exec_command_and_wait_for_pattern(self
, 'ping -c 3 10.0.2.2',
625 '3 packets transmitted, 3 packets received, 0% packet loss')
626 exec_command_and_wait_for_pattern(self
, 'reboot',
627 'reboot: Restarting system')
629 @skipUnless(os
.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
630 @skipUnless(P7ZIP_AVAILABLE
, '7z not installed')
631 def test_arm_orangepi_bionic(self
):
633 :avocado: tags=arch:arm
634 :avocado: tags=machine:orangepi-pc
637 # This test download a 196MB compressed image and expand it to 932MB...
638 image_url
= ('https://dl.armbian.com/orangepipc/archive/'
639 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
640 image_hash
= '196a8ffb72b0123d92cea4a070894813d305c71e'
641 image_path_7z
= self
.fetch_asset(image_url
, asset_hash
=image_hash
)
642 image_name
= 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
643 image_path
= os
.path
.join(self
.workdir
, image_name
)
644 process
.run("7z e -o%s %s" % (self
.workdir
, image_path_7z
))
646 self
.vm
.set_console()
647 self
.vm
.add_args('-drive', 'file=' + image_path
+ ',if=sd,format=raw',
652 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
653 'console=ttyS0,115200 '
656 'systemd.default_timeout_start_sec=9000 '
657 'systemd.mask=armbian-zram-config.service '
658 'systemd.mask=armbian-ramlog.service')
660 self
.wait_for_console_pattern('U-Boot SPL')
661 self
.wait_for_console_pattern('Autoboot in ')
662 exec_command_and_wait_for_pattern(self
, ' ', '=>')
663 exec_command_and_wait_for_pattern(self
, "setenv extraargs '" +
664 kernel_command_line
+ "'", '=>')
665 exec_command_and_wait_for_pattern(self
, 'boot', 'Starting kernel ...');
667 self
.wait_for_console_pattern('systemd[1]: Set hostname ' +
669 self
.wait_for_console_pattern('Starting Load Kernel Modules...')
671 @skipUnless(os
.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
672 def test_arm_orangepi_uboot_netbsd9(self
):
674 :avocado: tags=arch:arm
675 :avocado: tags=machine:orangepi-pc
677 # This test download a 304MB compressed image and expand it to 1.3GB...
678 deb_url
= ('http://snapshot.debian.org/archive/debian/'
679 '20200108T145233Z/pool/main/u/u-boot/'
680 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
681 deb_hash
= 'f67f404a80753ca3d1258f13e38f2b060e13db99'
682 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
683 # We use the common OrangePi PC 'plus' build of U-Boot for our secondary
684 # program loader (SPL). We will then set the path to the more specific
685 # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt,
686 # before to boot NetBSD.
687 uboot_path
= '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin'
688 uboot_path
= self
.extract_from_deb(deb_path
, uboot_path
)
689 image_url
= ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/'
690 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz')
691 image_hash
= '2babb29d36d8360adcb39c09e31060945259917a'
692 image_path_gz
= self
.fetch_asset(image_url
, asset_hash
=image_hash
)
693 image_path
= os
.path
.join(self
.workdir
, 'armv7.img')
694 image_drive_args
= 'if=sd,format=raw,snapshot=on,file=' + image_path
695 archive
.gzip_uncompress(image_path_gz
, image_path
)
697 # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
698 with
open(uboot_path
, 'rb') as f_in
:
699 with
open(image_path
, 'r+b') as f_out
:
701 shutil
.copyfileobj(f_in
, f_out
)
703 # Extend image, to avoid that NetBSD thinks the partition
704 # inside the image is larger than device size itself
706 f_out
.seek(64 * 1024 * 1024, 1)
707 f_out
.write(bytearray([0x00]))
709 self
.vm
.set_console()
710 self
.vm
.add_args('-nic', 'user',
711 '-drive', image_drive_args
,
712 '-global', 'allwinner-rtc.base-year=2000',
715 wait_for_console_pattern(self
, 'U-Boot 2020.01+dfsg-1')
716 interrupt_interactive_console_until_pattern(self
,
717 'Hit any key to stop autoboot:',
718 'switch to partitions #0, OK')
720 exec_command_and_wait_for_pattern(self
, '', '=>')
721 cmd
= 'setenv bootargs root=ld0a'
722 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
723 cmd
= 'setenv kernel netbsd-GENERIC.ub'
724 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
725 cmd
= 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb'
726 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
727 cmd
= ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; "
728 "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; "
729 "fdt addr ${fdt_addr_r}; "
730 "bootm ${kernel_addr_r} - ${fdt_addr_r}'")
731 exec_command_and_wait_for_pattern(self
, cmd
, '=>')
733 exec_command_and_wait_for_pattern(self
, 'boot',
734 'Booting kernel from Legacy Image')
735 wait_for_console_pattern(self
, 'Starting kernel ...')
736 wait_for_console_pattern(self
, 'NetBSD 9.0 (GENERIC)')
737 # Wait for user-space
738 wait_for_console_pattern(self
, 'Starting root file system check')
740 def test_s390x_s390_ccw_virtio(self
):
742 :avocado: tags=arch:s390x
743 :avocado: tags=machine:s390-ccw-virtio
745 kernel_url
= ('https://archives.fedoraproject.org/pub/archive'
746 '/fedora-secondary/releases/29/Everything/s390x/os/images'
748 kernel_hash
= 'e8e8439103ef8053418ef062644ffd46a7919313'
749 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
751 self
.vm
.set_console()
752 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=sclp0'
753 self
.vm
.add_args('-nodefaults',
754 '-kernel', kernel_path
,
755 '-append', kernel_command_line
)
757 console_pattern
= 'Kernel command line: %s' % kernel_command_line
758 self
.wait_for_console_pattern(console_pattern
)
760 def test_alpha_clipper(self
):
762 :avocado: tags=arch:alpha
763 :avocado: tags=machine:clipper
765 kernel_url
= ('http://archive.debian.org/debian/dists/lenny/main/'
766 'installer-alpha/current/images/cdrom/vmlinuz')
767 kernel_hash
= '3a943149335529e2ed3e74d0d787b85fb5671ba3'
768 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
770 uncompressed_kernel
= archive
.uncompress(kernel_path
, self
.workdir
)
772 self
.vm
.set_console()
773 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0'
774 self
.vm
.add_args('-nodefaults',
775 '-kernel', uncompressed_kernel
,
776 '-append', kernel_command_line
)
778 console_pattern
= 'Kernel command line: %s' % kernel_command_line
779 self
.wait_for_console_pattern(console_pattern
)
781 def test_ppc64_pseries(self
):
783 :avocado: tags=arch:ppc64
784 :avocado: tags=machine:pseries
786 kernel_url
= ('https://archives.fedoraproject.org/pub/archive'
787 '/fedora-secondary/releases/29/Everything/ppc64le/os'
788 '/ppc/ppc64/vmlinuz')
789 kernel_hash
= '3fe04abfc852b66653b8c3c897a59a689270bc77'
790 kernel_path
= self
.fetch_asset(kernel_url
, asset_hash
=kernel_hash
)
792 self
.vm
.set_console()
793 kernel_command_line
= self
.KERNEL_COMMON_COMMAND_LINE
+ 'console=hvc0'
794 self
.vm
.add_args('-kernel', kernel_path
,
795 '-append', kernel_command_line
)
797 console_pattern
= 'Kernel command line: %s' % kernel_command_line
798 self
.wait_for_console_pattern(console_pattern
)
800 def test_m68k_q800(self
):
802 :avocado: tags=arch:m68k
803 :avocado: tags=machine:q800
805 deb_url
= ('https://snapshot.debian.org/archive/debian-ports'
806 '/20191021T083923Z/pool-m68k/main'
807 '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
808 deb_hash
= '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
809 deb_path
= self
.fetch_asset(deb_url
, asset_hash
=deb_hash
)
810 kernel_path
= self
.extract_from_deb(deb_path
,
811 '/boot/vmlinux-5.3.0-1-m68k')
813 self
.vm
.set_console()
814 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
815 'console=ttyS0 vga=off')
816 self
.vm
.add_args('-kernel', kernel_path
,
817 '-append', kernel_command_line
)
819 console_pattern
= 'Kernel command line: %s' % kernel_command_line
820 self
.wait_for_console_pattern(console_pattern
)
821 console_pattern
= 'No filesystem could mount root'
822 self
.wait_for_console_pattern(console_pattern
)
824 def do_test_advcal_2018(self
, day
, tar_hash
, kernel_name
):
825 tar_url
= ('https://www.qemu-advent-calendar.org'
826 '/2018/download/day' + day
+ '.tar.xz')
827 file_path
= self
.fetch_asset(tar_url
, asset_hash
=tar_hash
)
828 archive
.extract(file_path
, self
.workdir
)
829 self
.vm
.set_console()
830 self
.vm
.add_args('-kernel',
831 self
.workdir
+ '/day' + day
+ '/' + kernel_name
)
833 self
.wait_for_console_pattern('QEMU advent calendar')
835 def test_arm_vexpressa9(self
):
837 :avocado: tags=arch:arm
838 :avocado: tags=machine:vexpress-a9
840 tar_hash
= '32b7677ce8b6f1471fb0059865f451169934245b'
841 self
.vm
.add_args('-dtb', self
.workdir
+ '/day16/vexpress-v2p-ca9.dtb')
842 self
.do_test_advcal_2018('16', tar_hash
, 'winter.zImage')
844 def test_m68k_mcf5208evb(self
):
846 :avocado: tags=arch:m68k
847 :avocado: tags=machine:mcf5208evb
849 tar_hash
= 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
850 self
.do_test_advcal_2018('07', tar_hash
, 'sanity-clause.elf')
852 def test_microblaze_s3adsp1800(self
):
854 :avocado: tags=arch:microblaze
855 :avocado: tags=machine:petalogix-s3adsp1800
857 tar_hash
= '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
858 self
.do_test_advcal_2018('17', tar_hash
, 'ballerina.bin')
860 def test_or1k_sim(self
):
862 :avocado: tags=arch:or1k
863 :avocado: tags=machine:or1k-sim
865 tar_hash
= '20334cdaf386108c530ff0badaecc955693027dd'
866 self
.do_test_advcal_2018('20', tar_hash
, 'vmlinux')
868 def test_nios2_10m50(self
):
870 :avocado: tags=arch:nios2
871 :avocado: tags=machine:10m50-ghrd
873 tar_hash
= 'e4251141726c412ac0407c5a6bceefbbff018918'
874 self
.do_test_advcal_2018('14', tar_hash
, 'vmlinux.elf')
876 def test_ppc64_e500(self
):
878 :avocado: tags=arch:ppc64
879 :avocado: tags=machine:ppce500
881 tar_hash
= '6951d86d644b302898da2fd701739c9406527fe1'
882 self
.vm
.add_args('-cpu', 'e5500')
883 self
.do_test_advcal_2018('19', tar_hash
, 'uImage')
885 def test_ppc_g3beige(self
):
887 :avocado: tags=arch:ppc
888 :avocado: tags=machine:g3beige
890 tar_hash
= 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
891 self
.vm
.add_args('-M', 'graphics=off')
892 self
.do_test_advcal_2018('15', tar_hash
, 'invaders.elf')
894 def test_ppc_mac99(self
):
896 :avocado: tags=arch:ppc
897 :avocado: tags=machine:mac99
899 tar_hash
= 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
900 self
.vm
.add_args('-M', 'graphics=off')
901 self
.do_test_advcal_2018('15', tar_hash
, 'invaders.elf')
903 def test_sparc_ss20(self
):
905 :avocado: tags=arch:sparc
906 :avocado: tags=machine:SS-20
908 tar_hash
= 'b18550d5d61c7615d989a06edace051017726a9f'
909 self
.do_test_advcal_2018('11', tar_hash
, 'zImage.elf')
911 def test_xtensa_lx60(self
):
913 :avocado: tags=arch:xtensa
914 :avocado: tags=machine:lx60
916 tar_hash
= '49e88d9933742f0164b60839886c9739cb7a0d34'
917 self
.vm
.add_args('-cpu', 'dc233c')
918 self
.do_test_advcal_2018('02', tar_hash
, 'santas-sleigh-ride.elf')