Simon Glass | b001227 | 2025-03-15 14:26:06 +0000 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
| 2 | # Copyright 2025 Canonical Ltd. |
| 3 | # Written by Simon Glass <simon.glass@canonical.com> |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | # Enable early console so that the test can see if something goes wrong |
| 8 | CONSOLE = 'earlycon=uart8250,io,0x3f8 console=uart8250,io,0x3f8' |
| 9 | |
| 10 | @pytest.mark.boardspec('qemu-x86_64') |
| 11 | @pytest.mark.role('qemu-x86_64') |
| 12 | def test_distro(ubman): |
| 13 | """Test that of-platdata can be generated and used in sandbox""" |
| 14 | with ubman.log.section('boot'): |
| 15 | ubman.run_command('boot', wait_for_prompt=False) |
| 16 | |
| 17 | with ubman.log.section('Grub'): |
| 18 | # Wait for grub to come up and offset a menu |
| 19 | ubman.p.expect(['Try or Install Ubuntu']) |
| 20 | |
| 21 | # Press 'e' to edit the command line |
| 22 | ubman.log.info("Pressing 'e'") |
| 23 | ubman.run_command('e', wait_for_prompt=False, send_nl=False) |
| 24 | |
| 25 | # Wait until we see the editor appear |
| 26 | ubman.p.expect(['/casper/initrd']) |
| 27 | |
| 28 | # Go down to the 'linux' line. Avoid using down-arrow as that includes |
| 29 | # an Escape character, which may be parsed by Grub as such, causing it |
| 30 | # to return to the top menu |
| 31 | ubman.log.info("Going DOWN") |
| 32 | ubman.ctrl('N') |
| 33 | ubman.ctrl('N') |
| 34 | ubman.ctrl('N') |
| 35 | |
| 36 | # Go to end of line |
| 37 | ubman.log.info("Going to EOL") |
| 38 | ubman.ctrl('E') |
| 39 | |
| 40 | # Backspace to remove 'quiet splash' |
| 41 | ubman.log.info("Erasing quiet and splash") |
| 42 | ubman.send('\b' * len('quiet splash')) |
| 43 | |
| 44 | # Send our noisy console |
| 45 | ubman.log.info("Noisy console") |
| 46 | ubman.send(CONSOLE) |
| 47 | |
| 48 | # Tell grub to boot |
| 49 | ubman.log.info("boot") |
| 50 | ubman.ctrl('X') |
| 51 | ubman.p.expect(['Booting a command list']) |
| 52 | |
| 53 | with ubman.log.section('Linux'): |
| 54 | # Linux should start immediately |
| 55 | ubman.p.expect(['Linux version']) |
| 56 | |
| 57 | with ubman.log.section('Ubuntu'): |
| 58 | # Shortly later, we should see this banner |
| 59 | ubman.p.expect(['Welcome to .*Ubuntu 24.04.1 LTS.*!']) |
| 60 | |
| 61 | ubman.restart_uboot() |