diff mbox

[kvm-unit-tests,4/6] run_tests: generalize check

Message ID 1450128261-21170-5-git-send-email-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář Dec. 14, 2015, 9:24 p.m. UTC
config attribute "check" is currently unused.
Provide a simple implementation instead of removing it.

Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 run_tests.sh | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Andrew Jones Dec. 14, 2015, 10:11 p.m. UTC | #1
On Mon, Dec 14, 2015 at 10:24:19PM +0100, Radim Kr?má? wrote:
> config attribute "check" is currently unused.
> Provide a simple implementation instead of removing it.
> 
> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> ---
>  run_tests.sh | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/run_tests.sh b/run_tests.sh
> index 4d813b9a7084..b0b064f2e341 100755
> --- a/run_tests.sh
> +++ b/run_tests.sh
> @@ -35,17 +35,10 @@ function run()
>          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
> +    eval $check || {
> +        echo "skip $1 (failed \$($check))"
> +        return
> +    }

I think we should use "\e[33mSKIP\e[0m" for skip. Maybe we should create
pass(),fail(),skip() functions in order to make sure all callers use the
same prefix with the same color.

>  
>      cmdline="TESTNAME=$testname ACCEL=$accel ./$TEST_DIR-run $kernel -smp $smp $opts"
>      if [ $verbose != 0 ]; then
> -- 
> 2.6.4
> 
> --
> 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
Radim Krčmář Dec. 15, 2015, 1:05 p.m. UTC | #2
2015-12-14 16:11-0600, Andrew Jones:
> On Mon, Dec 14, 2015 at 10:24:19PM +0100, Radim Kr?má? wrote:
> > ---
>> diff --git a/run_tests.sh b/run_tests.sh
>> @@ -35,17 +35,10 @@ function run()
>>          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
>> +    eval $check || {
>> +        echo "skip $1 (failed \$($check))"
>> +        return
>> +    }
> 
> I think we should use "\e[33mSKIP\e[0m" for skip. Maybe we should create
> pass(),fail(),skip() functions in order to make sure all callers use the
> same prefix with the same color.

Sounds good.
--
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 4d813b9a7084..b0b064f2e341 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -35,17 +35,10 @@  function run()
         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
+    eval $check || {
+        echo "skip $1 (failed \$($check))"
+        return
+    }
 
     cmdline="TESTNAME=$testname ACCEL=$accel ./$TEST_DIR-run $kernel -smp $smp $opts"
     if [ $verbose != 0 ]; then