KVM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 kvm-unit-tests] runtime.bash: skip test when checked file doesn't exist
@ 2020-10-15  8:38 Vitaly Kuznetsov
  2020-10-15  8:43 ` Andrew Jones
  2020-10-15 12:03 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2020-10-15  8:38 UTC (permalink / raw)
  To: kvm, Paolo Bonzini; +Cc: Thomas Huth, Andrew Jones

Currently, we have the following check condition in x86/unittests.cfg:

check = /sys/module/kvm_intel/parameters/allow_smaller_maxphyaddr=Y

the check, however, passes successfully on AMD because the checked file
is just missing. This doesn't sound right, reverse the check: fail
if the content of the file doesn't match the expectation or if the
file is not there.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
Changes since v1:
- tabs -> spaces [Thomas]
---
 scripts/runtime.bash | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 3121c1ffdae8..99d242d5cf8c 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -118,7 +118,10 @@ function run()
     for check_param in "${check[@]}"; do
         path=${check_param%%=*}
         value=${check_param#*=}
-        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
+        if [ -z "$path" ]; then
+            continue
+        fi
+        if [ ! -f "$path" ] || [ "$(cat $path)" != "$value" ]; then
             print_result "SKIP" $testname "" "$path not equal to $value"
             return 2
         fi
-- 
2.25.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 kvm-unit-tests] runtime.bash: skip test when checked file doesn't exist
  2020-10-15  8:38 [PATCH v2 kvm-unit-tests] runtime.bash: skip test when checked file doesn't exist Vitaly Kuznetsov
@ 2020-10-15  8:43 ` Andrew Jones
  2020-10-15 12:03 ` Paolo Bonzini
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Jones @ 2020-10-15  8:43 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: kvm, Paolo Bonzini, Thomas Huth

On Thu, Oct 15, 2020 at 10:38:08AM +0200, Vitaly Kuznetsov wrote:
> Currently, we have the following check condition in x86/unittests.cfg:
> 
> check = /sys/module/kvm_intel/parameters/allow_smaller_maxphyaddr=Y
> 
> the check, however, passes successfully on AMD because the checked file
> is just missing. This doesn't sound right, reverse the check: fail
> if the content of the file doesn't match the expectation or if the
> file is not there.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
> Changes since v1:
> - tabs -> spaces [Thomas]
> ---
>  scripts/runtime.bash | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index 3121c1ffdae8..99d242d5cf8c 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -118,7 +118,10 @@ function run()
>      for check_param in "${check[@]}"; do
>          path=${check_param%%=*}
>          value=${check_param#*=}
> -        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
> +        if [ -z "$path" ]; then
> +            continue
> +        fi
> +        if [ ! -f "$path" ] || [ "$(cat $path)" != "$value" ]; then
>              print_result "SKIP" $testname "" "$path not equal to $value"
>              return 2
>          fi
> -- 
> 2.25.4
>

Reviewed-by: Andrew Jones <drjones@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 kvm-unit-tests] runtime.bash: skip test when checked file doesn't exist
  2020-10-15  8:38 [PATCH v2 kvm-unit-tests] runtime.bash: skip test when checked file doesn't exist Vitaly Kuznetsov
  2020-10-15  8:43 ` Andrew Jones
@ 2020-10-15 12:03 ` Paolo Bonzini
  2020-10-15 13:51   ` Vitaly Kuznetsov
  1 sibling, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2020-10-15 12:03 UTC (permalink / raw)
  To: Vitaly Kuznetsov, kvm; +Cc: Thomas Huth, Andrew Jones

On 15/10/20 10:38, Vitaly Kuznetsov wrote:
> Currently, we have the following check condition in x86/unittests.cfg:
> 
> check = /sys/module/kvm_intel/parameters/allow_smaller_maxphyaddr=Y
> 
> the check, however, passes successfully on AMD because the checked file
> is just missing. This doesn't sound right, reverse the check: fail
> if the content of the file doesn't match the expectation or if the
> file is not there.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>

Hi Vitaly, I had already posted a fix for this but I pushed it only to
my repo and not to upstream (still getting used to CI!).  I pushed it now.

My fix actually checked whether ${check} was not empty at all.  That
said, the usage of ${check[@]} is wrong because $check is not an array.
 So it would break if we wanted to have more than one check.

Paolo

> ---
> Changes since v1:
> - tabs -> spaces [Thomas]
> ---
>  scripts/runtime.bash | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index 3121c1ffdae8..99d242d5cf8c 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -118,7 +118,10 @@ function run()
>      for check_param in "${check[@]}"; do
>          path=${check_param%%=*}
>          value=${check_param#*=}
> -        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
> +        if [ -z "$path" ]; then
> +            continue
> +        fi
> +        if [ ! -f "$path" ] || [ "$(cat $path)" != "$value" ]; then
>              print_result "SKIP" $testname "" "$path not equal to $value"
>              return 2
>          fi
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 kvm-unit-tests] runtime.bash: skip test when checked file doesn't exist
  2020-10-15 12:03 ` Paolo Bonzini
@ 2020-10-15 13:51   ` Vitaly Kuznetsov
  0 siblings, 0 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2020-10-15 13:51 UTC (permalink / raw)
  To: Paolo Bonzini, kvm; +Cc: Thomas Huth, Andrew Jones

Paolo Bonzini <pbonzini@redhat.com> writes:

> On 15/10/20 10:38, Vitaly Kuznetsov wrote:
>> Currently, we have the following check condition in x86/unittests.cfg:
>> 
>> check = /sys/module/kvm_intel/parameters/allow_smaller_maxphyaddr=Y
>> 
>> the check, however, passes successfully on AMD because the checked file
>> is just missing. This doesn't sound right, reverse the check: fail
>> if the content of the file doesn't match the expectation or if the
>> file is not there.
>> 
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> Hi Vitaly, I had already posted a fix for this but I pushed it only to
> my repo and not to upstream (still getting used to CI!).  I pushed it
> now.

Hm, I still don't see it on gitlab but as long as the bug is fixed I'm
fine ;-)

>
> My fix actually checked whether ${check} was not empty at all.  That
> said, the usage of ${check[@]} is wrong because $check is not an array.
>  So it would break if we wanted to have more than one check.

Oh, yes, I see.

>
> Paolo
>
>> ---
>> Changes since v1:
>> - tabs -> spaces [Thomas]
>> ---
>>  scripts/runtime.bash | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
>> index 3121c1ffdae8..99d242d5cf8c 100644
>> --- a/scripts/runtime.bash
>> +++ b/scripts/runtime.bash
>> @@ -118,7 +118,10 @@ function run()
>>      for check_param in "${check[@]}"; do
>>          path=${check_param%%=*}
>>          value=${check_param#*=}
>> -        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
>> +        if [ -z "$path" ]; then
>> +            continue
>> +        fi
>> +        if [ ! -f "$path" ] || [ "$(cat $path)" != "$value" ]; then
>>              print_result "SKIP" $testname "" "$path not equal to $value"
>>              return 2
>>          fi
>> 
>

-- 
Vitaly


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15  8:38 [PATCH v2 kvm-unit-tests] runtime.bash: skip test when checked file doesn't exist Vitaly Kuznetsov
2020-10-15  8:43 ` Andrew Jones
2020-10-15 12:03 ` Paolo Bonzini
2020-10-15 13:51   ` Vitaly Kuznetsov

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