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