Received: by 2002:a17:90a:2044:0:0:0:0 with SMTP id n62csp1138307pjc; Thu, 9 May 2019 14:38:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKZ5BZyACO4C1MrguyorSgnWzRoW47cc4LVyqZrDOL01KLaZZhcObL03kF1O4CrJN3mc7I X-Received: by 2002:a17:902:b193:: with SMTP id s19mr8508282plr.17.1557437909378; Thu, 09 May 2019 14:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557437909; cv=none; d=google.com; s=arc-20160816; b=0Xskwi0RKlGXS0lRDpM5LqMV+U23FJE+HCi4X0pm+ES8aFENFU/Fkow1VJ6wy+dq45 hp7j88NhvzNZTsJsp+IxSMQ0/dM6OIoyZ6+U+tdsVw3JQGmW2eFjJW9mdA8tHVs7jAds JsHBRzMSFJYV4oUiJlWDGfb1DzmiX56yCUl4wRPkzmqWeCCMlWTXK6/aeqMDEgGd83oK GcnMMAtnc4K0HH7BhXgHwel4NepoJbzEIGMPQNuvfLEQz0FOcEcwMReUzQUofmyFLJUu Bs5GEqREkSYqWaoyWrh71M1sRpEyP1xyaF6gkVBsuHwqQ8sU62tdtxjyrAXHR8CjYmo/ 2BsA== 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=8fYnx3XpP10omEG1ZlzyLWO7BR4wnnd7ASZ6KJ5Ot/0=; b=NHb6jXL0Su3d9cVXqGhF06lC+FgYOxEATaKJjno7GoKh+UT0wtrc7g24eCkG+L7M4W KJUimT4w8IWPeGat6alQtlr3huNaPLdezEHx7uPZzXj1NP8jvpo5grJ/Ao+pWGEY5LTb Txnzgs2V22sZKqqFOuD3oxVERJHsfm32QoJUsQLwd4N3M/n961uP9iTDbouBCJYzWeR7 a8OWl4g4UvrOChTGGrMl8PLusXP6DUaRdn/OaP3PQcKJl1/gaiQeSFRkMPxRXOsNpzAT dsbqbzwYpbpNlPBIErcO74GyBwHjXS7tgYyqtal0mIRRi9h749+vdnxz0o9xq+u0tC3Q Mwkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mrEvjfNs; 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 i7si4939659pgb.597.2019.05.09.14.38.13; Thu, 09 May 2019 14:38:29 -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=mrEvjfNs; 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 S1727158AbfEIVhR (ORCPT + 99 others); Thu, 9 May 2019 17:37:17 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:37924 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727138AbfEIVhQ (ORCPT ); Thu, 9 May 2019 17:37:16 -0400 Received: by mail-qt1-f196.google.com with SMTP id d13so4326930qth.5 for ; Thu, 09 May 2019 14:37:15 -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=8fYnx3XpP10omEG1ZlzyLWO7BR4wnnd7ASZ6KJ5Ot/0=; b=mrEvjfNsD8myC2b92BMGcZ2DzYdXgm6EuEnq/dFCKUWNstBXwYrWDboB329TQZRaCr IGcPqzRHqkVXXEPL2cfeVRg2nMpJB1yLeNTD9+fxNJruXr55/1IEAeVMzeLGV5AvA7Cx gOq5biTsuTWjaeKkGvxC1xu6jtW3z7ZYn9kl0q1E4FCpCOPgPLbRQ08MjzG2UBOHHH6M wGi+wS6U/edWmEyawcUXDB0G15+5NiWHmgzcvSgYbnQAxiOadQ7SEn5wVngb2IFz36g8 hteMHj4iCQgyD4wQL0GZII+CDpIeS6ZF8IU3XWtEhTffjhKAQ4ldiMXKGsrpQP+hJZq6 XA2g== 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=8fYnx3XpP10omEG1ZlzyLWO7BR4wnnd7ASZ6KJ5Ot/0=; b=L0VSxbuy0QbiIRqz3blK3GeUnCB/BlOTh+EIuBM7qsuO9HqhdDSrYhKvJHt4s5VHBl 2ux3whDu4pqcvP9MTj5qrsu/EnjSN/lFdr6+7G/tyJ7KciglNxmwaJxCnQdLayE4hs4+ +JDtfbSWo4GW4i53JCAXJy/RVbBd8f4VnPnKAUvJnezRs62r5q5/SnhJSaLw3/DQ6RRq +4bJvksrVwjPDz4SXIj/QuwYOYuV8bNdc1jR7u+9G8TtbsEwzWNn4lgl8ZL1sRbgwZjo 3xlSI3IB2hvlXBikRhgae5sppVEKF06qWuE8VegIu3X9ES/vC60SEZZSknM0UJ1qEwmt 2VUQ== X-Gm-Message-State: APjAAAXvZweWautDfbfxTZYnvVpflhjpIj0FnDuc/Wf64+3VrWDZUgT6 4ti0rsR4BJELnkTdS2gq8Q== X-Received: by 2002:ac8:1af9:: with SMTP id h54mr5912239qtk.292.1557437835522; Thu, 09 May 2019 14:37:15 -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 76sm1899721qke.46.2019.05.09.14.37.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 14:37:15 -0700 (PDT) From: Masayoshi Mizuma To: Steven Rostedt Cc: Masayoshi Mizuma , Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] ktest: cleanup get_grub_index Date: Thu, 9 May 2019 17:36:43 -0400 Message-Id: <20190509213647.6276-3-msys.mizuma@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509213647.6276-1-msys.mizuma@gmail.com> References: <20190509213647.6276-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, 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 { sub get_grub_index { - if ($reboot_type eq "grub2") { - get_grub2_index; - return; - } + my $command; + my $target; + my $skip; + my $grub_menu_qt; - if ($reboot_type ne "grub") { + if ($reboot_type !~ /^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 $ssh_grub = $ssh_exec; - $ssh_grub =~ s,\$SSH_COMMAND,cat /boot/grub/menu.lst,g; - - open(IN, "$ssh_grub |") - or dodie "unable to get menu.lst"; + $grub_menu_qt = quotemeta($grub_menu); - my $found = 0; - my $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'; + } else { + return; } - 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