1*4c0a2df8SThomas Huth#!/usr/bin/env python3
2*4c0a2df8SThomas Huth#
3*4c0a2df8SThomas Huth# Test that the U-Boot firmware boots on ppc 405 machines and check the console
4*4c0a2df8SThomas Huth#
5*4c0a2df8SThomas Huth# Copyright (c) 2021 Red Hat, Inc.
6*4c0a2df8SThomas Huth#
7*4c0a2df8SThomas Huth# This work is licensed under the terms of the GNU GPL, version 2 or
8*4c0a2df8SThomas Huth# later.  See the COPYING file in the top-level directory.
9*4c0a2df8SThomas Huth
10*4c0a2df8SThomas Huthfrom qemu_test import QemuSystemTest, Asset
11*4c0a2df8SThomas Huthfrom qemu_test import wait_for_console_pattern
12*4c0a2df8SThomas Huthfrom qemu_test import exec_command_and_wait_for_pattern
13*4c0a2df8SThomas Huth
14*4c0a2df8SThomas Huthclass Ppc405Machine(QemuSystemTest):
15*4c0a2df8SThomas Huth
16*4c0a2df8SThomas Huth    timeout = 90
17*4c0a2df8SThomas Huth
18*4c0a2df8SThomas Huth    ASSET_UBOOT = Asset(
19*4c0a2df8SThomas Huth        ('https://gitlab.com/huth/u-boot/-/raw/taihu-2021-10-09/'
20*4c0a2df8SThomas Huth         'u-boot-taihu.bin'),
21*4c0a2df8SThomas Huth        'a076bb6cdeaafa406330e51e074b66d8878d9036d67d4caa0137be03ee4c112c')
22*4c0a2df8SThomas Huth
23*4c0a2df8SThomas Huth    def do_test_ppc405(self):
24*4c0a2df8SThomas Huth        file_path = self.ASSET_UBOOT.fetch()
25*4c0a2df8SThomas Huth        self.vm.set_console(console_index=1)
26*4c0a2df8SThomas Huth        self.vm.add_args('-bios', file_path)
27*4c0a2df8SThomas Huth        self.vm.launch()
28*4c0a2df8SThomas Huth        wait_for_console_pattern(self, 'AMCC PPC405EP Evaluation Board')
29*4c0a2df8SThomas Huth        exec_command_and_wait_for_pattern(self, 'reset', 'AMCC PowerPC 405EP')
30*4c0a2df8SThomas Huth
31*4c0a2df8SThomas Huth    def test_ppc_ref405ep(self):
32*4c0a2df8SThomas Huth        self.require_accelerator("tcg")
33*4c0a2df8SThomas Huth        self.set_machine('ref405ep')
34*4c0a2df8SThomas Huth        self.do_test_ppc405()
35*4c0a2df8SThomas Huth
36*4c0a2df8SThomas Huthif __name__ == '__main__':
37*4c0a2df8SThomas Huth    QemuSystemTest.main()
38