All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Andrew Jones <drjones@redhat.com>
Subject: [PATCH kvm-unit-tests 06/12] run_tests: move reusable code to scripts/runtime
Date: Tue, 19 Jan 2016 14:24:05 +0100	[thread overview]
Message-ID: <1453209851-27760-7-git-send-email-rkrcmar@redhat.com> (raw)
In-Reply-To: <1453209851-27760-1-git-send-email-rkrcmar@redhat.com>

Standalone tests will use it.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 run_tests.sh         | 99 +---------------------------------------------------
 scripts/runtime.bash | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+), 98 deletions(-)
 create mode 100644 scripts/runtime.bash

diff --git a/run_tests.sh b/run_tests.sh
index fad22a935b00..2549679e653b 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -6,105 +6,8 @@ if [ ! -f config.mak ]; then
 fi
 source config.mak
 source scripts/functions.bash
+source scripts/runtime.bash
 
 config=$TEST_DIR/unittests.cfg
-qemu=${QEMU:-qemu-system-$ARCH}
-verbose=0
-
-function run()
-{
-    local testname="$1"
-    local groups="$2"
-    local smp="$3"
-    local kernel="$4"
-    local opts="$5"
-    local arch="$6"
-    local check="$7"
-    local accel="$8"
-
-    if [ -z "$testname" ]; then
-        return
-    fi
-
-    if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then
-        return
-    fi
-
-    if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
-        echo "skip $1 ($arch only)"
-        return
-    fi
-
-    # check a file for a particular value before running a test
-    # the check line can contain multiple files to check separated by a space
-    # but each check parameter needs to be of the form <path>=<value>
-    for check_param in ${check[@]}; do
-        path=${check_param%%=*}
-        value=${check_param#*=}
-        if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
-            echo "skip $1 ($path not equal to $value)"
-            return
-        fi
-    done
-
-    cmdline="TESTNAME=$testname ACCEL=$accel ./$TEST_DIR-run $kernel -smp $smp $opts"
-    if [ $verbose != 0 ]; then
-        echo $cmdline
-    fi
-
-    # extra_params in the config file may contain backticks that need to be
-    # expanded, so use eval to start qemu
-    eval $cmdline >> test.log
-
-    if [ $? -le 1 ]; then
-        echo -e "\e[32mPASS\e[0m $1"
-    else
-        echo -e "\e[31mFAIL\e[0m $1"
-    fi
-}
-
-function usage()
-{
-cat <<EOF
-
-Usage: $0 [-g group] [-h] [-v]
-
-    -g: Only execute tests in the given group
-    -h: Output this help text
-    -v: Enables verbose mode
-
-Set the environment variable QEMU=/path/to/qemu-system-ARCH to
-specify the appropriate qemu binary for ARCH-run.
-
-EOF
-}
-
-echo > test.log
-while getopts "g:hv" opt; do
-    case $opt in
-        g)
-            only_group=$OPTARG
-            ;;
-        h)
-            usage
-            exit
-            ;;
-        v)
-            verbose=1
-            ;;
-        *)
-            exit
-            ;;
-    esac
-done
-
-#
-# Probe for MAX_SMP
-#
-MAX_SMP=$(getconf _NPROCESSORS_CONF)
-while ./$TEST_DIR-run _NO_FILE_4Uhere_ -smp $MAX_SMP \
-		|& grep -q 'exceeds max cpus'; do
-	((--MAX_SMP))
-done
 
 for_each_unittest $config run
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
new file mode 100644
index 000000000000..8813b9ddbf1e
--- /dev/null
+++ b/scripts/runtime.bash
@@ -0,0 +1,98 @@
+qemu=${QEMU:-qemu-system-$ARCH}
+verbose=0
+
+function run()
+{
+    local testname="$1"
+    local groups="$2"
+    local smp="$3"
+    local kernel="$4"
+    local opts="$5"
+    local arch="$6"
+    local check="$7"
+    local accel="$8"
+
+    if [ -z "$testname" ]; then
+        return
+    fi
+
+    if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then
+        return
+    fi
+
+    if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
+        echo "skip $1 ($arch only)"
+        return
+    fi
+
+    # check a file for a particular value before running a test
+    # the check line can contain multiple files to check separated by a space
+    # but each check parameter needs to be of the form <path>=<value>
+    for check_param in ${check[@]}; do
+        path=${check_param%%=*}
+        value=${check_param#*=}
+        if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
+            echo "skip $1 ($path not equal to $value)"
+            return
+        fi
+    done
+
+    cmdline="TESTNAME=$testname ACCEL=$accel ./$TEST_DIR-run $kernel -smp $smp $opts"
+    if [ $verbose != 0 ]; then
+        echo $cmdline
+    fi
+
+    # extra_params in the config file may contain backticks that need to be
+    # expanded, so use eval to start qemu
+    eval $cmdline >> test.log
+
+    if [ $? -le 1 ]; then
+        echo -e "\e[32mPASS\e[0m $1"
+    else
+        echo -e "\e[31mFAIL\e[0m $1"
+    fi
+}
+
+function usage()
+{
+cat <<EOF
+
+Usage: $0 [-g group] [-h] [-v]
+
+    -g: Only execute tests in the given group
+    -h: Output this help text
+    -v: Enables verbose mode
+
+Set the environment variable QEMU=/path/to/qemu-system-ARCH to
+specify the appropriate qemu binary for ARCH-run.
+
+EOF
+}
+
+echo > test.log
+while getopts "g:hv" opt; do
+    case $opt in
+        g)
+            only_group=$OPTARG
+            ;;
+        h)
+            usage
+            exit
+            ;;
+        v)
+            verbose=1
+            ;;
+        *)
+            exit
+            ;;
+    esac
+done
+
+#
+# Probe for MAX_SMP
+#
+MAX_SMP=$(getconf _NPROCESSORS_CONF)
+while ./$TEST_DIR-run _NO_FILE_4Uhere_ -smp $MAX_SMP \
+		|& grep -q 'exceeds max cpus'; do
+	((--MAX_SMP))
+done
-- 
2.7.0


  parent reply	other threads:[~2016-01-19 13:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 13:23 [PATCH kvm-unit-tests 00/12] scripts/mkstandalone: rewrite Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 01/12] scripts/mkstandalone: simplify redirection Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 02/12] scripts/mkstandalone: fix ARCH Radim Krčmář
