KVM Archive on lore.kernel.org
 help / color / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: kvm@vger.kernel.org
Cc: Thomas Huth <thuth@redhat.com>
Subject: [PATCH kvm-unit-tests] scripts: Fix the check whether testname is in the only_tests list
Date: Wed,  1 Jul 2020 11:46:35 +0200
Message-ID: <20200701094635.19491-1-pbonzini@redhat.com> (raw)

When you currently run

  ./run_tests.sh ioapic-split

the kvm-unit-tests run scripts do not only execute the "ioapic-split"
test, but also the "ioapic" test, which is quite surprising. This
happens because we use "grep -w" for checking whether a test should
be run or not.  Because "grep -w" does not consider the "-" character as
part of a word, "ioapic" successfully matches against "ioapic-split".

To fix the issue, use spaces as the only delimiter when running "grep",
removing the problematic "-w" flag from the invocation.

Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/runtime.bash | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 8bfe31c..6158e37 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -68,6 +68,11 @@ function print_result()
     fi
 }
 
+function find_word()
+{
+    grep -q " $1 " <<< " $2 "
+}
+
 function run()
 {
     local testname="$1"
@@ -84,15 +89,15 @@ function run()
         return
     fi
 
-    if [ -n "$only_tests" ] && ! grep -qw "$testname" <<<$only_tests; then
+    if [ -n "$only_tests" ] && ! find_word "$testname" "$only_tests"; then
         return
     fi
 
-    if [ -n "$only_group" ] && ! grep -qw "$only_group" <<<$groups; then
+    if [ -n "$only_group" ] && ! find_word "$only_group" "$groups"; then
         return
     fi
 
-    if [ -z "$only_group" ] && grep -qw "nodefault" <<<$groups &&
+    if [ -z "$only_group" ] && find_word nodefault "$groups" &&
             skip_nodefault; then
         print_result "SKIP" $testname "" "test marked as manual run only"
         return;
-- 
2.25.4


             reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01  9:46 Paolo Bonzini [this message]
2020-07-01  9:52 ` Thomas Huth
2020-07-01 10:05   ` Paolo Bonzini
2020-07-01 10:11     ` Thomas Huth

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=20200701094635.19491-1-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=thuth@redhat.com \
    /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

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org
	public-inbox-index kvm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kvm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git