diff mbox series

[v2,04/31] tests/functional: simplify 'which' implementation

Message ID 20241211172648.2893097-5-berrange@redhat.com (mailing list archive)
State New
Headers show
Series tests/functional: various improvements wrt assets/scratch files | expand

Commit Message

Daniel P. Berrangé Dec. 11, 2024, 5:26 p.m. UTC
The 'access' check implies the file exists.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/functional/qemu_test/cmd.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Huth Dec. 11, 2024, 7:32 p.m. UTC | #1
On 11/12/2024 18.26, Daniel P. Berrangé wrote:
> The 'access' check implies the file exists.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/functional/qemu_test/cmd.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
> index 4106f1ee7c..600e0509db 100644
> --- a/tests/functional/qemu_test/cmd.py
> +++ b/tests/functional/qemu_test/cmd.py
> @@ -25,7 +25,7 @@ def which(tool):
>       paths=os.getenv('PATH')
>       for p in paths.split(os.path.pathsep):
>           p = os.path.join(p, tool)
> -        if os.path.exists(p) and os.access(p, os.X_OK):
> +        if os.access(p, os.X_OK):
>               return p
>       return None

Reviewed-by: Thomas Huth <thuth@redhat.com>
Richard Henderson Dec. 11, 2024, 8:50 p.m. UTC | #2
On 12/11/24 11:26, Daniel P. Berrangé wrote:
> The 'access' check implies the file exists.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/functional/qemu_test/cmd.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
> index 4106f1ee7c..600e0509db 100644
> --- a/tests/functional/qemu_test/cmd.py
> +++ b/tests/functional/qemu_test/cmd.py
> @@ -25,7 +25,7 @@ def which(tool):
>       paths=os.getenv('PATH')
>       for p in paths.split(os.path.pathsep):
>           p = os.path.join(p, tool)
> -        if os.path.exists(p) and os.access(p, os.X_OK):
> +        if os.access(p, os.X_OK):
>               return p
>       return None
>   

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
index 4106f1ee7c..600e0509db 100644
--- a/tests/functional/qemu_test/cmd.py
+++ b/tests/functional/qemu_test/cmd.py
@@ -25,7 +25,7 @@  def which(tool):
     paths=os.getenv('PATH')
     for p in paths.split(os.path.pathsep):
         p = os.path.join(p, tool)
-        if os.path.exists(p) and os.access(p, os.X_OK):
+        if os.access(p, os.X_OK):
             return p
     return None