Commit 38891392 authored by Masayoshi Mizuma's avatar Masayoshi Mizuma Committed by Steven Rostedt (VMware)

ktest: cleanup get_grub_index

Cleanup get_grub_index().

Link: http://lkml.kernel.org/r/20190509213647.6276-3-msys.mizuma@gmail.comSigned-off-by: default avatarMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent f824b686
...@@ -1946,46 +1946,30 @@ sub get_grub2_index { ...@@ -1946,46 +1946,30 @@ sub get_grub2_index {
sub get_grub_index { sub get_grub_index {
if ($reboot_type eq "grub2") { my $command;
get_grub2_index; my $target;
return; my $skip;
} my $grub_menu_qt;
if ($reboot_type ne "grub") { if ($reboot_type !~ /^grub/) {
return; return;
} }
return if (defined($grub_number) && defined($last_grub_menu) &&
$last_grub_menu eq $grub_menu && defined($last_machine) &&
$last_machine eq $machine);
doprint "Find grub menu ... ";
$grub_number = -1;
my $ssh_grub = $ssh_exec; $grub_menu_qt = quotemeta($grub_menu);
$ssh_grub =~ s,\$SSH_COMMAND,cat /boot/grub/menu.lst,g;
open(IN, "$ssh_grub |")
or dodie "unable to get menu.lst";
my $found = 0; if ($reboot_type eq "grub") {
my $grub_menu_qt = quotemeta($grub_menu); $command = "cat /boot/grub/menu.lst";
$target = '^\s*title\s+' . $grub_menu_qt . '\s*$';
while (<IN>) { $skip = '^\s*title\s';
if (/^\s*title\s+$grub_menu_qt\s*$/) { } elsif ($reboot_type eq "grub2") {
$grub_number++; $command = "cat $grub_file";
$found = 1; $target = '^menuentry.*' . $grub_menu_qt;
last; $skip = '^menuentry\s|^submenu\s';
} elsif (/^\s*title\s/) { } else {
$grub_number++; return;
}
} }
close(IN);
dodie "Could not find '$grub_menu' in /boot/grub/menu on $machine" _get_grub_index($command, $target, $skip);
if (!$found);
doprint "$grub_number\n";
$last_grub_menu = $grub_menu;
$last_machine = $machine;
} }
sub wait_for_input sub wait_for_input
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment