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