diff mbox

[kvm-unit-tests,v4,13/13] scripts/run: generalize check

Message ID 1462984243-5783-4-git-send-email-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář May 11, 2016, 4:30 p.m. UTC
config attribute "check" is currently unused and a simpler imlementation
has better chances of being used.

Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 v4: new

 scripts/runtime.bash | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Comments

Andrew Jones May 11, 2016, 5:31 p.m. UTC | #1
On Wed, May 11, 2016 at 06:30:43PM +0200, Radim Kr?má? wrote:
> config attribute "check" is currently unused and a simpler imlementation
> has better chances of being used.
> 
> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> ---
>  v4: new
> 
>  scripts/runtime.bash | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index c9ab9ba47d81..7f9bf9a2de0e 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -57,17 +57,11 @@ function run()
>          return 2
>      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 2
> -        fi
> -    done
> +    eval $check || {
> +        echo "skipped $testname (\`$check\` returned $?)" | RUNTIME_log_stderr
> +        echo "`SKIP` $testname (check failed)"
> +        return 77
> +    }
>  
>      last_line=$(premature_failure) && {
>          echo "`SKIP` $1 ($last_line)"
> -- 

Good, except you need to update all the unittests.cfg headers where
check is documented. Maybe something like

 check = <bash-expr>	# check an expression is true before running the test

Thanks,
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
diff mbox

Patch

diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index c9ab9ba47d81..7f9bf9a2de0e 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -57,17 +57,11 @@  function run()
         return 2
     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 2
-        fi
-    done
+    eval $check || {
+        echo "skipped $testname (\`$check\` returned $?)" | RUNTIME_log_stderr
+        echo "`SKIP` $testname (check failed)"
+        return 77
+    }
 
     last_line=$(premature_failure) && {
         echo "`SKIP` $1 ($last_line)"