kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kvm-unit-tests] runtime.bash: fix check for parameter files
@ 2020-09-28 11:34 Paolo Bonzini
  2020-09-28 11:56 ` Thomas Huth
  2020-09-28 12:37 ` Andrew Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-09-28 11:34 UTC (permalink / raw)
  To: kvm; +Cc: drjones

We need to check if the file exists, not just if it is a non-empty string.
While an empty $path would have the unfortunate effect that "cat" would
read from stdin, that is not an issue as you can simply not do that.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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


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

* Re: [PATCH kvm-unit-tests] runtime.bash: fix check for parameter files
  2020-09-28 11:34 [PATCH kvm-unit-tests] runtime.bash: fix check for parameter files Paolo Bonzini
@ 2020-09-28 11:56 ` Thomas Huth
  2020-09-28 12:37 ` Andrew Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2020-09-28 11:56 UTC (permalink / raw)
  To: Paolo Bonzini, kvm; +Cc: drjones

On 28/09/2020 13.34, Paolo Bonzini wrote:
> We need to check if the file exists, not just if it is a non-empty string.
> While an empty $path would have the unfortunate effect that "cat" would
> read from stdin, that is not an issue as you can simply not do that.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/runtime.bash | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index 294e6b1..3121c1f 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -118,7 +118,7 @@ function run()
>      for check_param in "${check[@]}"; do
>          path=${check_param%%=*}
>          value=${check_param#*=}
> -        if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
> +        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
>              print_result "SKIP" $testname "" "$path not equal to $value"
>              return 2
>          fi

Reviewed-by: Thomas Huth <thuth@redhat.com>


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

* Re: [PATCH kvm-unit-tests] runtime.bash: fix check for parameter files
  2020-09-28 11:34 [PATCH kvm-unit-tests] runtime.bash: fix check for parameter files Paolo Bonzini
  2020-09-28 11:56 ` Thomas Huth
@ 2020-09-28 12:37 ` Andrew Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2020-09-28 12:37 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm

On Mon, Sep 28, 2020 at 07:34:12AM -0400, Paolo Bonzini wrote:
> We need to check if the file exists, not just if it is a non-empty string.
> While an empty $path would have the unfortunate effect that "cat" would
> read from stdin, that is not an issue as you can simply not do that.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/runtime.bash | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index 294e6b1..3121c1f 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -118,7 +118,7 @@ function run()
>      for check_param in "${check[@]}"; do
>          path=${check_param%%=*}
>          value=${check_param#*=}
> -        if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
> +        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
>              print_result "SKIP" $testname "" "$path not equal to $value"
>              return 2
>          fi
> -- 
> 2.26.2
>

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


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

end of thread, other threads:[~2020-09-28 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28 11:34 [PATCH kvm-unit-tests] runtime.bash: fix check for parameter files Paolo Bonzini
2020-09-28 11:56 ` Thomas Huth
2020-09-28 12:37 ` Andrew Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).