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 8 9from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern 10from qemu_test import interrupt_interactive_console_until_pattern, skipSlowTest 11 12 13class EmcraftSf2Machine(LinuxKernelTest): 14 15 ASSET_IMAGE = Asset( 16 ('https://github.com/hskinnemoen/openbmc/releases/download/' 17 '20200711-gsj-qemu-0/obmc-phosphor-image-gsj.static.mtd.gz'), 18 'eccd4e375cde53034c84aece5c511932cacf838d9fd3f63da368a511757da72b') 19 20 ASSET_INITRD = Asset( 21 ('https://github.com/hskinnemoen/openbmc/releases/download/' 22 '20200711-gsj-qemu-0/obmc-phosphor-initramfs-gsj.cpio.xz'), 23 '37b05009fc54db1434beac12bd7ff99a2e751a2f032ee18d9042f991dd0cdeaa') 24 25 ASSET_KERNEL = Asset( 26 ('https://github.com/hskinnemoen/openbmc/releases/download/' 27 '20200711-gsj-qemu-0/uImage-gsj.bin'), 28 'ce6d6b37bff46c74fc7b1e90da10a431cc37a62cdb35ec199fa73473d0790110') 29 30 ASSET_DTB = Asset( 31 ('https://github.com/hskinnemoen/openbmc/releases/download/' 32 '20200711-gsj-qemu-0/nuvoton-npcm730-gsj.dtb'), 33 '3249b2da787d4b9ad4e61f315b160abfceb87b5e1895a7ce898ce7f40c8d4045') 34 35 @skipSlowTest() 36 def test_arm_quanta_gsj(self): 37 self.set_machine('quanta-gsj') 38 image_path = self.uncompress(self.ASSET_IMAGE, format='gz') 39 40 self.vm.set_console() 41 drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0' 42 self.vm.add_args('-drive', drive_args) 43 self.vm.launch() 44 45 # Disable drivers and services that stall for a long time during boot, 46 # to avoid running past the 90-second timeout. These may be removed 47 # as the corresponding device support is added. 48 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + ( 49 'console=${console} ' 50 'mem=${mem} ' 51 'initcall_blacklist=npcm_i2c_bus_driver_init ' 52 'systemd.mask=systemd-random-seed.service ' 53 'systemd.mask=dropbearkey.service ' 54 ) 55 56 self.wait_for_console_pattern('> BootBlock by Nuvoton') 57 self.wait_for_console_pattern('>Device: Poleg BMC NPCM730') 58 self.wait_for_console_pattern('>Skip DDR init.') 59 self.wait_for_console_pattern('U-Boot ') 60 interrupt_interactive_console_until_pattern( 61 self, 'Hit any key to stop autoboot:', 'U-Boot>') 62 exec_command_and_wait_for_pattern( 63 self, "setenv bootargs ${bootargs} " + kernel_command_line, 64 'U-Boot>') 65 exec_command_and_wait_for_pattern( 66 self, 'run romboot', 'Booting Kernel from flash') 67 self.wait_for_console_pattern('Booting Linux on physical CPU 0x0') 68 self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') 69 self.wait_for_console_pattern('OpenBMC Project Reference Distro') 70 self.wait_for_console_pattern('gsj login:') 71 72 def test_arm_quanta_gsj_initrd(self): 73 self.set_machine('quanta-gsj') 74 initrd_path = self.ASSET_INITRD.fetch() 75 kernel_path = self.ASSET_KERNEL.fetch() 76 dtb_path = self.ASSET_DTB.fetch() 77 78 self.vm.set_console() 79 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 80 'console=ttyS0,115200n8 ' 81 'earlycon=uart8250,mmio32,0xf0001000') 82 self.vm.add_args('-kernel', kernel_path, 83 '-initrd', initrd_path, 84 '-dtb', dtb_path, 85 '-append', kernel_command_line) 86 self.vm.launch() 87 88 self.wait_for_console_pattern('Booting Linux on physical CPU 0x0') 89 self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') 90 self.wait_for_console_pattern( 91 'Give root password for system maintenance') 92 93if __name__ == '__main__': 94 LinuxKernelTest.main() 95