2016-01-19 14:32   ` Paolo Bonzini
2016-01-19 13:24 ` [PATCH kvm-unit-tests 03/12] scripts/mkstandalone: refactor temp file creation Radim Krčmář
2016-01-19 14:46   ` Paolo Bonzini
2016-01-19 14:53     ` Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 04/12] scripts/mkstandalone: use bash in standalone test Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 05/12] scripts/mkstandalone: reuse $TEST_DIR/run Radim Krčmář
2016-01-19 13:24 ` Radim Krčmář [this message]
2016-01-19 13:24 ` [PATCH kvm-unit-tests 07/12] scripts/runtime: change callsite of $TEST_DIR/run Radim Krčmář
2016-01-19 14:38   ` Paolo Bonzini
2016-01-19 14:55     ` Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 08/12] scripts/mkstandalone: refactor check for test kernel Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 09/12] scripts/mkstandalone: use scripts/runtime Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 10/12] scripts/mkstandalone: simplifiy redirection, again Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 11/12] scripts/mkstandalone: sanitize one_kernel handling Radim Krčmář
2016-01-19 13:24 ` [PATCH kvm-unit-tests 12/12] scripts/mkstandalone: return the exit value of a test Radim Krčmář
2016-01-19 14:49 ` [PATCH kvm-unit-tests 00/12] scripts/mkstandalone: rewrite Paolo Bonzini
2016-01-19 14:56   ` Radim Krčmář
2016-01-19 15:20 ` Andrew Jones

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=1453209851-27760-7-git-send-email-rkrcmar@redhat.com \
    --to=rkrcmar@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.