Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1106203yba; Thu, 9 May 2019 10:49:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIvguz/SfPRLnpOcmGqgfG1wJEfvD2fXnrJqKfNIHCQkY8rKPPXJy07t4MVEWI6yhz0Tmw X-Received: by 2002:a17:902:9048:: with SMTP id w8mr6803700plz.195.1557424190588; Thu, 09 May 2019 10:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557424190; cv=none; d=google.com; s=arc-20160816; b=f3f7eUZVFzngT1ILSAdW428mp7BXZ8zxiJ9oloNIkISuJ6PPJcLB77jTGTQTSUdHTT TugpocRYmUZr2u6A9OKY8yq2gsFtxHKz0GYSXHWHa0a60yCrhfoF+CXfxMM4D8zyhL3S v/v00KvFOl7uDBANenAevk7T6kYxrDIRTxkUE3o66o6/GocukdAWDVbnigHpD2StkvcH FZa+R+h/BqUAg41X7pYd/PDrcmszREhG3XHNikxvPxB9KcAdFejq/FEwGd6h5JlTYqGn vrtvGb/isRPgvQ8/QJGe1cEKpdZ2tRnWQNWJUOSNHPtof3H3ab1liN4a+MGyLochCGpp nVrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=cj0DlhFnSLAXH8ArFEaurqQD8JYO47YeBdLQtQ9/QVc=; b=COBqQfThYL749jOqdKNYur78yQlg+FwuEUxuMx7nLf+QPFMJpiCwNLf/GS16TUr/cv Jwaz6Tlj4ZaDn/2NSIx+z5DKMC4xq6dg1pR++ZIZ8rcw2+isU4BeBD1voVtZ4vECKyh+ 4RD0te/sopyGJAVpKZ3g6/KsClPX9dNYjXBcFRyrPmoz+C6uWvuTlekkvP1C1iPQ35Kr plC9ac4YTo5hoU2ni5lKDjLPie0olcJYoydM76FizPBFNe/2/EllVq3irvLLxM0ebaxq MRSY1aN9PKosKlfyGLb86GdC2IDq/6mkaondY0rTHBttwBrPyc+MfYy6pJiYqBwBUOR4 cA8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j0khjSsD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f16si3944170plr.340.2019.05.09.10.49.34; Thu, 09 May 2019 10:49:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j0khjSsD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbfEIRrV (ORCPT + 99 others); Thu, 9 May 2019 13:47:21 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:42891 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbfEIRrU (ORCPT ); Thu, 9 May 2019 13:47:20 -0400 Received: by mail-qt1-f195.google.com with SMTP id j53so3480734qta.9 for ; Thu, 09 May 2019 10:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cj0DlhFnSLAXH8ArFEaurqQD8JYO47YeBdLQtQ9/QVc=; b=j0khjSsDQ+XotdNTQOii0x/GJROhNyKRcRxPjSoMJOawGSM/UPXykPs8Oa9AEw8OPn KgqhrQY3t5ZWdcD63P8+nKWr4eBrtbactYWg23xPTtwa8xYR6Pze8KFJ7pTJqWVdx9dd 8oUTxuirKZOvFvKMPO4wcSlsYO35o6aiuw3ARSFFPv3MLtyWNF75Yfh+OQcORI3N0lVJ wPsPP3RnHdxfGMyBLqdCDdvRqTOSa2Gh1cVoLiQrm5exIhoPUrYlrGx1SqKOm/xa2OxJ 08qITYXjQeAAy03bGUjdUIdbZa8kRyxXfSEHD9vQwWZPWXv8jHyE3VNownq2qkQV3432 P79A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cj0DlhFnSLAXH8ArFEaurqQD8JYO47YeBdLQtQ9/QVc=; b=hFFoSid92RgbLUdVBGqmQpU/c5UUTLdna5H/nw6OPu5qNCwQ9YmClpm0JVCFls34GI Io/Lg5519eKCGybYQxrg4k6Pb940y3BQMQkPptaSD28N86zkxdEIxw3WjjtzZ89dYVEG LBIYCdnpYiE3YibaBcLhacifNCnjjxSt6ZIDSVl4cpYYxZay389Q91ZGJXZaDJoAFsJy EMVyj2teoApIaJ0aileB+am6EUiMGdg1NTxE4gp84jF45xeJW6HIj0Y2FbC/bP06Gj2D Oi0r70SboPot3NCNsZX+yOmxw21liDhQmVcFy3Mjx0n7x8n/obQzKQAxAOOfllfO6Goj rBRw== X-Gm-Message-State: APjAAAWy4IF68SnexvXvIQ+gxuAAqn1Q6ssUbrc2lM0vV0mBCj6Ek4JC RaXzES68uW5s19bS7FIGkw== X-Received: by 2002:aed:3fa7:: with SMTP id s36mr5012741qth.124.1557424039826; Thu, 09 May 2019 10:47:19 -0700 (PDT) Received: from gabell.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id z11sm1262953qki.95.2019.05.09.10.47.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 10:47:19 -0700 (PDT) From: Masayoshi Mizuma To: Steven Rostedt Cc: Masayoshi Mizuma , Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: [PATCH 2/5] ktest: cleanup get_grub_index Date: Thu, 9 May 2019 13:46:27 -0400 Message-Id: <20190509174630.26713-3-msys.mizuma@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509174630.26713-1-msys.mizuma@gmail.com> References: <20190509174630.26713-1-msys.mizuma@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masayoshi Mizuma Cleanup get_grub_index(). Signed-off-by: Masayoshi Mizuma --- 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 () { - 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