LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Masayoshi Mizuma <msys.mizuma@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Masayoshi Mizuma <msys.mizuma@gmail.com>,
Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] ktest: cleanup get_grub_index
Date: Thu, 9 May 2019 13:46:27 -0400 [thread overview]
Message-ID: <20190509174630.26713-3-msys.mizuma@gmail.com> (raw)
In-Reply-To: <20190509174630.26713-1-msys.mizuma@gmail.com>
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Cleanup get_grub_index().
Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
tools/testing/ktest/ktest.pl | 50 +++++++++++-------------------------
1 file changed, 15 insertions(+), 35 deletions(-)
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 3862b23672f7..1255ea0d9df4 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -1934,46 +1934,26 @@ sub get_grub2_index {
sub get_grub_index {
- if ($reboot_type eq "grub2") {
- get_grub2_index;
- return;
- }
-
- if ($reboot_type ne "grub") {
- 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 $command;
+ my $target;
+ my $skip;
+ my $grub_menu_qt;
- my $ssh_grub = $ssh_exec;
- $ssh_grub =~ s,\$SSH_COMMAND,cat /boot/grub/menu.lst,g;
+ return if ($reboot_type ne "grub") and ($reboot_type ne "grub2");
- open(IN, "$ssh_grub |")
- or dodie "unable to get menu.lst";
-
- my $found = 0;
- my $grub_menu_qt = quotemeta($grub_menu);
+ $grub_menu_qt = quotemeta($grub_menu);
- while (<IN>) {
- if (/^\s*title\s+$grub_menu_qt\s*$/) {
- $grub_number++;
- $found = 1;
- last;
- } elsif (/^\s*title\s/) {
- $grub_number++;
- }
+ if ($reboot_type eq "grub") {
+ $command = "cat /boot/grub/menu.lst";
+ $target = '^\s*title\s+' . $grub_menu_qt . '\s*$';
+ $skip = '^\s*title\s';
+ } elsif ($reboot_type eq "grub2") {
+ $command = "cat $grub_file";
+ $target = '^menuentry.*' . $grub_menu_qt;
+ $skip = '^menuentry\s|^submenu\s';
}
- close(IN);
- dodie "Could not find '$grub_menu' in /boot/grub/menu on $machine"
- if (!$found);
- doprint "$grub_number\n";
- $last_grub_menu = $grub_menu;
- $last_machine = $machine;
+ _get_grub_index($command, $target, $skip);
}
sub wait_for_input
--
2.20.1
next prev parent reply other threads:[~2019-05-09 17:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-09 17:46 [PATCH 0/5] ktest: support for Boot Loader Specification Masayoshi Mizuma
2019-05-09 17:46 ` [PATCH 1/5] ktest: introduce _get_grub_index Masayoshi Mizuma
2019-05-09 17:46 ` Masayoshi Mizuma [this message]
2019-05-09 17:57 ` [PATCH 2/5] ktest: cleanup get_grub_index Steven Rostedt
2019-05-09 18:41 ` Masayoshi Mizuma
2019-05-09 19:13 ` Steven Rostedt
2019-05-09 17:46 ` [PATCH 3/5] ktest: introduce grub2bls REBOOT_TYPE option Masayoshi Mizuma
2019-05-09 17:46 ` [PATCH 4/5] ktest: remove get_grub2_index Masayoshi Mizuma
2019-05-09 17:46 ` [PATCH 5/5] ktest: update sample.conf for grub2bls Masayoshi Mizuma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190509174630.26713-3-msys.mizuma@gmail.com \
--to=msys.mizuma@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.mizuma@jp.fujitsu.com \
--cc=rostedt@goodmis.org \
--subject='Re: [PATCH 2/5] ktest: cleanup get_grub_index' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).