[PATCH v2 11/13] tests: fix check for sudo access in LUKS I/O test

Daniel P. Berrangé posted 13 patches 3 weeks, 6 days ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
There is a newer version of this series
[PATCH v2 11/13] tests: fix check for sudo access in LUKS I/O test
Posted by Daniel P. Berrangé 3 weeks, 6 days ago
The test did not cope with the possibility that 'sudo' was not installed
at all, merely that it was not configured. This broke tests in any CI
env which lacks 'sudo'.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/qemu-iotests/149 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
index c13343d7ef..6dff39a28a 100755
--- a/tests/qemu-iotests/149
+++ b/tests/qemu-iotests/149
@@ -95,11 +95,14 @@ def verify_passwordless_sudo():
 
     args = ["sudo", "-n", "/bin/true"]
 
-    proc = subprocess.Popen(args,
-                            stdin=subprocess.PIPE,
-                            stdout=subprocess.PIPE,
-                            stderr=subprocess.STDOUT,
-                            universal_newlines=True)
+    try:
+        proc = subprocess.Popen(args,
+                                stdin=subprocess.PIPE,
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.STDOUT,
+                                universal_newlines=True)
+    except FileNotFoundError as e:
+        iotests.notrun('requires sudo binary: %s' % e)
 
     msg = proc.communicate()[0]
 
-- 
2.52.0


Re: [PATCH v2 11/13] tests: fix check for sudo access in LUKS I/O test
Posted by Thomas Huth 3 weeks, 5 days ago
On 12/01/2026 21.40, Daniel P. Berrangé wrote:
> The test did not cope with the possibility that 'sudo' was not installed
> at all, merely that it was not configured. This broke tests in any CI
> env which lacks 'sudo'.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/qemu-iotests/149 | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
> index c13343d7ef..6dff39a28a 100755
> --- a/tests/qemu-iotests/149
> +++ b/tests/qemu-iotests/149
> @@ -95,11 +95,14 @@ def verify_passwordless_sudo():
>   
>       args = ["sudo", "-n", "/bin/true"]
>   
> -    proc = subprocess.Popen(args,
> -                            stdin=subprocess.PIPE,
> -                            stdout=subprocess.PIPE,
> -                            stderr=subprocess.STDOUT,
> -                            universal_newlines=True)
> +    try:
> +        proc = subprocess.Popen(args,
> +                                stdin=subprocess.PIPE,
> +                                stdout=subprocess.PIPE,
> +                                stderr=subprocess.STDOUT,
> +                                universal_newlines=True)
> +    except FileNotFoundError as e:
> +        iotests.notrun('requires sudo binary: %s' % e)
>   
>       msg = proc.communicate()[0]
>   

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