1# Test class to boot aspeed machines 2# 3# SPDX-License-Identifier: GPL-2.0-or-later 4 5from qemu_test import exec_command_and_wait_for_pattern 6from qemu_test import LinuxKernelTest 7 8class AspeedTest(LinuxKernelTest): 9 10 def do_test_arm_aspeed_openbmc(self, machine, image, uboot='2019.04', 11 cpu_id='0x0', soc='AST2500 rev A1', 12 image_hostname=None): 13 # Allow for the image hostname to not end in "-bmc" 14 if image_hostname is not None: 15 hostname = image_hostname 16 else: 17 hostname = machine.removesuffix('-bmc') 18 19 self.set_machine(machine) 20 self.vm.set_console() 21 self.vm.add_args('-drive', f'file={image},if=mtd,format=raw', 22 '-snapshot') 23 self.vm.launch() 24 25 self.wait_for_console_pattern(f'U-Boot {uboot}') 26 self.wait_for_console_pattern('## Loading kernel from FIT Image') 27 self.wait_for_console_pattern('Starting kernel ...') 28 self.wait_for_console_pattern(f'Booting Linux on physical CPU {cpu_id}') 29 self.wait_for_console_pattern(f'ASPEED {soc}') 30 self.wait_for_console_pattern('/init as init process') 31 self.wait_for_console_pattern(f'systemd[1]: Hostname set to <{hostname}>.') 32 33 def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'): 34 self.require_netdev('user') 35 self.vm.set_console() 36 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw,read-only=true', 37 '-net', 'nic', '-net', 'user') 38 self.vm.launch() 39 40 self.wait_for_console_pattern('U-Boot 2019.04') 41 self.wait_for_console_pattern('## Loading kernel from FIT Image') 42 self.wait_for_console_pattern('Starting kernel ...') 43 self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id) 44 self.wait_for_console_pattern('lease of 10.0.2.15') 45 # the line before login: 46 self.wait_for_console_pattern(pattern) 47 exec_command_and_wait_for_pattern(self, 'root', 'Password:') 48 exec_command_and_wait_for_pattern(self, 'passw0rd', '#') 49 50 def do_test_arm_aspeed_buildroot_poweroff(self): 51 exec_command_and_wait_for_pattern(self, 'poweroff', 52 'System halted') 53 54 def do_test_arm_aspeed_sdk_start(self, image): 55 self.require_netdev('user') 56 self.vm.set_console() 57 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', 58 '-net', 'nic', '-net', 'user', '-snapshot') 59 self.vm.launch() 60 61 self.wait_for_console_pattern('U-Boot 2019.04') 62 self.wait_for_console_pattern('## Loading kernel from FIT Image') 63 self.wait_for_console_pattern('Starting kernel ...') 64