xref: /openbmc/qemu/tests/avocado/replay_kernel.py (revision 4926b6e6)
1# Record/replay test that boots a Linux kernel
2#
3# Copyright (c) 2020 ISP RAS
4#
5# Author:
6#  Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
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
11import os
12import lzma
13import shutil
14import logging
15import time
16import subprocess
17
18from avocado import skip
19from avocado import skipUnless
20from avocado import skipUnless
21from avocado_qemu import wait_for_console_pattern
22from avocado.utils import archive
23from avocado.utils import process
24from boot_linux_console import LinuxKernelTest
25
26class ReplayKernelBase(LinuxKernelTest):
27    """
28    Boots a Linux kernel in record mode and checks that the console
29    is operational and the kernel command line is properly passed
30    from QEMU to the kernel.
31    Then replays the same scenario and verifies, that QEMU correctly
32    terminates.
33    """
34
35    timeout = 180
36    KERNEL_COMMON_COMMAND_LINE = 'printk.time=1 panic=-1 '
37
38    def run_vm(self, kernel_path, kernel_command_line, console_pattern,
39               record, shift, args, replay_path):
40        # icount requires TCG to be available
41        self.require_accelerator('tcg')
42
43        logger = logging.getLogger('replay')
44        start_time = time.time()
45        vm = self.get_vm()
46        vm.set_console()
47        if record:
48            logger.info('recording the execution...')
49            mode = 'record'
50        else:
51            logger.info('replaying the execution...')
52            mode = 'replay'
53        vm.add_args('-icount', 'shift=%s,rr=%s,rrfile=%s' %
54                    (shift, mode, replay_path),
55                    '-kernel', kernel_path,
56                    '-append', kernel_command_line,
57                    '-net', 'none',
58                    '-no-reboot')
59        if args:
60            vm.add_args(*args)
61        vm.launch()
62        self.wait_for_console_pattern(console_pattern, vm)
63        if record:
64            vm.shutdown()
65            logger.info('finished the recording with log size %s bytes'
66                        % os.path.getsize(replay_path))
67            self.run_replay_dump(replay_path)
68            logger.info('successfully tested replay-dump.py')
69        else:
70            vm.wait()
71            logger.info('successfully finished the replay')
72        elapsed = time.time() - start_time
73        logger.info('elapsed time %.2f sec' % elapsed)
74        return elapsed
75
76    def run_replay_dump(self, replay_path):
77        try:
78            subprocess.check_call(["./scripts/replay-dump.py",
79                                   "-f", replay_path],
80                                  stdout=subprocess.DEVNULL)
81        except subprocess.CalledProcessError:
82            self.fail('replay-dump.py failed')
83
84    def run_rr(self, kernel_path, kernel_command_line, console_pattern,
85               shift=7, args=None):
86        replay_path = os.path.join(self.workdir, 'replay.bin')
87        t1 = self.run_vm(kernel_path, kernel_command_line, console_pattern,
88                         True, shift, args, replay_path)
89        t2 = self.run_vm(kernel_path, kernel_command_line, console_pattern,
90                         False, shift, args, replay_path)
91        logger = logging.getLogger('replay')
92        logger.info('replay overhead {:.2%}'.format(t2 / t1 - 1))
93
94class ReplayKernelNormal(ReplayKernelBase):
95
96    def test_i386_pc(self):
97        """
98        :avocado: tags=arch:i386
99        :avocado: tags=machine:pc
100        """
101        kernel_url = ('https://storage.tuxboot.com/20230331/i386/bzImage')
102        kernel_hash = 'a3e5b32a354729e65910f5a1ffcda7c14a6c12a55e8213fb86e277f1b76ed956'
103        kernel_path = self.fetch_asset(kernel_url,
104                                       asset_hash=kernel_hash,
105                                       algorithm = "sha256")
106
107        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
108        console_pattern = 'VFS: Cannot open root device'
109
110        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
111
112    # See https://gitlab.com/qemu-project/qemu/-/issues/2094
113    @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test sometimes gets stuck')
114    def test_x86_64_pc(self):
115        """
116        :avocado: tags=arch:x86_64
117        :avocado: tags=machine:pc
118        :avocado: tags=flaky
119        """
120        kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
121                      '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
122                      '/vmlinuz')
123        kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
124        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
125
126        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
127        console_pattern = 'VFS: Cannot open root device'
128
129        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
130
131    def test_mips_malta(self):
132        """
133        :avocado: tags=arch:mips
134        :avocado: tags=machine:malta
135        :avocado: tags=endian:big
136        """
137        deb_url = ('http://snapshot.debian.org/archive/debian/'
138                   '20130217T032700Z/pool/main/l/linux-2.6/'
139                   'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
140        deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
141        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
142        kernel_path = self.extract_from_deb(deb_path,
143                                            '/boot/vmlinux-2.6.32-5-4kc-malta')
144        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
145        console_pattern = 'Kernel command line: %s' % kernel_command_line
146
147        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
148
149    def test_mips64el_malta(self):
150        """
151        This test requires the ar tool to extract "data.tar.gz" from
152        the Debian package.
153
154        The kernel can be rebuilt using this Debian kernel source [1] and
155        following the instructions on [2].
156
157        [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
158            #linux-source-2.6.32_2.6.32-48
159        [2] https://kernel-team.pages.debian.net/kernel-handbook/
160            ch-common-tasks.html#s-common-official
161
162        :avocado: tags=arch:mips64el
163        :avocado: tags=machine:malta
164        """
165        deb_url = ('http://snapshot.debian.org/archive/debian/'
166                   '20130217T032700Z/pool/main/l/linux-2.6/'
167                   'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
168        deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
169        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
170        kernel_path = self.extract_from_deb(deb_path,
171                                            '/boot/vmlinux-2.6.32-5-5kc-malta')
172        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
173        console_pattern = 'Kernel command line: %s' % kernel_command_line
174        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
175
176    def test_aarch64_virt(self):
177        """
178        :avocado: tags=arch:aarch64
179        :avocado: tags=machine:virt
180        :avocado: tags=cpu:cortex-a53
181        """
182        kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
183                      '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
184                      '/vmlinuz')
185        kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
186        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
187
188        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
189                               'console=ttyAMA0')
190        console_pattern = 'VFS: Cannot open root device'
191
192        self.run_rr(kernel_path, kernel_command_line, console_pattern)
193
194    def test_arm_virt(self):
195        """
196        :avocado: tags=arch:arm
197        :avocado: tags=machine:virt
198        """
199        kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
200                      '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
201                      '/vmlinuz')
202        kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
203        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
204
205        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
206                               'console=ttyAMA0')
207        console_pattern = 'VFS: Cannot open root device'
208
209        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1)
210
211    def test_arm_cubieboard_initrd(self):
212        """
213        :avocado: tags=arch:arm
214        :avocado: tags=machine:cubieboard
215        """
216        deb_url = ('https://apt.armbian.com/pool/main/l/'
217                   'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb')
218        deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b'
219        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
220        kernel_path = self.extract_from_deb(deb_path,
221                                            '/boot/vmlinuz-6.6.16-current-sunxi')
222        dtb_path = '/usr/lib/linux-image-6.6.16-current-sunxi/sun4i-a10-cubieboard.dtb'
223        dtb_path = self.extract_from_deb(deb_path, dtb_path)
224        initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
225                      '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
226                      'arm/rootfs-armv5.cpio.gz')
227        initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
228        initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
229        initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
230        archive.gzip_uncompress(initrd_path_gz, initrd_path)
231
232        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
233                               'console=ttyS0,115200 '
234                               'usbcore.nousb '
235                               'panic=-1 noreboot')
236        console_pattern = 'Boot successful.'
237        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1,
238                    args=('-dtb', dtb_path,
239                          '-initrd', initrd_path,
240                          '-no-reboot'))
241
242    def test_s390x_s390_ccw_virtio(self):
243        """
244        :avocado: tags=arch:s390x
245        :avocado: tags=machine:s390-ccw-virtio
246        """
247        kernel_url = ('https://archives.fedoraproject.org/pub/archive'
248                      '/fedora-secondary/releases/29/Everything/s390x/os/images'
249                      '/kernel.img')
250        kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
251        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
252
253        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
254        console_pattern = 'Kernel command line: %s' % kernel_command_line
255        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=9)
256
257    def test_alpha_clipper(self):
258        """
259        :avocado: tags=arch:alpha
260        :avocado: tags=machine:clipper
261        """
262        kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
263                      'installer-alpha/20090123lenny10/images/cdrom/vmlinuz')
264        kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
265        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
266
267        uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
268
269        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
270        console_pattern = 'Kernel command line: %s' % kernel_command_line
271        self.run_rr(uncompressed_kernel, kernel_command_line, console_pattern, shift=9,
272            args=('-nodefaults', ))
273
274    def test_ppc64_pseries(self):
275        """
276        :avocado: tags=arch:ppc64
277        :avocado: tags=machine:pseries
278        :avocado: tags=accel:tcg
279        """
280        kernel_url = ('https://archives.fedoraproject.org/pub/archive'
281                      '/fedora-secondary/releases/29/Everything/ppc64le/os'
282                      '/ppc/ppc64/vmlinuz')
283        kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
284        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
285
286        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
287        console_pattern = 'VFS: Cannot open root device'
288        self.run_rr(kernel_path, kernel_command_line, console_pattern)
289
290    def test_ppc64_powernv(self):
291        """
292        :avocado: tags=arch:ppc64
293        :avocado: tags=machine:powernv
294        :avocado: tags=accel:tcg
295        """
296        kernel_url = ('https://archives.fedoraproject.org/pub/archive'
297                      '/fedora-secondary/releases/29/Everything/ppc64le/os'
298                      '/ppc/ppc64/vmlinuz')
299        kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
300        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
301
302        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + \
303                              'console=tty0 console=hvc0'
304        console_pattern = 'VFS: Cannot open root device'
305        self.run_rr(kernel_path, kernel_command_line, console_pattern)
306
307    def test_m68k_q800(self):
308        """
309        :avocado: tags=arch:m68k
310        :avocado: tags=machine:q800
311        """
312        deb_url = ('https://snapshot.debian.org/archive/debian-ports'
313                   '/20191021T083923Z/pool-m68k/main'
314                   '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
315        deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
316        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
317        kernel_path = self.extract_from_deb(deb_path,
318                                            '/boot/vmlinux-5.3.0-1-m68k')
319
320        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
321                               'console=ttyS0 vga=off')
322        console_pattern = 'No filesystem could mount root'
323        self.run_rr(kernel_path, kernel_command_line, console_pattern)
324
325    def do_test_advcal_2018(self, file_path, kernel_name, args=None):
326        archive.extract(file_path, self.workdir)
327
328        for entry in os.scandir(self.workdir):
329            if entry.name.startswith('day') and entry.is_dir():
330                kernel_path = os.path.join(entry.path, kernel_name)
331                break
332
333        kernel_command_line = ''
334        console_pattern = 'QEMU advent calendar'
335        self.run_rr(kernel_path, kernel_command_line, console_pattern,
336                    args=args)
337
338    def test_arm_vexpressa9(self):
339        """
340        :avocado: tags=arch:arm
341        :avocado: tags=machine:vexpress-a9
342        """
343        tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
344        tar_url = ('https://qemu-advcal.gitlab.io'
345                   '/qac-best-of-multiarch/download/day16.tar.xz')
346        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
347        dtb_path = self.workdir + '/day16/vexpress-v2p-ca9.dtb'
348        self.do_test_advcal_2018(file_path, 'winter.zImage',
349                                 args=('-dtb', dtb_path))
350
351    def test_m68k_mcf5208evb(self):
352        """
353        :avocado: tags=arch:m68k
354        :avocado: tags=machine:mcf5208evb
355        """
356        tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
357        tar_url = ('https://qemu-advcal.gitlab.io'
358                   '/qac-best-of-multiarch/download/day07.tar.xz')
359        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
360        self.do_test_advcal_2018(file_path, 'sanity-clause.elf')
361
362    def test_microblaze_s3adsp1800(self):
363        """
364        :avocado: tags=arch:microblaze
365        :avocado: tags=machine:petalogix-s3adsp1800
366        """
367        tar_hash = '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
368        tar_url = ('https://qemu-advcal.gitlab.io'
369                   '/qac-best-of-multiarch/download/day17.tar.xz')
370        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
371        self.do_test_advcal_2018(file_path, 'ballerina.bin')
372
373    def test_ppc64_e500(self):
374        """
375        :avocado: tags=arch:ppc64
376        :avocado: tags=machine:ppce500
377        :avocado: tags=cpu:e5500
378        """
379        tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
380        tar_url = ('https://qemu-advcal.gitlab.io'
381                   '/qac-best-of-multiarch/download/day19.tar.xz')
382        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
383        self.do_test_advcal_2018(file_path, 'uImage')
384
385    def test_or1k_sim(self):
386        """
387        :avocado: tags=arch:or1k
388        :avocado: tags=machine:or1k-sim
389        """
390        tar_hash = '20334cdaf386108c530ff0badaecc955693027dd'
391        tar_url = ('https://qemu-advcal.gitlab.io'
392                   '/qac-best-of-multiarch/download/day20.tar.xz')
393        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
394        self.do_test_advcal_2018(file_path, 'vmlinux')
395
396    def test_ppc_g3beige(self):
397        """
398        :avocado: tags=arch:ppc
399        :avocado: tags=machine:g3beige
400        """
401        tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
402        tar_url = ('https://qemu-advcal.gitlab.io'
403                   '/qac-best-of-multiarch/download/day15.tar.xz')
404        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
405        self.do_test_advcal_2018(file_path, 'invaders.elf',
406                                 args=('-M', 'graphics=off'))
407
408    def test_ppc_mac99(self):
409        """
410        :avocado: tags=arch:ppc
411        :avocado: tags=machine:mac99
412        """
413        tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
414        tar_url = ('https://qemu-advcal.gitlab.io'
415                   '/qac-best-of-multiarch/download/day15.tar.xz')
416        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
417        self.do_test_advcal_2018(file_path, 'invaders.elf',
418                                 args=('-M', 'graphics=off'))
419
420    def test_sparc_ss20(self):
421        """
422        :avocado: tags=arch:sparc
423        :avocado: tags=machine:SS-20
424        """
425        tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
426        tar_url = ('https://qemu-advcal.gitlab.io'
427                   '/qac-best-of-multiarch/download/day11.tar.xz')
428        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
429        self.do_test_advcal_2018(file_path, 'zImage.elf')
430
431    def test_xtensa_lx60(self):
432        """
433        :avocado: tags=arch:xtensa
434        :avocado: tags=machine:lx60
435        :avocado: tags=cpu:dc233c
436        """
437        tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
438        tar_url = ('https://qemu-advcal.gitlab.io'
439                   '/qac-best-of-multiarch/download/day02.tar.xz')
440        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
441        self.do_test_advcal_2018(file_path, 'santas-sleigh-ride.elf')
442
443@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
444class ReplayKernelSlow(ReplayKernelBase):
445    # Override the timeout, because this kernel includes an inner
446    # loop which is executed with TB recompilings during replay,
447    # making it very slow.
448    timeout = 180
449
450    def test_mips_malta_cpio(self):
451        """
452        :avocado: tags=arch:mips
453        :avocado: tags=machine:malta
454        :avocado: tags=endian:big
455        :avocado: tags=slowness:high
456        """
457        deb_url = ('http://snapshot.debian.org/archive/debian/'
458                   '20160601T041800Z/pool/main/l/linux/'
459                   'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
460        deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
461        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
462        kernel_path = self.extract_from_deb(deb_path,
463                                            '/boot/vmlinux-4.5.0-2-4kc-malta')
464        initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
465                      '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
466                      'mips/rootfs.cpio.gz')
467        initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
468        initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
469        initrd_path = self.workdir + "rootfs.cpio"
470        archive.gzip_uncompress(initrd_path_gz, initrd_path)
471
472        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
473                               'console=ttyS0 console=tty '
474                               'rdinit=/sbin/init noreboot')
475        console_pattern = 'Boot successful.'
476        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5,
477                    args=('-initrd', initrd_path))
478
479    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
480    def test_mips64el_malta_5KEc_cpio(self):
481        """
482        :avocado: tags=arch:mips64el
483        :avocado: tags=machine:malta
484        :avocado: tags=endian:little
485        :avocado: tags=slowness:high
486        :avocado: tags=cpu:5KEc
487        """
488        kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
489                      'raw/9ad2df38/mips/malta/mips64el/'
490                      'vmlinux-3.19.3.mtoman.20150408')
491        kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
492        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
493        initrd_url = ('https://github.com/groeck/linux-build-test/'
494                      'raw/8584a59e/rootfs/'
495                      'mipsel64/rootfs.mipsel64r1.cpio.gz')
496        initrd_hash = '1dbb8a396e916847325284dbe2151167'
497        initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5',
498                                          asset_hash=initrd_hash)
499        initrd_path = self.workdir + "rootfs.cpio"
500        archive.gzip_uncompress(initrd_path_gz, initrd_path)
501
502        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
503                               'console=ttyS0 console=tty '
504                               'rdinit=/sbin/init noreboot')
505        console_pattern = 'Boot successful.'
506        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5,
507                    args=('-initrd', initrd_path))
508
509    def do_test_mips_malta32el_nanomips(self, kernel_path_xz):
510        kernel_path = self.workdir + "kernel"
511        with lzma.open(kernel_path_xz, 'rb') as f_in:
512            with open(kernel_path, 'wb') as f_out:
513                shutil.copyfileobj(f_in, f_out)
514
515        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
516                               'mem=256m@@0x0 '
517                               'console=ttyS0')
518        console_pattern = 'Kernel command line: %s' % kernel_command_line
519        self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
520
521    def test_mips_malta32el_nanomips_4k(self):
522        """
523        :avocado: tags=arch:mipsel
524        :avocado: tags=machine:malta
525        :avocado: tags=endian:little
526        :avocado: tags=cpu:I7200
527        """
528        kernel_url = ('http://mipsdistros.mips.com/LinuxDistro/nanomips/'
529                      'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
530                      'generic_nano32r6el_page4k.xz')
531        kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6'
532        kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
533        self.do_test_mips_malta32el_nanomips(kernel_path_xz)
534
535    def test_mips_malta32el_nanomips_16k_up(self):
536        """
537        :avocado: tags=arch:mipsel
538        :avocado: tags=machine:malta
539        :avocado: tags=endian:little
540        :avocado: tags=cpu:I7200
541        """
542        kernel_url = ('http://mipsdistros.mips.com/LinuxDistro/nanomips/'
543                      'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
544                      'generic_nano32r6el_page16k_up.xz')
545        kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc'
546        kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
547        self.do_test_mips_malta32el_nanomips(kernel_path_xz)
548
549    def test_mips_malta32el_nanomips_64k_dbg(self):
550        """
551        :avocado: tags=arch:mipsel
552        :avocado: tags=machine:malta
553        :avocado: tags=endian:little
554        :avocado: tags=cpu:I7200
555        """
556        kernel_url = ('http://mipsdistros.mips.com/LinuxDistro/nanomips/'
557                      'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
558                      'generic_nano32r6el_page64k_dbg.xz')
559        kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
560        kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
561        self.do_test_mips_malta32el_nanomips(kernel_path_xz)
562