xref: /qemu/tests/functional/test_arm_quanta_gsj.py (revision 55f5bf716a65f67663d0769bcb8c017764b3e53a)
1799d6830SThomas Huth#!/usr/bin/env python3
2799d6830SThomas Huth#
3799d6830SThomas Huth# Functional test that boots a Linux kernel and checks the console
4799d6830SThomas Huth#
5799d6830SThomas Huth# SPDX-License-Identifier: GPL-2.0-or-later
6799d6830SThomas Huth
7799d6830SThomas Huthfrom qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
8*4ae633b0SThomas Huthfrom qemu_test import interrupt_interactive_console_until_pattern, skipSlowTest
9*4ae633b0SThomas Huth
10799d6830SThomas Huth
11799d6830SThomas Huthclass EmcraftSf2Machine(LinuxKernelTest):
12799d6830SThomas Huth
13799d6830SThomas Huth    ASSET_IMAGE = Asset(
14799d6830SThomas Huth        ('https://github.com/hskinnemoen/openbmc/releases/download/'
15799d6830SThomas Huth         '20200711-gsj-qemu-0/obmc-phosphor-image-gsj.static.mtd.gz'),
16799d6830SThomas Huth        'eccd4e375cde53034c84aece5c511932cacf838d9fd3f63da368a511757da72b')
17799d6830SThomas Huth
18799d6830SThomas Huth    ASSET_INITRD = Asset(
19799d6830SThomas Huth        ('https://github.com/hskinnemoen/openbmc/releases/download/'
20799d6830SThomas Huth         '20200711-gsj-qemu-0/obmc-phosphor-initramfs-gsj.cpio.xz'),
21799d6830SThomas Huth        '37b05009fc54db1434beac12bd7ff99a2e751a2f032ee18d9042f991dd0cdeaa')
22799d6830SThomas Huth
23799d6830SThomas Huth    ASSET_KERNEL = Asset(
24799d6830SThomas Huth        ('https://github.com/hskinnemoen/openbmc/releases/download/'
25799d6830SThomas Huth         '20200711-gsj-qemu-0/uImage-gsj.bin'),
26799d6830SThomas Huth        'ce6d6b37bff46c74fc7b1e90da10a431cc37a62cdb35ec199fa73473d0790110')
27799d6830SThomas Huth
28799d6830SThomas Huth    ASSET_DTB = Asset(
29799d6830SThomas Huth        ('https://github.com/hskinnemoen/openbmc/releases/download/'
30799d6830SThomas Huth         '20200711-gsj-qemu-0/nuvoton-npcm730-gsj.dtb'),
31799d6830SThomas Huth        '3249b2da787d4b9ad4e61f315b160abfceb87b5e1895a7ce898ce7f40c8d4045')
32799d6830SThomas Huth
33*4ae633b0SThomas Huth    @skipSlowTest()
34799d6830SThomas Huth    def test_arm_quanta_gsj(self):
35799d6830SThomas Huth        self.set_machine('quanta-gsj')
36c5efe546SThomas Huth        image_path = self.uncompress(self.ASSET_IMAGE, format='gz')
37799d6830SThomas Huth
38799d6830SThomas Huth        self.vm.set_console()
39799d6830SThomas Huth        drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0'
40799d6830SThomas Huth        self.vm.add_args('-drive', drive_args)
41799d6830SThomas Huth        self.vm.launch()
42799d6830SThomas Huth
43799d6830SThomas Huth        # Disable drivers and services that stall for a long time during boot,
44799d6830SThomas Huth        # to avoid running past the 90-second timeout. These may be removed
45799d6830SThomas Huth        # as the corresponding device support is added.
46799d6830SThomas Huth        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + (
47799d6830SThomas Huth                'console=${console} '
48799d6830SThomas Huth                'mem=${mem} '
49799d6830SThomas Huth                'initcall_blacklist=npcm_i2c_bus_driver_init '
50799d6830SThomas Huth                'systemd.mask=systemd-random-seed.service '
51799d6830SThomas Huth                'systemd.mask=dropbearkey.service '
52799d6830SThomas Huth        )
53799d6830SThomas Huth
54799d6830SThomas Huth        self.wait_for_console_pattern('> BootBlock by Nuvoton')
55799d6830SThomas Huth        self.wait_for_console_pattern('>Device: Poleg BMC NPCM730')
56799d6830SThomas Huth        self.wait_for_console_pattern('>Skip DDR init.')
57799d6830SThomas Huth        self.wait_for_console_pattern('U-Boot ')
58799d6830SThomas Huth        interrupt_interactive_console_until_pattern(
59799d6830SThomas Huth                self, 'Hit any key to stop autoboot:', 'U-Boot>')
60799d6830SThomas Huth        exec_command_and_wait_for_pattern(
61799d6830SThomas Huth                self, "setenv bootargs ${bootargs} " + kernel_command_line,
62799d6830SThomas Huth                'U-Boot>')
63799d6830SThomas Huth        exec_command_and_wait_for_pattern(
64799d6830SThomas Huth                self, 'run romboot', 'Booting Kernel from flash')
65799d6830SThomas Huth        self.wait_for_console_pattern('Booting Linux on physical CPU 0x0')
66799d6830SThomas Huth        self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0')
67799d6830SThomas Huth        self.wait_for_console_pattern('OpenBMC Project Reference Distro')
68799d6830SThomas Huth        self.wait_for_console_pattern('gsj login:')
69799d6830SThomas Huth
70799d6830SThomas Huth    def test_arm_quanta_gsj_initrd(self):
71799d6830SThomas Huth        self.set_machine('quanta-gsj')
72799d6830SThomas Huth        initrd_path = self.ASSET_INITRD.fetch()
73799d6830SThomas Huth        kernel_path = self.ASSET_KERNEL.fetch()
74799d6830SThomas Huth        dtb_path = self.ASSET_DTB.fetch()
75799d6830SThomas Huth
76799d6830SThomas Huth        self.vm.set_console()
77799d6830SThomas Huth        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
78799d6830SThomas Huth                               'console=ttyS0,115200n8 '
79799d6830SThomas Huth                               'earlycon=uart8250,mmio32,0xf0001000')
80799d6830SThomas Huth        self.vm.add_args('-kernel', kernel_path,
81799d6830SThomas Huth                         '-initrd', initrd_path,
82799d6830SThomas Huth                         '-dtb', dtb_path,
83799d6830SThomas Huth                         '-append', kernel_command_line)
84799d6830SThomas Huth        self.vm.launch()
85799d6830SThomas Huth
86799d6830SThomas Huth        self.wait_for_console_pattern('Booting Linux on physical CPU 0x0')
87799d6830SThomas Huth        self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0')
88799d6830SThomas Huth        self.wait_for_console_pattern(
89799d6830SThomas Huth                'Give root password for system maintenance')
90799d6830SThomas Huth
91799d6830SThomas Huthif __name__ == '__main__':
92799d6830SThomas Huth    LinuxKernelTest.main()
93