tests/acceptance: Skip slow quanta-gsj U-boot+Linux test
[qemu/ar7.git] / tests / acceptance / boot_linux_console.py
blob0118ed5915655c55d8ba9d3269a076361e19febe
1 # Functional test that boots a Linux kernel and checks the console
3 # Copyright (c) 2018 Red Hat, Inc.
5 # Author:
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.
11 import os
12 import lzma
13 import gzip
14 import shutil
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
26 try:
27     find_command('7z')
28 except CmdNotFoundError:
29     P7ZIP_AVAILABLE = False
31 """
32 Round up to next power of 2
33 """
34 def pow2ceil(x):
35     return 1 if x == 0 else 2**(x - 1).bit_length()
37 """
38 Expand file size to next power of 2
39 """
40 def image_pow2ceil_expand(path):
41         size = os.path.getsize(path)
42         size_aligned = pow2ceil(size)
43         if size != size_aligned:
44             with open(path, 'ab+') as fd:
45                 fd.truncate(size_aligned)
47 class LinuxKernelTest(Test):
48     KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
50     def wait_for_console_pattern(self, success_message, vm=None):
51         wait_for_console_pattern(self, success_message,
52                                  failure_message='Kernel panic - not syncing',
53                                  vm=vm)
55     def extract_from_deb(self, deb, path):
56         """
57         Extracts a file from a deb package into the test workdir
59         :param deb: path to the deb archive
60         :param path: path within the deb archive of the file to be extracted
61         :returns: path of the extracted file
62         """
63         cwd = os.getcwd()
64         os.chdir(self.workdir)
65         file_path = process.run("ar t %s" % deb).stdout_text.split()[2]
66         process.run("ar x %s %s" % (deb, file_path))
67         archive.extract(file_path, self.workdir)
68         os.chdir(cwd)
69         # Return complete path to extracted file.  Because callers to
70         # extract_from_deb() specify 'path' with a leading slash, it is
71         # necessary to use os.path.relpath() as otherwise os.path.join()
72         # interprets it as an absolute path and drops the self.workdir part.
73         return os.path.normpath(os.path.join(self.workdir,
74                                              os.path.relpath(path, '/')))
76     def extract_from_rpm(self, rpm, path):
77         """
78         Extracts a file from an RPM package into the test workdir.
80         :param rpm: path to the rpm archive
81         :param path: path within the rpm archive of the file to be extracted
82                      needs to be a relative path (starting with './') because
83                      cpio(1), which is used to extract the file, expects that.
84         :returns: path of the extracted file
85         """
86         cwd = os.getcwd()
87         os.chdir(self.workdir)
88         process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True)
89         os.chdir(cwd)
90         return os.path.normpath(os.path.join(self.workdir, path))
92 class BootLinuxConsole(LinuxKernelTest):
93     """
94     Boots a Linux kernel and checks that the console is operational and the
95     kernel command line is properly passed from QEMU to the kernel
96     """
97     timeout = 90
99     def test_x86_64_pc(self):
100         """
101         :avocado: tags=arch:x86_64
102         :avocado: tags=machine:pc
103         """
104         kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
105                       '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
106                       '/vmlinuz')
107         kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
108         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
110         self.vm.set_console()
111         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
112         self.vm.add_args('-kernel', kernel_path,
113                          '-append', kernel_command_line)
114         self.vm.launch()
115         console_pattern = 'Kernel command line: %s' % kernel_command_line
116         self.wait_for_console_pattern(console_pattern)
118     def test_mips_malta(self):
119         """
120         :avocado: tags=arch:mips
121         :avocado: tags=machine:malta
122         :avocado: tags=endian:big
123         """
124         deb_url = ('http://snapshot.debian.org/archive/debian/'
125                    '20130217T032700Z/pool/main/l/linux-2.6/'
126                    'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
127         deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
128         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
129         kernel_path = self.extract_from_deb(deb_path,
130                                             '/boot/vmlinux-2.6.32-5-4kc-malta')
132         self.vm.set_console()
133         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
134         self.vm.add_args('-kernel', kernel_path,
135                          '-append', kernel_command_line)
136         self.vm.launch()
137         console_pattern = 'Kernel command line: %s' % kernel_command_line
138         self.wait_for_console_pattern(console_pattern)
140     def test_mips64el_malta(self):
141         """
142         This test requires the ar tool to extract "data.tar.gz" from
143         the Debian package.
145         The kernel can be rebuilt using this Debian kernel source [1] and
146         following the instructions on [2].
148         [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
149             #linux-source-2.6.32_2.6.32-48
150         [2] https://kernel-team.pages.debian.net/kernel-handbook/
151             ch-common-tasks.html#s-common-official
153         :avocado: tags=arch:mips64el
154         :avocado: tags=machine:malta
155         """
156         deb_url = ('http://snapshot.debian.org/archive/debian/'
157                    '20130217T032700Z/pool/main/l/linux-2.6/'
158                    'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
159         deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
160         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
161         kernel_path = self.extract_from_deb(deb_path,
162                                             '/boot/vmlinux-2.6.32-5-5kc-malta')
164         self.vm.set_console()
165         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
166         self.vm.add_args('-kernel', kernel_path,
167                          '-append', kernel_command_line)
168         self.vm.launch()
169         console_pattern = 'Kernel command line: %s' % kernel_command_line
170         self.wait_for_console_pattern(console_pattern)
172     def test_mips_malta_cpio(self):
173         """
174         :avocado: tags=arch:mips
175         :avocado: tags=machine:malta
176         :avocado: tags=endian:big
177         """
178         deb_url = ('http://snapshot.debian.org/archive/debian/'
179                    '20160601T041800Z/pool/main/l/linux/'
180                    'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
181         deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
182         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
183         kernel_path = self.extract_from_deb(deb_path,
184                                             '/boot/vmlinux-4.5.0-2-4kc-malta')
185         initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
186                       '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
187                       'mips/rootfs.cpio.gz')
188         initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
189         initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
190         initrd_path = self.workdir + "rootfs.cpio"
191         archive.gzip_uncompress(initrd_path_gz, initrd_path)
193         self.vm.set_console()
194         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
195                                + 'console=ttyS0 console=tty '
196                                + 'rdinit=/sbin/init noreboot')
197         self.vm.add_args('-kernel', kernel_path,
198                          '-initrd', initrd_path,
199                          '-append', kernel_command_line,
200                          '-no-reboot')
201         self.vm.launch()
202         self.wait_for_console_pattern('Boot successful.')
204         exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
205                                                 'BogoMIPS')
206         exec_command_and_wait_for_pattern(self, 'uname -a',
207                                                 'Debian')
208         exec_command_and_wait_for_pattern(self, 'reboot',
209                                                 'reboot: Restarting system')
210         # Wait for VM to shut down gracefully
211         self.vm.wait()
213     @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
214     def test_mips64el_malta_5KEc_cpio(self):
215         """
216         :avocado: tags=arch:mips64el
217         :avocado: tags=machine:malta
218         :avocado: tags=endian:little
219         """
220         kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
221                       'raw/9ad2df38/mips/malta/mips64el/'
222                       'vmlinux-3.19.3.mtoman.20150408')
223         kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
224         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
225         initrd_url = ('https://github.com/groeck/linux-build-test/'
226                       'raw/8584a59e/rootfs/'
227                       'mipsel64/rootfs.mipsel64r1.cpio.gz')
228         initrd_hash = '1dbb8a396e916847325284dbe2151167'
229         initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5',
230                                           asset_hash=initrd_hash)
231         initrd_path = self.workdir + "rootfs.cpio"
232         archive.gzip_uncompress(initrd_path_gz, initrd_path)
234         self.vm.set_console()
235         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
236                                + 'console=ttyS0 console=tty '
237                                + 'rdinit=/sbin/init noreboot')
238         self.vm.add_args('-cpu', '5KEc',
239                          '-kernel', kernel_path,
240                          '-initrd', initrd_path,
241                          '-append', kernel_command_line,
242                          '-no-reboot')
243         self.vm.launch()
244         wait_for_console_pattern(self, 'Boot successful.')
246         exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
247                                                 'MIPS 5KE')
248         exec_command_and_wait_for_pattern(self, 'uname -a',
249                                                 '3.19.3.mtoman.20150408')
250         exec_command_and_wait_for_pattern(self, 'reboot',
251                                                 'reboot: Restarting system')
252         # Wait for VM to shut down gracefully
253         self.vm.wait()
255     def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
256         kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
257         kernel_path = self.workdir + "kernel"
258         with lzma.open(kernel_path_xz, 'rb') as f_in:
259             with open(kernel_path, 'wb') as f_out:
260                 shutil.copyfileobj(f_in, f_out)
262         self.vm.set_console()
263         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
264                                + 'mem=256m@@0x0 '
265                                + 'console=ttyS0')
266         self.vm.add_args('-no-reboot',
267                          '-cpu', 'I7200',
268                          '-kernel', kernel_path,
269                          '-append', kernel_command_line)
270         self.vm.launch()
271         console_pattern = 'Kernel command line: %s' % kernel_command_line
272         self.wait_for_console_pattern(console_pattern)
274     def test_mips_malta32el_nanomips_4k(self):
275         """
276         :avocado: tags=arch:mipsel
277         :avocado: tags=machine:malta
278         :avocado: tags=endian:little
279         """
280         kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
281                       'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
282                       'generic_nano32r6el_page4k.xz')
283         kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6'
284         self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
286     def test_mips_malta32el_nanomips_16k_up(self):
287         """
288         :avocado: tags=arch:mipsel
289         :avocado: tags=machine:malta
290         :avocado: tags=endian:little
291         """
292         kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
293                       'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
294                       'generic_nano32r6el_page16k_up.xz')
295         kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc'
296         self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
298     def test_mips_malta32el_nanomips_64k_dbg(self):
299         """
300         :avocado: tags=arch:mipsel
301         :avocado: tags=machine:malta
302         :avocado: tags=endian:little
303         """
304         kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
305                       'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
306                       'generic_nano32r6el_page64k_dbg.xz')
307         kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
308         self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
310     def test_aarch64_virt(self):
311         """
312         :avocado: tags=arch:aarch64
313         :avocado: tags=machine:virt
314         """
315         kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
316                       '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
317                       '/vmlinuz')
318         kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
319         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
321         self.vm.set_console()
322         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
323                                'console=ttyAMA0')
324         self.vm.add_args('-cpu', 'cortex-a53',
325                          '-kernel', kernel_path,
326                          '-append', kernel_command_line)
327         self.vm.launch()
328         console_pattern = 'Kernel command line: %s' % kernel_command_line
329         self.wait_for_console_pattern(console_pattern)
331     def test_aarch64_xlnx_versal_virt(self):
332         """
333         :avocado: tags=arch:aarch64
334         :avocado: tags=machine:xlnx-versal-virt
335         :avocado: tags=device:pl011
336         :avocado: tags=device:arm_gicv3
337         """
338         images_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/'
339                       'bionic-updates/main/installer-arm64/'
340                       '20101020ubuntu543.15/images/')
341         kernel_url = images_url + 'netboot/ubuntu-installer/arm64/linux'
342         kernel_hash = '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50'
343         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
345         initrd_url = images_url + 'netboot/ubuntu-installer/arm64/initrd.gz'
346         initrd_hash = 'd385d3e88d53e2004c5d43cbe668b458a094f772'
347         initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
349         self.vm.set_console()
350         self.vm.add_args('-m', '2G',
351                          '-kernel', kernel_path,
352                          '-initrd', initrd_path)
353         self.vm.launch()
354         self.wait_for_console_pattern('Checked W+X mappings: passed')
356     def test_arm_virt(self):
357         """
358         :avocado: tags=arch:arm
359         :avocado: tags=machine:virt
360         """
361         kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
362                       '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
363                       '/vmlinuz')
364         kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
365         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
367         self.vm.set_console()
368         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
369                                'console=ttyAMA0')
370         self.vm.add_args('-kernel', kernel_path,
371                          '-append', kernel_command_line)
372         self.vm.launch()
373         console_pattern = 'Kernel command line: %s' % kernel_command_line
374         self.wait_for_console_pattern(console_pattern)
376     def test_arm_emcraft_sf2(self):
377         """
378         :avocado: tags=arch:arm
379         :avocado: tags=machine:emcraft-sf2
380         :avocado: tags=endian:little
381         :avocado: tags=u-boot
382         """
383         uboot_url = ('https://raw.githubusercontent.com/'
384                      'Subbaraya-Sundeep/qemu-test-binaries/'
385                      'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot')
386         uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2'
387         uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash)
388         spi_url = ('https://raw.githubusercontent.com/'
389                    'Subbaraya-Sundeep/qemu-test-binaries/'
390                    'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin')
391         spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501'
392         spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
394         self.vm.set_console()
395         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
396         self.vm.add_args('-kernel', uboot_path,
397                          '-append', kernel_command_line,
398                          '-drive', 'file=' + spi_path + ',if=mtd,format=raw',
399                          '-no-reboot')
400         self.vm.launch()
401         self.wait_for_console_pattern('Enter \'help\' for a list')
403         exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15',
404                                                  'eth0: link becomes ready')
405         exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
406             '3 packets transmitted, 3 packets received, 0% packet loss')
408     def do_test_arm_raspi2(self, uart_id):
409         """
410         The kernel can be rebuilt using the kernel source referenced
411         and following the instructions on the on:
412         https://www.raspberrypi.org/documentation/linux/kernel/building.md
413         """
414         serial_kernel_cmdline = {
415             0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
416         }
417         deb_url = ('http://archive.raspberrypi.org/debian/'
418                    'pool/main/r/raspberrypi-firmware/'
419                    'raspberrypi-kernel_1.20190215-1_armhf.deb')
420         deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
421         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
422         kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
423         dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
425         self.vm.set_console()
426         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
427                                serial_kernel_cmdline[uart_id] +
428                                ' root=/dev/mmcblk0p2 rootwait ' +
429                                'dwc_otg.fiq_fsm_enable=0')
430         self.vm.add_args('-kernel', kernel_path,
431                          '-dtb', dtb_path,
432                          '-append', kernel_command_line,
433                          '-device', 'usb-kbd')
434         self.vm.launch()
435         console_pattern = 'Kernel command line: %s' % kernel_command_line
436         self.wait_for_console_pattern(console_pattern)
437         console_pattern = 'Product: QEMU USB Keyboard'
438         self.wait_for_console_pattern(console_pattern)
440     def test_arm_raspi2_uart0(self):
441         """
442         :avocado: tags=arch:arm
443         :avocado: tags=machine:raspi2
444         :avocado: tags=device:pl011
445         """
446         self.do_test_arm_raspi2(0)
448     def test_arm_exynos4210_initrd(self):
449         """
450         :avocado: tags=arch:arm
451         :avocado: tags=machine:smdkc210
452         """
453         deb_url = ('https://snapshot.debian.org/archive/debian/'
454                    '20190928T224601Z/pool/main/l/linux/'
455                    'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
456         deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
457         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
458         kernel_path = self.extract_from_deb(deb_path,
459                                             '/boot/vmlinuz-4.19.0-6-armmp')
460         dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
461         dtb_path = self.extract_from_deb(deb_path, dtb_path)
463         initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
464                       '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
465                       'arm/rootfs-armv5.cpio.gz')
466         initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
467         initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
468         initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
469         archive.gzip_uncompress(initrd_path_gz, initrd_path)
471         self.vm.set_console()
472         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
473                                'earlycon=exynos4210,0x13800000 earlyprintk ' +
474                                'console=ttySAC0,115200n8 ' +
475                                'random.trust_cpu=off cryptomgr.notests ' +
476                                'cpuidle.off=1 panic=-1 noreboot')
478         self.vm.add_args('-kernel', kernel_path,
479                          '-dtb', dtb_path,
480                          '-initrd', initrd_path,
481                          '-append', kernel_command_line,
482                          '-no-reboot')
483         self.vm.launch()
485         self.wait_for_console_pattern('Boot successful.')
486         # TODO user command, for now the uart is stuck
488     @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
489                 'Test artifacts fetched from unreliable apt.armbian.com')
490     def test_arm_cubieboard_initrd(self):
491         """
492         :avocado: tags=arch:arm
493         :avocado: tags=machine:cubieboard
494         """
495         deb_url = ('https://apt.armbian.com/pool/main/l/'
496                    'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
497         deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
498         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
499         kernel_path = self.extract_from_deb(deb_path,
500                                             '/boot/vmlinuz-4.20.7-sunxi')
501         dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
502         dtb_path = self.extract_from_deb(deb_path, dtb_path)
503         initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
504                       '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
505                       'arm/rootfs-armv5.cpio.gz')
506         initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
507         initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
508         initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
509         archive.gzip_uncompress(initrd_path_gz, initrd_path)
511         self.vm.set_console()
512         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
513                                'console=ttyS0,115200 '
514                                'usbcore.nousb '
515                                'panic=-1 noreboot')
516         self.vm.add_args('-kernel', kernel_path,
517                          '-dtb', dtb_path,
518                          '-initrd', initrd_path,
519                          '-append', kernel_command_line,
520                          '-no-reboot')
521         self.vm.launch()
522         self.wait_for_console_pattern('Boot successful.')
524         exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
525                                                 'Allwinner sun4i/sun5i')
526         exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
527                                                 'system-control@1c00000')
528         # cubieboard's reboot is not functioning; omit reboot test.
530     @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
531                 'Test artifacts fetched from unreliable apt.armbian.com')
532     def test_arm_cubieboard_sata(self):
533         """
534         :avocado: tags=arch:arm
535         :avocado: tags=machine:cubieboard
536         """
537         deb_url = ('https://apt.armbian.com/pool/main/l/'
538                    'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
539         deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
540         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
541         kernel_path = self.extract_from_deb(deb_path,
542                                             '/boot/vmlinuz-4.20.7-sunxi')
543         dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
544         dtb_path = self.extract_from_deb(deb_path, dtb_path)
545         rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
546                       '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
547                       'arm/rootfs-armv5.ext2.gz')
548         rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
549         rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
550         rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
551         archive.gzip_uncompress(rootfs_path_gz, rootfs_path)
553         self.vm.set_console()
554         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
555                                'console=ttyS0,115200 '
556                                'usbcore.nousb '
557                                'root=/dev/sda ro '
558                                'panic=-1 noreboot')
559         self.vm.add_args('-kernel', kernel_path,
560                          '-dtb', dtb_path,
561                          '-drive', 'if=none,format=raw,id=disk0,file='
562                                    + rootfs_path,
563                          '-device', 'ide-hd,bus=ide.0,drive=disk0',
564                          '-append', kernel_command_line,
565                          '-no-reboot')
566         self.vm.launch()
567         self.wait_for_console_pattern('Boot successful.')
569         exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
570                                                 'Allwinner sun4i/sun5i')
571         exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
572                                                 'sda')
573         # cubieboard's reboot is not functioning; omit reboot test.
575     @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
576     def test_arm_quanta_gsj(self):
577         """
578         :avocado: tags=arch:arm
579         :avocado: tags=machine:quanta-gsj
580         """
581         # 25 MiB compressed, 32 MiB uncompressed.
582         image_url = (
583                 'https://github.com/hskinnemoen/openbmc/releases/download/'
584                 '20200711-gsj-qemu-0/obmc-phosphor-image-gsj.static.mtd.gz')
585         image_hash = '14895e634923345cb5c8776037ff7876df96f6b1'
586         image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash)
587         image_name = 'obmc.mtd'
588         image_path = os.path.join(self.workdir, image_name)
589         archive.gzip_uncompress(image_path_gz, image_path)
591         self.vm.set_console()
592         drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0'
593         self.vm.add_args('-drive', drive_args)
594         self.vm.launch()
596         # Disable drivers and services that stall for a long time during boot,
597         # to avoid running past the 90-second timeout. These may be removed
598         # as the corresponding device support is added.
599         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + (
600                 'console=${console} '
601                 'mem=${mem} '
602                 'initcall_blacklist=npcm_i2c_bus_driver_init '
603                 'systemd.mask=systemd-random-seed.service '
604                 'systemd.mask=dropbearkey.service '
605         )
607         self.wait_for_console_pattern('> BootBlock by Nuvoton')
608         self.wait_for_console_pattern('>Device: Poleg BMC NPCM730')
609         self.wait_for_console_pattern('>Skip DDR init.')
610         self.wait_for_console_pattern('U-Boot ')
611         interrupt_interactive_console_until_pattern(
612                 self, 'Hit any key to stop autoboot:', 'U-Boot>')
613         exec_command_and_wait_for_pattern(
614                 self, "setenv bootargs ${bootargs} " + kernel_command_line,
615                 'U-Boot>')
616         exec_command_and_wait_for_pattern(
617                 self, 'run romboot', 'Booting Kernel from flash')
618         self.wait_for_console_pattern('Booting Linux on physical CPU 0x0')
619         self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0')
620         self.wait_for_console_pattern('OpenBMC Project Reference Distro')
621         self.wait_for_console_pattern('gsj login:')
623     def test_arm_quanta_gsj_initrd(self):
624         """
625         :avocado: tags=arch:arm
626         :avocado: tags=machine:quanta-gsj
627         """
628         initrd_url = (
629                 'https://github.com/hskinnemoen/openbmc/releases/download/'
630                 '20200711-gsj-qemu-0/obmc-phosphor-initramfs-gsj.cpio.xz')
631         initrd_hash = '98fefe5d7e56727b1eb17d5c00311b1b5c945300'
632         initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
633         kernel_url = (
634                 'https://github.com/hskinnemoen/openbmc/releases/download/'
635                 '20200711-gsj-qemu-0/uImage-gsj.bin')
636         kernel_hash = 'fa67b2f141d56d39b3c54305c0e8a899c99eb2c7'
637         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
638         dtb_url = (
639                 'https://github.com/hskinnemoen/openbmc/releases/download/'
640                 '20200711-gsj-qemu-0/nuvoton-npcm730-gsj.dtb')
641         dtb_hash = '18315f7006d7b688d8312d5c727eecd819aa36a4'
642         dtb_path = self.fetch_asset(dtb_url, asset_hash=dtb_hash)
644         self.vm.set_console()
645         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
646                                'console=ttyS0,115200n8 '
647                                'earlycon=uart8250,mmio32,0xf0001000')
648         self.vm.add_args('-kernel', kernel_path,
649                          '-initrd', initrd_path,
650                          '-dtb', dtb_path,
651                          '-append', kernel_command_line)
652         self.vm.launch()
654         self.wait_for_console_pattern('Booting Linux on physical CPU 0x0')
655         self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0')
656         self.wait_for_console_pattern(
657                 'Give root password for system maintenance')
659     @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
660                 'Test artifacts fetched from unreliable apt.armbian.com')
661     def test_arm_orangepi(self):
662         """
663         :avocado: tags=arch:arm
664         :avocado: tags=machine:orangepi-pc
665         """
666         deb_url = ('https://apt.armbian.com/pool/main/l/'
667                    'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
668         deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
669         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
670         kernel_path = self.extract_from_deb(deb_path,
671                                             '/boot/vmlinuz-4.20.7-sunxi')
672         dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
673         dtb_path = self.extract_from_deb(deb_path, dtb_path)
675         self.vm.set_console()
676         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
677                                'console=ttyS0,115200n8 '
678                                'earlycon=uart,mmio32,0x1c28000')
679         self.vm.add_args('-kernel', kernel_path,
680                          '-dtb', dtb_path,
681                          '-append', kernel_command_line)
682         self.vm.launch()
683         console_pattern = 'Kernel command line: %s' % kernel_command_line
684         self.wait_for_console_pattern(console_pattern)
686     @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
687                 'Test artifacts fetched from unreliable apt.armbian.com')
688     def test_arm_orangepi_initrd(self):
689         """
690         :avocado: tags=arch:arm
691         :avocado: tags=machine:orangepi-pc
692         """
693         deb_url = ('https://apt.armbian.com/pool/main/l/'
694                    'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
695         deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
696         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
697         kernel_path = self.extract_from_deb(deb_path,
698                                             '/boot/vmlinuz-4.20.7-sunxi')
699         dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
700         dtb_path = self.extract_from_deb(deb_path, dtb_path)
701         initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
702                       '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
703                       'arm/rootfs-armv7a.cpio.gz')
704         initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
705         initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
706         initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
707         archive.gzip_uncompress(initrd_path_gz, initrd_path)
709         self.vm.set_console()
710         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
711                                'console=ttyS0,115200 '
712                                'panic=-1 noreboot')
713         self.vm.add_args('-kernel', kernel_path,
714                          '-dtb', dtb_path,
715                          '-initrd', initrd_path,
716                          '-append', kernel_command_line,
717                          '-no-reboot')
718         self.vm.launch()
719         self.wait_for_console_pattern('Boot successful.')
721         exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
722                                                 'Allwinner sun8i Family')
723         exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
724                                                 'system-control@1c00000')
725         exec_command_and_wait_for_pattern(self, 'reboot',
726                                                 'reboot: Restarting system')
727         # Wait for VM to shut down gracefully
728         self.vm.wait()
730     @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
731                 'Test artifacts fetched from unreliable apt.armbian.com')
732     def test_arm_orangepi_sd(self):
733         """
734         :avocado: tags=arch:arm
735         :avocado: tags=machine:orangepi-pc
736         :avocado: tags=device:sd
737         """
738         deb_url = ('https://apt.armbian.com/pool/main/l/'
739                    'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
740         deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
741         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
742         kernel_path = self.extract_from_deb(deb_path,
743                                             '/boot/vmlinuz-4.20.7-sunxi')
744         dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
745         dtb_path = self.extract_from_deb(deb_path, dtb_path)
746         rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/'
747                       'kci-2019.02/armel/base/rootfs.ext2.xz')
748         rootfs_hash = '692510cb625efda31640d1de0a8d60e26040f061'
749         rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
750         rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
751         archive.lzma_uncompress(rootfs_path_xz, rootfs_path)
752         image_pow2ceil_expand(rootfs_path)
754         self.vm.set_console()
755         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
756                                'console=ttyS0,115200 '
757                                'root=/dev/mmcblk0 rootwait rw '
758                                'panic=-1 noreboot')
759         self.vm.add_args('-kernel', kernel_path,
760                          '-dtb', dtb_path,
761                          '-drive', 'file=' + rootfs_path + ',if=sd,format=raw',
762                          '-append', kernel_command_line,
763                          '-no-reboot')
764         self.vm.launch()
765         shell_ready = "/bin/sh: can't access tty; job control turned off"
766         self.wait_for_console_pattern(shell_ready)
768         exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
769                                                 'Allwinner sun8i Family')
770         exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
771                                                 'mmcblk0')
772         exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up',
773                                                  'eth0: Link is Up')
774         exec_command_and_wait_for_pattern(self, 'udhcpc eth0',
775             'udhcpc: lease of 10.0.2.15 obtained')
776         exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
777             '3 packets transmitted, 3 packets received, 0% packet loss')
778         exec_command_and_wait_for_pattern(self, 'reboot',
779                                                 'reboot: Restarting system')
780         # Wait for VM to shut down gracefully
781         self.vm.wait()
783     @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
784     @skipUnless(P7ZIP_AVAILABLE, '7z not installed')
785     def test_arm_orangepi_bionic(self):
786         """
787         :avocado: tags=arch:arm
788         :avocado: tags=machine:orangepi-pc
789         :avocado: tags=device:sd
790         """
792         # This test download a 196MB compressed image and expand it to 1GB
793         image_url = ('https://dl.armbian.com/orangepipc/archive/'
794                      'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
795         image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e'
796         image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash)
797         image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
798         image_path = os.path.join(self.workdir, image_name)
799         process.run("7z e -o%s %s" % (self.workdir, image_path_7z))
800         image_pow2ceil_expand(image_path)
802         self.vm.set_console()
803         self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
804                          '-nic', 'user',
805                          '-no-reboot')
806         self.vm.launch()
808         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
809                                'console=ttyS0,115200 '
810                                'loglevel=7 '
811                                'nosmp '
812                                'systemd.default_timeout_start_sec=9000 '
813                                'systemd.mask=armbian-zram-config.service '
814                                'systemd.mask=armbian-ramlog.service')
816         self.wait_for_console_pattern('U-Boot SPL')
817         self.wait_for_console_pattern('Autoboot in ')
818         exec_command_and_wait_for_pattern(self, ' ', '=>')
819         exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
820                                                 kernel_command_line + "'", '=>')
821         exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...');
823         self.wait_for_console_pattern('systemd[1]: Set hostname ' +
824                                       'to <orangepipc>')
825         self.wait_for_console_pattern('Starting Load Kernel Modules...')
827     @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
828     def test_arm_orangepi_uboot_netbsd9(self):
829         """
830         :avocado: tags=arch:arm
831         :avocado: tags=machine:orangepi-pc
832         :avocado: tags=device:sd
833         """
834         # This test download a 304MB compressed image and expand it to 2GB
835         deb_url = ('http://snapshot.debian.org/archive/debian/'
836                    '20200108T145233Z/pool/main/u/u-boot/'
837                    'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
838         deb_hash = 'f67f404a80753ca3d1258f13e38f2b060e13db99'
839         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
840         # We use the common OrangePi PC 'plus' build of U-Boot for our secondary
841         # program loader (SPL). We will then set the path to the more specific
842         # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt,
843         # before to boot NetBSD.
844         uboot_path = '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin'
845         uboot_path = self.extract_from_deb(deb_path, uboot_path)
846         image_url = ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/'
847                      'evbarm-earmv7hf/binary/gzimg/armv7.img.gz')
848         image_hash = '2babb29d36d8360adcb39c09e31060945259917a'
849         image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash)
850         image_path = os.path.join(self.workdir, 'armv7.img')
851         archive.gzip_uncompress(image_path_gz, image_path)
852         image_pow2ceil_expand(image_path)
853         image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path
855         # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
856         with open(uboot_path, 'rb') as f_in:
857             with open(image_path, 'r+b') as f_out:
858                 f_out.seek(8 * 1024)
859                 shutil.copyfileobj(f_in, f_out)
861         self.vm.set_console()
862         self.vm.add_args('-nic', 'user',
863                          '-drive', image_drive_args,
864                          '-global', 'allwinner-rtc.base-year=2000',
865                          '-no-reboot')
866         self.vm.launch()
867         wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1')
868         interrupt_interactive_console_until_pattern(self,
869                                        'Hit any key to stop autoboot:',
870                                        'switch to partitions #0, OK')
872         exec_command_and_wait_for_pattern(self, '', '=>')
873         cmd = 'setenv bootargs root=ld0a'
874         exec_command_and_wait_for_pattern(self, cmd, '=>')
875         cmd = 'setenv kernel netbsd-GENERIC.ub'
876         exec_command_and_wait_for_pattern(self, cmd, '=>')
877         cmd = 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb'
878         exec_command_and_wait_for_pattern(self, cmd, '=>')
879         cmd = ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; "
880                "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; "
881                "fdt addr ${fdt_addr_r}; "
882                "bootm ${kernel_addr_r} - ${fdt_addr_r}'")
883         exec_command_and_wait_for_pattern(self, cmd, '=>')
885         exec_command_and_wait_for_pattern(self, 'boot',
886                                           'Booting kernel from Legacy Image')
887         wait_for_console_pattern(self, 'Starting kernel ...')
888         wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)')
889         # Wait for user-space
890         wait_for_console_pattern(self, 'Starting root file system check')
892     def test_s390x_s390_ccw_virtio(self):
893         """
894         :avocado: tags=arch:s390x
895         :avocado: tags=machine:s390-ccw-virtio
896         """
897         kernel_url = ('https://archives.fedoraproject.org/pub/archive'
898                       '/fedora-secondary/releases/29/Everything/s390x/os/images'
899                       '/kernel.img')
900         kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
901         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
903         self.vm.set_console()
904         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
905         self.vm.add_args('-nodefaults',
906                          '-kernel', kernel_path,
907                          '-append', kernel_command_line)
908         self.vm.launch()
909         console_pattern = 'Kernel command line: %s' % kernel_command_line
910         self.wait_for_console_pattern(console_pattern)
912     def test_alpha_clipper(self):
913         """
914         :avocado: tags=arch:alpha
915         :avocado: tags=machine:clipper
916         """
917         kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
918                       'installer-alpha/20090123lenny10/images/cdrom/vmlinuz')
919         kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
920         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
922         uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
924         self.vm.set_console()
925         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
926         self.vm.add_args('-nodefaults',
927                          '-kernel', uncompressed_kernel,
928                          '-append', kernel_command_line)
929         self.vm.launch()
930         console_pattern = 'Kernel command line: %s' % kernel_command_line
931         self.wait_for_console_pattern(console_pattern)
933     def test_ppc64_pseries(self):
934         """
935         :avocado: tags=arch:ppc64
936         :avocado: tags=machine:pseries
937         """
938         kernel_url = ('https://archives.fedoraproject.org/pub/archive'
939                       '/fedora-secondary/releases/29/Everything/ppc64le/os'
940                       '/ppc/ppc64/vmlinuz')
941         kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
942         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
944         self.vm.set_console()
945         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
946         self.vm.add_args('-kernel', kernel_path,
947                          '-append', kernel_command_line)
948         self.vm.launch()
949         console_pattern = 'Kernel command line: %s' % kernel_command_line
950         self.wait_for_console_pattern(console_pattern)
952     def test_m68k_q800(self):
953         """
954         :avocado: tags=arch:m68k
955         :avocado: tags=machine:q800
956         """
957         deb_url = ('https://snapshot.debian.org/archive/debian-ports'
958                    '/20191021T083923Z/pool-m68k/main'
959                    '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
960         deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
961         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
962         kernel_path = self.extract_from_deb(deb_path,
963                                             '/boot/vmlinux-5.3.0-1-m68k')
965         self.vm.set_console()
966         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
967                                'console=ttyS0 vga=off')
968         self.vm.add_args('-kernel', kernel_path,
969                          '-append', kernel_command_line)
970         self.vm.launch()
971         console_pattern = 'Kernel command line: %s' % kernel_command_line
972         self.wait_for_console_pattern(console_pattern)
973         console_pattern = 'No filesystem could mount root'
974         self.wait_for_console_pattern(console_pattern)
976     def do_test_advcal_2018(self, day, tar_hash, kernel_name, console=0):
977         tar_url = ('https://www.qemu-advent-calendar.org'
978                    '/2018/download/day' + day + '.tar.xz')
979         file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
980         archive.extract(file_path, self.workdir)
981         self.vm.set_console(console_index=console)
982         self.vm.add_args('-kernel',
983                          self.workdir + '/day' + day + '/' + kernel_name)
984         self.vm.launch()
985         self.wait_for_console_pattern('QEMU advent calendar')
987     def test_arm_vexpressa9(self):
988         """
989         :avocado: tags=arch:arm
990         :avocado: tags=machine:vexpress-a9
991         """
992         tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
993         self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb')
994         self.do_test_advcal_2018('16', tar_hash, 'winter.zImage')
996     def test_m68k_mcf5208evb(self):
997         """
998         :avocado: tags=arch:m68k
999         :avocado: tags=machine:mcf5208evb
1000         """
1001         tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
1002         self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf')
1004     def test_microblaze_s3adsp1800(self):
1005         """
1006         :avocado: tags=arch:microblaze
1007         :avocado: tags=machine:petalogix-s3adsp1800
1008         """
1009         tar_hash = '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
1010         self.do_test_advcal_2018('17', tar_hash, 'ballerina.bin')
1012     def test_or1k_sim(self):
1013         """
1014         :avocado: tags=arch:or1k
1015         :avocado: tags=machine:or1k-sim
1016         """
1017         tar_hash = '20334cdaf386108c530ff0badaecc955693027dd'
1018         self.do_test_advcal_2018('20', tar_hash, 'vmlinux')
1020     def test_nios2_10m50(self):
1021         """
1022         :avocado: tags=arch:nios2
1023         :avocado: tags=machine:10m50-ghrd
1024         """
1025         tar_hash = 'e4251141726c412ac0407c5a6bceefbbff018918'
1026         self.do_test_advcal_2018('14', tar_hash, 'vmlinux.elf')
1028     def test_ppc64_e500(self):
1029         """
1030         :avocado: tags=arch:ppc64
1031         :avocado: tags=machine:ppce500
1032         """
1033         tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
1034         self.vm.add_args('-cpu', 'e5500')
1035         self.do_test_advcal_2018('19', tar_hash, 'uImage')
1037     def test_ppc_g3beige(self):
1038         """
1039         :avocado: tags=arch:ppc
1040         :avocado: tags=machine:g3beige
1041         """
1042         tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
1043         self.vm.add_args('-M', 'graphics=off')
1044         self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
1046     def test_ppc_mac99(self):
1047         """
1048         :avocado: tags=arch:ppc
1049         :avocado: tags=machine:mac99
1050         """
1051         tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
1052         self.vm.add_args('-M', 'graphics=off')
1053         self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
1055     def test_sh4_r2d(self):
1056         """
1057         :avocado: tags=arch:sh4
1058         :avocado: tags=machine:r2d
1059         """
1060         tar_hash = 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
1061         self.vm.add_args('-append', 'console=ttySC1')
1062         self.do_test_advcal_2018('09', tar_hash, 'zImage', console=1)
1064     def test_sparc_ss20(self):
1065         """
1066         :avocado: tags=arch:sparc
1067         :avocado: tags=machine:SS-20
1068         """
1069         tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
1070         self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
1072     def test_xtensa_lx60(self):
1073         """
1074         :avocado: tags=arch:xtensa
1075         :avocado: tags=machine:lx60
1076         """
1077         tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
1078         self.vm.add_args('-cpu', 'dc233c')
1079         self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')