1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-25 15:23:08 +00:00
os-autoinst-distri-fedora/tests/rtt/boot_once.pm
2023-11-13 11:31:17 +01:00

73 lines
2.2 KiB
Perl

use base "installedtest";
use strict;
use testapi;
use utils;
# This test adds a new boot entry into Grub and sets this
# entry as the next boot entry. Then it reboots the computer
# and checks that the temporary boot entry has been booted.
# Then it reboots again and sees, if the original boot
# entry is used.
sub run {
my $self = shift;
my $new_cmdline = '';
my $title = "Terminator kernel";
my $cli_args = "terminate";
# Let's go to the virtual console to perform the testing.
$self->root_console(tty => 3);
# Now, we have a freshly booted system with the
# default boot entry, so we will remember the
# command line.
my $default_cmdline = script_output("cat /proc/cmdline");
# Then we will set up the temporary boot entry.
# First, let's check that no /boot/kernel exists
my $system = script_output("uname -r");
assert_script_run("! grubby --info=/boot/kernel");
assert_script_run("cp /boot/vmlinuz-$system /boot/kernel");
assert_script_run("cp /boot/initramfs-$system.img /boot/initrd");
# Assert that no test arguments exist in the cmdline.
assert_script_run("! grep $cli_args /proc/cmdline");
# Add custom kernel entry
assert_script_run("grubby --copy-default --add-kernel=/boot/kernel --initrd=/boot/initrd --title='$title' --args=$cli_args");
# Set temporary default
assert_script_run("grub2-reboot '$title'");
# Reboot the system.
enter_cmd("reboot");
# Wait until we arrive at the login screen and log
# onto the console again.
boot_to_login_screen;
$self->root_console(tty => 3);
# Check that the correct kernel has been booted.
assert_script_run("grep $cli_args /proc/cmdline");
# Reboot the system.
enter_cmd("reboot");
# Wait until we arrive at the login screen and log
# onto the console again.
boot_to_login_screen;
$self->root_console(tty => 3);
# Check that the previous kernel has been booted.
assert_script_run("! grep $cli_args /proc/cmdline");
my $current_cmdline = script_output("cat /proc/cmdline");
die("Some unexpected kernel entry has been used.") if ($current_cmdline ne $default_cmdline);
}
sub test_flags {
return {always_rollback => 1};
}
1;
# vim: set sw=4 et: