summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>2019-05-09 17:36:42 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-18 11:30:53 +0100
commit5f2956dcdbab203246160653d2bfeab6a6752d1b (patch)
treed923631e7f3896c8ae666be459f173b2cf3536f6 /tools
parent80295824e15fe76fed575000831fef80cb913758 (diff)
downloadlinux-stable-5f2956dcdbab203246160653d2bfeab6a6752d1b.tar.gz
linux-stable-5f2956dcdbab203246160653d2bfeab6a6752d1b.tar.bz2
linux-stable-5f2956dcdbab203246160653d2bfeab6a6752d1b.zip
ktest: introduce _get_grub_index
[ Upstream commit f824b6866835bc5051c44ffd289134974f214e98 ] Introduce _get_grub_index() to deal with Boot Loader Specification (BLS) and cleanup. Link: http://lkml.kernel.org/r/20190509213647.6276-2-msys.mizuma@gmail.com Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Stable-dep-of: 26df05a8c142 ("kest.pl: Fix grub2 menu handling for rebooting") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/ktest/ktest.pl37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 635121ecf543..5fa60b3c564f 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -1850,6 +1850,43 @@ sub run_scp_mod {
return run_scp($src, $dst, $cp_scp);
}
+sub _get_grub_index {
+
+ my ($command, $target, $skip) = @_;
+
+ return if (defined($grub_number) && defined($last_grub_menu) &&
+ $last_grub_menu eq $grub_menu && defined($last_machine) &&
+ $last_machine eq $machine);
+
+ doprint "Find $reboot_type menu ... ";
+ $grub_number = -1;
+
+ my $ssh_grub = $ssh_exec;
+ $ssh_grub =~ s,\$SSH_COMMAND,$command,g;
+
+ open(IN, "$ssh_grub |")
+ or dodie "unable to execute $command";
+
+ my $found = 0;
+
+ while (<IN>) {
+ if (/$target/) {
+ $grub_number++;
+ $found = 1;
+ last;
+ } elsif (/$skip/) {
+ $grub_number++;
+ }
+ }
+ close(IN);
+
+ dodie "Could not find '$grub_menu' through $command on $machine"
+ if (!$found);
+ doprint "$grub_number\n";
+ $last_grub_menu = $grub_menu;
+ $last_machine = $machine;
+}
+
sub get_grub2_index {
return if (defined($grub_number) && defined($last_grub_menu) &&