summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>2019-05-09 17:36:43 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-05-10 14:53:08 -0400
commit38891392916c42d4ba46f474d553c76d1ed329ca (patch)
tree9adc1f5ab809bc5cb8e6f1113d6ef346d763d49c
parentf824b6866835bc5051c44ffd289134974f214e98 (diff)
ktest: cleanup get_grub_index
Cleanup get_grub_index(). Link: http://lkml.kernel.org/r/20190509213647.6276-3-msys.mizuma@gmail.com Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rwxr-xr-xtools/testing/ktest/ktest.pl50
1 files changed, 17 insertions, 33 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 43868ee07e17..ff43f8336da1 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -1946,46 +1946,30 @@ sub get_grub2_index {
1946 1946
1947sub get_grub_index { 1947sub get_grub_index {
1948 1948
1949 if ($reboot_type eq "grub2") { 1949 my $command;
1950 get_grub2_index; 1950 my $target;
1951 return; 1951 my $skip;
1952 } 1952 my $grub_menu_qt;
1953 1953
1954 if ($reboot_type ne "grub") { 1954 if ($reboot_type !~ /^grub/) {
1955 return; 1955 return;
1956 } 1956 }
1957 return if (defined($grub_number) && defined($last_grub_menu) &&
1958 $last_grub_menu eq $grub_menu && defined($last_machine) &&
1959 $last_machine eq $machine);
1960
1961 doprint "Find grub menu ... ";
1962 $grub_number = -1;
1963 1957
1964 my $ssh_grub = $ssh_exec; 1958 $grub_menu_qt = quotemeta($grub_menu);
1965 $ssh_grub =~ s,\$SSH_COMMAND,cat /boot/grub/menu.lst,g;
1966
1967 open(IN, "$ssh_grub |")
1968 or dodie "unable to get menu.lst";
1969 1959
1970 my $found = 0; 1960 if ($reboot_type eq "grub") {
1971 my $grub_menu_qt = quotemeta($grub_menu); 1961 $command = "cat /boot/grub/menu.lst";
1972 1962 $target = '^\s*title\s+' . $grub_menu_qt . '\s*$';
1973 while (<IN>) { 1963 $skip = '^\s*title\s';
1974 if (/^\s*title\s+$grub_menu_qt\s*$/) { 1964 } elsif ($reboot_type eq "grub2") {
1975 $grub_number++; 1965 $command = "cat $grub_file";
1976 $found = 1; 1966 $target = '^menuentry.*' . $grub_menu_qt;
1977 last; 1967 $skip = '^menuentry\s|^submenu\s';
1978 } elsif (/^\s*title\s/) { 1968 } else {
1979 $grub_number++; 1969 return;
1980 }
1981 } 1970 }
1982 close(IN);
1983 1971
1984 dodie "Could not find '$grub_menu' in /boot/grub/menu on $machine" 1972 _get_grub_index($command, $target, $skip);
1985 if (!$found);
1986 doprint "$grub_number\n";
1987 $last_grub_menu = $grub_menu;
1988 $last_machine = $machine;
1989} 1973}
1990 1974
1991sub wait_for_input 1975sub wait_for_input