diff options
author | Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | 2019-05-09 17:36:42 -0400 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-05-10 14:52:43 -0400 |
commit | f824b6866835bc5051c44ffd289134974f214e98 (patch) | |
tree | 0fc591b37cdc27f24f49c49a8a295ddd5ba99a81 | |
parent | 37e1677330bdc2e96e70f18701e589876f054c67 (diff) |
ktest: introduce _get_grub_index
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>
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 275ad8ac8872..43868ee07e17 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -1871,6 +1871,43 @@ sub run_scp_mod { | |||
1871 | return run_scp($src, $dst, $cp_scp); | 1871 | return run_scp($src, $dst, $cp_scp); |
1872 | } | 1872 | } |
1873 | 1873 | ||
1874 | sub _get_grub_index { | ||
1875 | |||
1876 | my ($command, $target, $skip) = @_; | ||
1877 | |||
1878 | return if (defined($grub_number) && defined($last_grub_menu) && | ||
1879 | $last_grub_menu eq $grub_menu && defined($last_machine) && | ||
1880 | $last_machine eq $machine); | ||
1881 | |||
1882 | doprint "Find $reboot_type menu ... "; | ||
1883 | $grub_number = -1; | ||
1884 | |||
1885 | my $ssh_grub = $ssh_exec; | ||
1886 | $ssh_grub =~ s,\$SSH_COMMAND,$command,g; | ||
1887 | |||
1888 | open(IN, "$ssh_grub |") | ||
1889 | or dodie "unable to execute $command"; | ||
1890 | |||
1891 | my $found = 0; | ||
1892 | |||
1893 | while (<IN>) { | ||
1894 | if (/$target/) { | ||
1895 | $grub_number++; | ||
1896 | $found = 1; | ||
1897 | last; | ||
1898 | } elsif (/$skip/) { | ||
1899 | $grub_number++; | ||
1900 | } | ||
1901 | } | ||
1902 | close(IN); | ||
1903 | |||
1904 | dodie "Could not find '$grub_menu' through $command on $machine" | ||
1905 | if (!$found); | ||
1906 | doprint "$grub_number\n"; | ||
1907 | $last_grub_menu = $grub_menu; | ||
1908 | $last_machine = $machine; | ||
1909 | } | ||
1910 | |||
1874 | sub get_grub2_index { | 1911 | sub get_grub2_index { |
1875 | 1912 | ||
1876 | return if (defined($grub_number) && defined($last_grub_menu) && | 1913 | return if (defined($grub_number) && defined($last_grub_menu) && |