]> git.proxmox.com Git - mirror_qemu.git/blame - tests/acceptance/boot_linux_console.py
hw/arm/allwinner: add RTC device support
[mirror_qemu.git] / tests / acceptance / boot_linux_console.py
CommitLineData
c1cc73f4
CR
1# Functional test that boots a Linux kernel and checks the console
2#
3# Copyright (c) 2018 Red Hat, Inc.
4#
5# Author:
6# Cleber Rosa <crosa@redhat.com>
7#
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.
10
f8792047 11import os
f375ad6a 12import lzma
89368673 13import gzip
f375ad6a 14import shutil
c1cc73f4 15
efdb45bf 16from avocado import skipUnless
c1cc73f4 17from avocado_qemu import Test
2b17d81f 18from avocado_qemu import exec_command_and_wait_for_pattern
77bcd248 19from avocado_qemu import wait_for_console_pattern
f8792047
PMD
20from avocado.utils import process
21from avocado.utils import archive
c1cc73f4
CR
22
23
24class BootLinuxConsole(Test):
25 """
78664ed8
CR
26 Boots a Linux kernel and checks that the console is operational and the
27 kernel command line is properly passed from QEMU to the kernel
c1cc73f4
CR
28 """
29
61f74506 30 timeout = 90
c1cc73f4 31
b50fcd39
CR
32 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
33
77bcd248
CR
34 def wait_for_console_pattern(self, success_message):
35 wait_for_console_pattern(self, success_message,
36 failure_message='Kernel panic - not syncing')
89368673 37
f8792047
PMD
38 def extract_from_deb(self, deb, path):
39 """
40 Extracts a file from a deb package into the test workdir
41
42 :param deb: path to the deb archive
45260388 43 :param path: path within the deb archive of the file to be extracted
f8792047
PMD
44 :returns: path of the extracted file
45 """
46 cwd = os.getcwd()
47 os.chdir(self.workdir)
6c1c4c33
PMD
48 file_path = process.run("ar t %s" % deb).stdout_text.split()[2]
49 process.run("ar x %s %s" % (deb, file_path))
50 archive.extract(file_path, self.workdir)
f8792047 51 os.chdir(cwd)
921a9f6d
LM
52 # Return complete path to extracted file. Because callers to
53 # extract_from_deb() specify 'path' with a leading slash, it is
54 # necessary to use os.path.relpath() as otherwise os.path.join()
55 # interprets it as an absolute path and drops the self.workdir part.
56 return os.path.normpath(os.path.join(self.workdir,
57 os.path.relpath(path, '/')))
f8792047 58
76a901d2
LM
59 def extract_from_rpm(self, rpm, path):
60 """
61 Extracts a file from an RPM package into the test workdir.
62
63 :param rpm: path to the rpm archive
64 :param path: path within the rpm archive of the file to be extracted
65 needs to be a relative path (starting with './') because
66 cpio(1), which is used to extract the file, expects that.
67 :returns: path of the extracted file
68 """
69 cwd = os.getcwd()
70 os.chdir(self.workdir)
71 process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True)
72 os.chdir(cwd)
73 return os.path.normpath(os.path.join(self.workdir, path))
74
78664ed8
CR
75 def test_x86_64_pc(self):
76 """
77 :avocado: tags=arch:x86_64
78 :avocado: tags=machine:pc
79 """
93bbbdf6
CR
80 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
81 '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
82 '/vmlinuz')
7d7985b1 83 kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
c1cc73f4
CR
84 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
85
c1cc73f4 86 self.vm.set_console()
b50fcd39 87 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
c1cc73f4
CR
88 self.vm.add_args('-kernel', kernel_path,
89 '-append', kernel_command_line)
90 self.vm.launch()
0d1d74e5
CR
91 console_pattern = 'Kernel command line: %s' % kernel_command_line
92 self.wait_for_console_pattern(console_pattern)
f8792047
PMD
93
94 def test_mips_malta(self):
95 """
96 :avocado: tags=arch:mips
97 :avocado: tags=machine:malta
98 :avocado: tags=endian:big
99 """
100 deb_url = ('http://snapshot.debian.org/archive/debian/'
101 '20130217T032700Z/pool/main/l/linux-2.6/'
102 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
103 deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
104 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
105 kernel_path = self.extract_from_deb(deb_path,
106 '/boot/vmlinux-2.6.32-5-4kc-malta')
107
f8792047
PMD
108 self.vm.set_console()
109 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
110 self.vm.add_args('-kernel', kernel_path,
111 '-append', kernel_command_line)
112 self.vm.launch()
113 console_pattern = 'Kernel command line: %s' % kernel_command_line
114 self.wait_for_console_pattern(console_pattern)
02c2852b
CR
115
116 def test_mips64el_malta(self):
117 """
118 This test requires the ar tool to extract "data.tar.gz" from
119 the Debian package.
120
121 The kernel can be rebuilt using this Debian kernel source [1] and
122 following the instructions on [2].
123
124 [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
125 #linux-source-2.6.32_2.6.32-48
126 [2] https://kernel-team.pages.debian.net/kernel-handbook/
127 ch-common-tasks.html#s-common-official
128
129 :avocado: tags=arch:mips64el
130 :avocado: tags=machine:malta
131 """
132 deb_url = ('http://snapshot.debian.org/archive/debian/'
133 '20130217T032700Z/pool/main/l/linux-2.6/'
134 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
135 deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
136 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
137 kernel_path = self.extract_from_deb(deb_path,
138 '/boot/vmlinux-2.6.32-5-5kc-malta')
139
02c2852b
CR
140 self.vm.set_console()
141 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
142 self.vm.add_args('-kernel', kernel_path,
143 '-append', kernel_command_line)
144 self.vm.launch()
145 console_pattern = 'Kernel command line: %s' % kernel_command_line
146 self.wait_for_console_pattern(console_pattern)
d4e12161 147
89368673
PMD
148 def test_mips_malta_cpio(self):
149 """
150 :avocado: tags=arch:mips
151 :avocado: tags=machine:malta
152 :avocado: tags=endian:big
153 """
154 deb_url = ('http://snapshot.debian.org/archive/debian/'
155 '20160601T041800Z/pool/main/l/linux/'
156 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
157 deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
158 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
159 kernel_path = self.extract_from_deb(deb_path,
160 '/boot/vmlinux-4.5.0-2-4kc-malta')
161 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
162 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
163 'mips/rootfs.cpio.gz')
164 initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
165 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
166 initrd_path = self.workdir + "rootfs.cpio"
f2cd6cf6 167 archive.gzip_uncompress(initrd_path_gz, initrd_path)
89368673 168
89368673
PMD
169 self.vm.set_console()
170 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
171 + 'console=ttyS0 console=tty '
172 + 'rdinit=/sbin/init noreboot')
173 self.vm.add_args('-kernel', kernel_path,
174 '-initrd', initrd_path,
175 '-append', kernel_command_line,
176 '-no-reboot')
177 self.vm.launch()
178 self.wait_for_console_pattern('Boot successful.')
179
2b17d81f
PMD
180 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
181 'BogoMIPS')
182 exec_command_and_wait_for_pattern(self, 'uname -a',
183 'Debian')
184 exec_command_and_wait_for_pattern(self, 'reboot',
185 'reboot: Restarting system')
89368673 186
efdb45bf
PMD
187 @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
188 def test_mips64el_malta_5KEc_cpio(self):
189 """
190 :avocado: tags=arch:mips64el
191 :avocado: tags=machine:malta
192 :avocado: tags=endian:little
193 """
194 kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
195 'raw/9ad2df38/mips/malta/mips64el/'
196 'vmlinux-3.19.3.mtoman.20150408')
197 kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
198 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
199 initrd_url = ('https://github.com/groeck/linux-build-test/'
200 'raw/8584a59e/rootfs/'
201 'mipsel64/rootfs.mipsel64r1.cpio.gz')
202 initrd_hash = '1dbb8a396e916847325284dbe2151167'
203 initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5',
204 asset_hash=initrd_hash)
205 initrd_path = self.workdir + "rootfs.cpio"
206 archive.gzip_uncompress(initrd_path_gz, initrd_path)
207
efdb45bf
PMD
208 self.vm.set_console()
209 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
210 + 'console=ttyS0 console=tty '
211 + 'rdinit=/sbin/init noreboot')
212 self.vm.add_args('-cpu', '5KEc',
213 '-kernel', kernel_path,
214 '-initrd', initrd_path,
215 '-append', kernel_command_line,
216 '-no-reboot')
217 self.vm.launch()
218 wait_for_console_pattern(self, 'Boot successful.')
219
220 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
221 'MIPS 5KE')
222 exec_command_and_wait_for_pattern(self, 'uname -a',
223 '3.19.3.mtoman.20150408')
224 exec_command_and_wait_for_pattern(self, 'reboot',
225 'reboot: Restarting system')
89368673 226
f375ad6a
PMD
227 def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
228 kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
229 kernel_path = self.workdir + "kernel"
230 with lzma.open(kernel_path_xz, 'rb') as f_in:
231 with open(kernel_path, 'wb') as f_out:
232 shutil.copyfileobj(f_in, f_out)
233
f375ad6a
PMD
234 self.vm.set_console()
235 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
236 + 'mem=256m@@0x0 '
237 + 'console=ttyS0')
238 self.vm.add_args('-no-reboot',
239 '-cpu', 'I7200',
240 '-kernel', kernel_path,
241 '-append', kernel_command_line)
242 self.vm.launch()
243 console_pattern = 'Kernel command line: %s' % kernel_command_line
244 self.wait_for_console_pattern(console_pattern)
245
246 def test_mips_malta32el_nanomips_4k(self):
247 """
248 :avocado: tags=arch:mipsel
249 :avocado: tags=machine:malta
250 :avocado: tags=endian:little
251 """
252 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
253 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
254 'generic_nano32r6el_page4k.xz')
255 kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6'
256 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
257
258 def test_mips_malta32el_nanomips_16k_up(self):
259 """
260 :avocado: tags=arch:mipsel
261 :avocado: tags=machine:malta
262 :avocado: tags=endian:little
263 """
264 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
265 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
266 'generic_nano32r6el_page16k_up.xz')
267 kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc'
268 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
269
270 def test_mips_malta32el_nanomips_64k_dbg(self):
271 """
272 :avocado: tags=arch:mipsel
273 :avocado: tags=machine:malta
274 :avocado: tags=endian:little
275 """
276 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
277 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
278 'generic_nano32r6el_page64k_dbg.xz')
279 kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
280 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
281
d4e12161
CR
282 def test_aarch64_virt(self):
283 """
284 :avocado: tags=arch:aarch64
285 :avocado: tags=machine:virt
286 """
93bbbdf6
CR
287 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
288 '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
289 '/vmlinuz')
d4e12161
CR
290 kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
291 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
292
d4e12161
CR
293 self.vm.set_console()
294 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
295 'console=ttyAMA0')
296 self.vm.add_args('-cpu', 'cortex-a53',
297 '-kernel', kernel_path,
298 '-append', kernel_command_line)
299 self.vm.launch()
300 console_pattern = 'Kernel command line: %s' % kernel_command_line
301 self.wait_for_console_pattern(console_pattern)
1a30892e
CR
302
303 def test_arm_virt(self):
304 """
305 :avocado: tags=arch:arm
306 :avocado: tags=machine:virt
307 """
93bbbdf6
CR
308 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
309 '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
310 '/vmlinuz')
1a30892e
CR
311 kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
312 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
313
1a30892e
CR
314 self.vm.set_console()
315 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
316 'console=ttyAMA0')
317 self.vm.add_args('-kernel', kernel_path,
318 '-append', kernel_command_line)
319 self.vm.launch()
320 console_pattern = 'Kernel command line: %s' % kernel_command_line
321 self.wait_for_console_pattern(console_pattern)
79182494 322
77ead6b8
PMD
323 def test_arm_emcraft_sf2(self):
324 """
325 :avocado: tags=arch:arm
ba21bde9 326 :avocado: tags=machine:emcraft-sf2
77ead6b8 327 :avocado: tags=endian:little
b6f0a434 328 :avocado: tags=u-boot
77ead6b8
PMD
329 """
330 uboot_url = ('https://raw.githubusercontent.com/'
331 'Subbaraya-Sundeep/qemu-test-binaries/'
332 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/u-boot')
333 uboot_hash = 'abba5d9c24cdd2d49cdc2a8aa92976cf20737eff'
334 uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash)
335 spi_url = ('https://raw.githubusercontent.com/'
336 'Subbaraya-Sundeep/qemu-test-binaries/'
337 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/spi.bin')
338 spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a'
339 spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
340
77ead6b8
PMD
341 self.vm.set_console()
342 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
343 self.vm.add_args('-kernel', uboot_path,
344 '-append', kernel_command_line,
345 '-drive', 'file=' + spi_path + ',if=mtd,format=raw',
346 '-no-reboot')
347 self.vm.launch()
348 self.wait_for_console_pattern('init started: BusyBox')
349
92d93612
PMD
350 def do_test_arm_raspi2(self, uart_id):
351 """
352 The kernel can be rebuilt using the kernel source referenced
353 and following the instructions on the on:
354 https://www.raspberrypi.org/documentation/linux/kernel/building.md
355 """
356 serial_kernel_cmdline = {
357 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
358 }
359 deb_url = ('http://archive.raspberrypi.org/debian/'
360 'pool/main/r/raspberrypi-firmware/'
361 'raspberrypi-kernel_1.20190215-1_armhf.deb')
362 deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
363 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
364 kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
365 dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
366
92d93612
PMD
367 self.vm.set_console()
368 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
369 serial_kernel_cmdline[uart_id])
370 self.vm.add_args('-kernel', kernel_path,
371 '-dtb', dtb_path,
372 '-append', kernel_command_line)
373 self.vm.launch()
374 console_pattern = 'Kernel command line: %s' % kernel_command_line
375 self.wait_for_console_pattern(console_pattern)
376
377 def test_arm_raspi2_uart0(self):
378 """
379 :avocado: tags=arch:arm
380 :avocado: tags=machine:raspi2
381 :avocado: tags=device:pl011
382 """
383 self.do_test_arm_raspi2(0)
384
017aa60b
PMD
385 def test_arm_exynos4210_initrd(self):
386 """
387 :avocado: tags=arch:arm
388 :avocado: tags=machine:smdkc210
389 """
390 deb_url = ('https://snapshot.debian.org/archive/debian/'
391 '20190928T224601Z/pool/main/l/linux/'
392 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
393 deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
394 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
395 kernel_path = self.extract_from_deb(deb_path,
396 '/boot/vmlinuz-4.19.0-6-armmp')
397 dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
398 dtb_path = self.extract_from_deb(deb_path, dtb_path)
399
400 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
401 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
402 'arm/rootfs-armv5.cpio.gz')
403 initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
404 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
405 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
406 archive.gzip_uncompress(initrd_path_gz, initrd_path)
407
017aa60b
PMD
408 self.vm.set_console()
409 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
410 'earlycon=exynos4210,0x13800000 earlyprintk ' +
411 'console=ttySAC0,115200n8 ' +
412 'random.trust_cpu=off cryptomgr.notests ' +
413 'cpuidle.off=1 panic=-1 noreboot')
414
415 self.vm.add_args('-kernel', kernel_path,
416 '-dtb', dtb_path,
417 '-initrd', initrd_path,
418 '-append', kernel_command_line,
419 '-no-reboot')
420 self.vm.launch()
421
422 self.wait_for_console_pattern('Boot successful.')
423 # TODO user command, for now the uart is stuck
424
c5ce3153
PMD
425 def test_arm_cubieboard_initrd(self):
426 """
427 :avocado: tags=arch:arm
428 :avocado: tags=machine:cubieboard
429 """
430 deb_url = ('https://apt.armbian.com/pool/main/l/'
431 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
432 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
433 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
434 kernel_path = self.extract_from_deb(deb_path,
435 '/boot/vmlinuz-4.20.7-sunxi')
436 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
437 dtb_path = self.extract_from_deb(deb_path, dtb_path)
438 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
439 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
440 'arm/rootfs-armv5.cpio.gz')
441 initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
442 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
443 initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
444 archive.gzip_uncompress(initrd_path_gz, initrd_path)
445
446 self.vm.set_console()
447 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
448 'console=ttyS0,115200 '
449 'usbcore.nousb '
450 'panic=-1 noreboot')
451 self.vm.add_args('-kernel', kernel_path,
452 '-dtb', dtb_path,
453 '-initrd', initrd_path,
454 '-append', kernel_command_line,
455 '-no-reboot')
456 self.vm.launch()
457 self.wait_for_console_pattern('Boot successful.')
458
459 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
460 'Allwinner sun4i/sun5i')
461 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
462 'system-control@1c00000')
463 exec_command_and_wait_for_pattern(self, 'reboot',
464 'reboot: Restarting system')
465
e33ee309
PMD
466 def test_arm_cubieboard_sata(self):
467 """
468 :avocado: tags=arch:arm
469 :avocado: tags=machine:cubieboard
470 """
471 deb_url = ('https://apt.armbian.com/pool/main/l/'
472 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
473 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
474 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
475 kernel_path = self.extract_from_deb(deb_path,
476 '/boot/vmlinuz-4.20.7-sunxi')
477 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
478 dtb_path = self.extract_from_deb(deb_path, dtb_path)
479 rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
480 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
481 'arm/rootfs-armv5.ext2.gz')
482 rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
483 rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
484 rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
485 archive.gzip_uncompress(rootfs_path_gz, rootfs_path)
486
487 self.vm.set_console()
488 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
489 'console=ttyS0,115200 '
490 'usbcore.nousb '
491 'root=/dev/sda ro '
492 'panic=-1 noreboot')
493 self.vm.add_args('-kernel', kernel_path,
494 '-dtb', dtb_path,
495 '-drive', 'if=none,format=raw,id=disk0,file='
496 + rootfs_path,
497 '-device', 'ide-hd,bus=ide.0,drive=disk0',
498 '-append', kernel_command_line,
499 '-no-reboot')
500 self.vm.launch()
501 self.wait_for_console_pattern('Boot successful.')
502
503 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
504 'Allwinner sun4i/sun5i')
505 exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
506 'sda')
507 exec_command_and_wait_for_pattern(self, 'reboot',
508 'reboot: Restarting system')
509
79182494
CR
510 def test_s390x_s390_ccw_virtio(self):
511 """
512 :avocado: tags=arch:s390x
ba21bde9 513 :avocado: tags=machine:s390-ccw-virtio
79182494 514 """
93bbbdf6
CR
515 kernel_url = ('https://archives.fedoraproject.org/pub/archive'
516 '/fedora-secondary/releases/29/Everything/s390x/os/images'
517 '/kernel.img')
79182494
CR
518 kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
519 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
520
79182494
CR
521 self.vm.set_console()
522 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
523 self.vm.add_args('-nodefaults',
524 '-kernel', kernel_path,
525 '-append', kernel_command_line)
526 self.vm.launch()
527 console_pattern = 'Kernel command line: %s' % kernel_command_line
528 self.wait_for_console_pattern(console_pattern)
b36b5937
CR
529
530 def test_alpha_clipper(self):
531 """
532 :avocado: tags=arch:alpha
533 :avocado: tags=machine:clipper
534 """
535 kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
536 'installer-alpha/current/images/cdrom/vmlinuz')
537 kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
538 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
539
540 uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
541
b36b5937
CR
542 self.vm.set_console()
543 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
1d77f1b1 544 self.vm.add_args('-nodefaults',
b36b5937
CR
545 '-kernel', uncompressed_kernel,
546 '-append', kernel_command_line)
547 self.vm.launch()
548 console_pattern = 'Kernel command line: %s' % kernel_command_line
549 self.wait_for_console_pattern(console_pattern)
83fa3bc3
CR
550
551 def test_ppc64_pseries(self):
552 """
553 :avocado: tags=arch:ppc64
554 :avocado: tags=machine:pseries
555 """
93bbbdf6
CR
556 kernel_url = ('https://archives.fedoraproject.org/pub/archive'
557 '/fedora-secondary/releases/29/Everything/ppc64le/os'
558 '/ppc/ppc64/vmlinuz')
83fa3bc3
CR
559 kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
560 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
561
83fa3bc3
CR
562 self.vm.set_console()
563 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
564 self.vm.add_args('-kernel', kernel_path,
565 '-append', kernel_command_line)
566 self.vm.launch()
567 console_pattern = 'Kernel command line: %s' % kernel_command_line
568 self.wait_for_console_pattern(console_pattern)
f7d85525
PMD
569
570 def test_m68k_q800(self):
571 """
572 :avocado: tags=arch:m68k
573 :avocado: tags=machine:q800
574 """
f44b5549
PMD
575 deb_url = ('https://snapshot.debian.org/archive/debian-ports'
576 '/20191021T083923Z/pool-m68k/main'
2ecde8b2
CR
577 '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
578 deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
b67d22aa 579 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
f7d85525 580 kernel_path = self.extract_from_deb(deb_path,
2ecde8b2 581 '/boot/vmlinux-5.3.0-1-m68k')
f7d85525 582
f7d85525
PMD
583 self.vm.set_console()
584 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
585 'console=ttyS0 vga=off')
586 self.vm.add_args('-kernel', kernel_path,
587 '-append', kernel_command_line)
588 self.vm.launch()
589 console_pattern = 'Kernel command line: %s' % kernel_command_line
590 self.wait_for_console_pattern(console_pattern)
591 console_pattern = 'No filesystem could mount root'
592 self.wait_for_console_pattern(console_pattern)
b0065e1f
TH
593
594 def do_test_advcal_2018(self, day, tar_hash, kernel_name):
595 tar_url = ('https://www.qemu-advent-calendar.org'
596 '/2018/download/day' + day + '.tar.xz')
597 file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
598 archive.extract(file_path, self.workdir)
599 self.vm.set_console()
600 self.vm.add_args('-kernel',
601 self.workdir + '/day' + day + '/' + kernel_name)
602 self.vm.launch()
603 self.wait_for_console_pattern('QEMU advent calendar')
604
605 def test_arm_vexpressa9(self):
606 """
607 :avocado: tags=arch:arm
608 :avocado: tags=machine:vexpress-a9
609 """
610 tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
611 self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb')
612 self.do_test_advcal_2018('16', tar_hash, 'winter.zImage')
613
614 def test_m68k_mcf5208evb(self):
615 """
616 :avocado: tags=arch:m68k
617 :avocado: tags=machine:mcf5208evb
618 """
619 tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
620 self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf')
621
622 def test_microblaze_s3adsp1800(self):
623 """
624 :avocado: tags=arch:microblaze
625 :avocado: tags=machine:petalogix-s3adsp1800
626 """
627 tar_hash = '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
628 self.do_test_advcal_2018('17', tar_hash, 'ballerina.bin')
629
630 def test_or1k_sim(self):
631 """
632 :avocado: tags=arch:or1k
633 :avocado: tags=machine:or1k-sim
634 """
635 tar_hash = '20334cdaf386108c530ff0badaecc955693027dd'
636 self.do_test_advcal_2018('20', tar_hash, 'vmlinux')
637
638 def test_nios2_10m50(self):
639 """
640 :avocado: tags=arch:nios2
641 :avocado: tags=machine:10m50-ghrd
642 """
643 tar_hash = 'e4251141726c412ac0407c5a6bceefbbff018918'
644 self.do_test_advcal_2018('14', tar_hash, 'vmlinux.elf')
645
646 def test_ppc64_e500(self):
647 """
648 :avocado: tags=arch:ppc64
649 :avocado: tags=machine:ppce500
650 """
651 tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
652 self.vm.add_args('-cpu', 'e5500')
653 self.do_test_advcal_2018('19', tar_hash, 'uImage')
654
655 def test_ppc_g3beige(self):
656 """
657 :avocado: tags=arch:ppc
658 :avocado: tags=machine:g3beige
659 """
660 tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
661 self.vm.add_args('-M', 'graphics=off')
662 self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
663
664 def test_ppc_mac99(self):
665 """
666 :avocado: tags=arch:ppc
667 :avocado: tags=machine:mac99
668 """
669 tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
670 self.vm.add_args('-M', 'graphics=off')
671 self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
672
673 def test_sparc_ss20(self):
674 """
675 :avocado: tags=arch:sparc
676 :avocado: tags=machine:SS-20
677 """
678 tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
679 self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
680
681 def test_xtensa_lx60(self):
682 """
683 :avocado: tags=arch:xtensa
684 :avocado: tags=machine:lx60
685 """
686 tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
687 self.vm.add_args('-cpu', 'dc233c')
688 self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')