| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Functional test that boots a Linux kernel and checks the console |
| 4 | # |
| 5 | # Copyright (c) 2018 Red Hat, Inc. |
| 6 | # |
| 7 | # Author: |
| 8 | # Cleber Rosa <crosa@redhat.com> |
| 9 | # |
| 10 | # This work is licensed under the terms of the GNU GPL, version 2 or |
| 11 | # later. See the COPYING file in the top-level directory. |
| 12 | |
| 13 | from qemu_test import QemuSystemTest, Asset |
| 14 | from qemu_test import exec_command_and_wait_for_pattern |
| 15 | from qemu_test import wait_for_console_pattern, skipFlakyTest |
| 16 | |
| 17 | |
| 18 | class RxGdbSimMachine(QemuSystemTest): |
| 19 | |
| 20 | ASSET_UBOOT = Asset( |
| 21 | ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/' |
| 22 | 'u-boot.bin'), |
| 23 | 'dd7dd4220cccf7aeb32227b26233bf39600db05c3f8e26005bcc2bf6c927207d') |
| 24 | ASSET_DTB = Asset( |
| 25 | ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/' |
| 26 | 'rx-gdbsim.dtb'), |
| 27 | 'aa278d9c1907a4501741d7ee57e7f65c02dd1b3e0323b33c6d4247f1b32cf29a') |
| 28 | ASSET_KERNEL = Asset( |
| 29 | ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/' |
| 30 | 'zImage'), |
| 31 | 'baa43205e74a7220ed8482188c5e9ce497226712abb7f4e7e4f825ce19ff9656') |
| 32 | |
| 33 | def test_uboot(self): |
| 34 | """ |
| 35 | U-Boot and checks that the console is operational. |
| 36 | """ |
| 37 | self.set_machine('gdbsim-r5f562n8') |
| 38 | |
| 39 | uboot_path = self.ASSET_UBOOT.fetch() |
| 40 | |
| 41 | self.vm.set_console() |
| 42 | self.vm.add_args('-bios', uboot_path, |
| 43 | '-no-reboot') |
| 44 | self.vm.launch() |
| 45 | uboot_version = 'U-Boot 2016.05-rc3-23705-ga1ef3c71cb-dirty' |
| 46 | wait_for_console_pattern(self, uboot_version) |
| 47 | #gcc_version = 'rx-unknown-linux-gcc (GCC) 9.0.0 20181105 (experimental)' |
| 48 | # FIXME limit baudrate on chardev, else we type too fast |
| 49 | # https://gitlab.com/qemu-project/qemu/-/issues/2691 |
| 50 | #exec_command_and_wait_for_pattern(self, 'version', gcc_version) |
| 51 | |
| 52 | @skipFlakyTest(bug_url="https://gitlab.com/qemu-project/qemu/-/issues/2691") |
| 53 | def test_linux_sash(self): |
| 54 | """ |
| 55 | Boots a Linux kernel and checks that the console is operational. |
| 56 | """ |
| 57 | self.set_machine('gdbsim-r5f562n7') |
| 58 | |
| 59 | dtb_path = self.ASSET_DTB.fetch() |
| 60 | kernel_path = self.ASSET_KERNEL.fetch() |
| 61 | |
| 62 | self.vm.set_console() |
| 63 | self.vm.add_args('-kernel', kernel_path, |
| 64 | '-dtb', dtb_path, |
| 65 | '-no-reboot') |
| 66 | self.vm.launch() |
| 67 | wait_for_console_pattern(self, 'Sash command shell (version 1.1.1)', |
| 68 | failure_message='Kernel panic - not syncing') |
| 69 | exec_command_and_wait_for_pattern(self, 'printenv', 'TERM=linux') |
| 70 | |
| 71 | if __name__ == '__main__': |
| 72 | QemuSystemTest.main() |