1# Functional tests for the Generic Loongson-3 Platform.
2#
3# Copyright (c) 2021 Jiaxun Yang <jiaxun.yang@flygoat.com>
4#
5# This work is licensed under the terms of the GNU GPL, version 2 or later.
6# See the COPYING file in the top-level directory.
7#
8# SPDX-License-Identifier: GPL-2.0-or-later
9
10import os
11import time
12
13from avocado import skipUnless
14from avocado_qemu import QemuSystemTest
15from avocado_qemu import wait_for_console_pattern
16
17class MipsLoongson3v(QemuSystemTest):
18    timeout = 60
19
20    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
21    def test_pmon_serial_console(self):
22        """
23        :avocado: tags=arch:mips64el
24        :avocado: tags=endian:little
25        :avocado: tags=machine:loongson3-virt
26        :avocado: tags=cpu:Loongson-3A1000
27        :avocado: tags=device:liointc
28        :avocado: tags=device:goldfish_rtc
29        """
30
31        pmon_hash = '7c8b45dd81ccfc55ff28f5aa267a41c3'
32        pmon_path = self.fetch_asset('https://github.com/loongson-community/pmon/'
33                                    'releases/download/20210112/pmon-3avirt.bin',
34                                     asset_hash=pmon_hash, algorithm='md5')
35
36        self.vm.set_console()
37        self.vm.add_args('-bios', pmon_path)
38        self.vm.launch()
39        wait_for_console_pattern(self, 'CPU GODSON3 BogoMIPS:')
40