xref: /qemu/tests/functional/test_arm_smdkc210.py (revision ccc76731aee7d3efb16a679fa5bf3cc3f57e9f2d)
1#!/usr/bin/env python3
2#
3# Functional test that boots a Linux kernel and checks the console
4#
5# SPDX-License-Identifier: GPL-2.0-or-later
6
7import os
8import shutil
9
10from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
11from qemu_test.utils import gzip_uncompress
12
13class Smdkc210Machine(LinuxKernelTest):
14
15    ASSET_DEB = Asset(
16        ('https://snapshot.debian.org/archive/debian/20190928T224601Z/pool/'
17         'main/l/linux/linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb'),
18        '421804e7579ef40d554c962850dbdf1bfc79f7fa7faec9d391397170dc806c3e')
19
20    ASSET_ROOTFS = Asset(
21        ('https://github.com/groeck/linux-build-test/raw/'
22         '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/arm/'
23         'rootfs-armv5.cpio.gz'),
24        '334b8d256db67a3f2b3ad070aa08b5ade39624e0e7e35b02f4359a577bc8f39b')
25
26    def test_arm_exynos4210_initrd(self):
27        self.set_machine('smdkc210')
28
29        deb_path = self.ASSET_DEB.fetch()
30        kernel_path = self.extract_from_deb(deb_path,
31                                            '/boot/vmlinuz-4.19.0-6-armmp')
32        dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
33        dtb_path = self.extract_from_deb(deb_path, dtb_path)
34
35        initrd_path_gz = self.ASSET_ROOTFS.fetch()
36        initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
37        gzip_uncompress(initrd_path_gz, initrd_path)
38
39        self.vm.set_console()
40        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
41                               'earlycon=exynos4210,0x13800000 earlyprintk ' +
42                               'console=ttySAC0,115200n8 ' +
43                               'random.trust_cpu=off cryptomgr.notests ' +
44                               'cpuidle.off=1 panic=-1 noreboot')
45
46        self.vm.add_args('-kernel', kernel_path,
47                         '-dtb', dtb_path,
48                         '-initrd', initrd_path,
49                         '-append', kernel_command_line,
50                         '-no-reboot')
51        self.vm.launch()
52
53        self.wait_for_console_pattern('Boot successful.')
54        # TODO user command, for now the uart is stuck
55
56if __name__ == '__main__':
57    LinuxKernelTest.main()
58