diff mbox

[kvm-unit-tests,v2,01/12] run_tests: move run() to scripts/

Message ID 1450374823-7648-2-git-send-email-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář Dec. 17, 2015, 5:53 p.m. UTC
We'll be using it from scripts/mkstandalone later.

Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 v2: new
 
 run_tests.sh     | 53 +----------------------------------------------------
 scripts/run.bash | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 52 deletions(-)
 create mode 100644 scripts/run.bash

Comments

Andrew Jones Dec. 17, 2015, 6:45 p.m. UTC | #1
On Thu, Dec 17, 2015 at 06:53:32PM +0100, Radim Kr?má? wrote:
> We'll be using it from scripts/mkstandalone later.
> 
> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> ---
>  v2: new
>  
>  run_tests.sh     | 53 +----------------------------------------------------
>  scripts/run.bash | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++

Could probably just put run() in scripts/functions.bash

drew
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Radim Krčmář Dec. 18, 2015, 10:42 a.m. UTC | #2
2015-12-17 12:45-0600, Andrew Jones:
> On Thu, Dec 17, 2015 at 06:53:32PM +0100, Radim Kr?má? wrote:
>> We'll be using it from scripts/mkstandalone later.
>> 
>> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
>> ---
>>  v2: new
>>  
>>  run_tests.sh     | 53 +----------------------------------------------------
>>  scripts/run.bash | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 
> Could probably just put run() in scripts/functions.bash

Definitely.  The drawback is that for_each_unittest() and any future
helper would be pasted in each unit test, which would complicate
conversion back to shell and uselessly bloat tests.  Even though I like
programming in shell far more than in C, I would not do it if we decide
to POSIX our standalone tests.  (Bloating is not an issue for me.)
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Jones Dec. 18, 2015, 6:52 p.m. UTC | #3
On Fri, Dec 18, 2015 at 11:42:40AM +0100, Radim Kr?má? wrote:
> 2015-12-17 12:45-0600, Andrew Jones:
> > On Thu, Dec 17, 2015 at 06:53:32PM +0100, Radim Kr?má? wrote:
> >> We'll be using it from scripts/mkstandalone later.
> >> 
> >> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> >> ---
> >>  v2: new
> >>  
> >>  run_tests.sh     | 53 +----------------------------------------------------
> >>  scripts/run.bash | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> > 
> > Could probably just put run() in scripts/functions.bash
> 
> Definitely.  The drawback is that for_each_unittest() and any future
> helper would be pasted in each unit test, which would complicate
> conversion back to shell and uselessly bloat tests.  Even though I like

Oh right, nevermind then. If we're going to 'cat run.bash >>' then it
needs to be separate. But do we really want to 'cat run.bash'? I guess I
need to look at your mkstandalone changes again.

> programming in shell far more than in C, I would not do it if we decide
> to POSIX our standalone tests.  (Bloating is not an issue for me.)
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/run_tests.sh b/run_tests.sh
index fad22a935b00..58949e39c38c 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -6,63 +6,12 @@  if [ ! -f config.mak ]; then
 fi
 source config.mak
 source scripts/functions.bash
+source scripts/run.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
diff --git a/scripts/run.bash b/scripts/run.bash
new file mode 100644
index 000000000000..0c5a2569d80e
--- /dev/null
+++ b/scripts/run.bash
@@ -0,0 +1,51 @@ 
+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
+}