[PATCH] tests/functional/x86_64: Use the right Python interpreter & fix format string

Thomas Huth posted 1 patch 3 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260114101101.36225-1-thuth@redhat.com
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>
tests/functional/x86_64/test_bad_vmstate.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] tests/functional/x86_64: Use the right Python interpreter & fix format string
Posted by Thomas Huth 3 weeks, 2 days ago
From: Thomas Huth <thuth@redhat.com>

The bad_vmstate test currently fails if the host does not have a "python3"
binary in $PATH because the vmstate-static-checker.py script is executed
directly, so that it gets run via its shebang line. Use the right Python
interpreter from sys.executable to fix this problem.

Additionally, there was another bug with the formatting of the error
message in case of failures: The "+" operator can only concatenate strings,
but not strings with integers. Use a proper format string here instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/x86_64/test_bad_vmstate.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/functional/x86_64/test_bad_vmstate.py b/tests/functional/x86_64/test_bad_vmstate.py
index 40098a8490b..71a1c0cf638 100755
--- a/tests/functional/x86_64/test_bad_vmstate.py
+++ b/tests/functional/x86_64/test_bad_vmstate.py
@@ -5,6 +5,7 @@
 '''Test whether the vmstate-static-checker script detects problems correctly'''
 
 import subprocess
+import sys
 
 from qemu_test import QemuBaseTest
 
@@ -41,12 +42,13 @@ def test_checker(self):
                                        'vmstate-static-checker.py')
 
         self.log.info('Comparing %s with %s', src_json, dst_json)
-        cp = subprocess.run([checkerscript, '-s', src_json, '-d', dst_json],
+        cp = subprocess.run([sys.executable, checkerscript,
+                             '-s', src_json, '-d', dst_json],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT,
                             text=True, check=False)
         if cp.returncode != 13:
-            self.fail('Unexpected return code of vmstate-static-checker: ' +
+            self.fail('Unexpected return code of vmstate-static-checker: %d' %
                       cp.returncode)
         if cp.stdout != EXPECTED_OUTPUT:
             self.log.info('vmstate-static-checker output:\n%s', cp.stdout)
-- 
2.52.0
Re: [PATCH] tests/functional/x86_64: Use the right Python interpreter & fix format string
Posted by Fabiano Rosas 3 weeks, 2 days ago
Thomas Huth <thuth@redhat.com> writes:

> From: Thomas Huth <thuth@redhat.com>
>
> The bad_vmstate test currently fails if the host does not have a "python3"
> binary in $PATH because the vmstate-static-checker.py script is executed
> directly, so that it gets run via its shebang line. Use the right Python
> interpreter from sys.executable to fix this problem.
>
> Additionally, there was another bug with the formatting of the error
> message in case of failures: The "+" operator can only concatenate strings,
> but not strings with integers. Use a proper format string here instead.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/functional/x86_64/test_bad_vmstate.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tests/functional/x86_64/test_bad_vmstate.py b/tests/functional/x86_64/test_bad_vmstate.py
> index 40098a8490b..71a1c0cf638 100755
> --- a/tests/functional/x86_64/test_bad_vmstate.py
> +++ b/tests/functional/x86_64/test_bad_vmstate.py
> @@ -5,6 +5,7 @@
>  '''Test whether the vmstate-static-checker script detects problems correctly'''
>  
>  import subprocess
> +import sys
>  
>  from qemu_test import QemuBaseTest
>  
> @@ -41,12 +42,13 @@ def test_checker(self):
>                                         'vmstate-static-checker.py')
>  
>          self.log.info('Comparing %s with %s', src_json, dst_json)
> -        cp = subprocess.run([checkerscript, '-s', src_json, '-d', dst_json],
> +        cp = subprocess.run([sys.executable, checkerscript,
> +                             '-s', src_json, '-d', dst_json],
>                              stdout=subprocess.PIPE,
>                              stderr=subprocess.STDOUT,
>                              text=True, check=False)
>          if cp.returncode != 13:
> -            self.fail('Unexpected return code of vmstate-static-checker: ' +
> +            self.fail('Unexpected return code of vmstate-static-checker: %d' %
>                        cp.returncode)
>          if cp.stdout != EXPECTED_OUTPUT:
>              self.log.info('vmstate-static-checker output:\n%s', cp.stdout)

Acked-by: Fabiano Rosas <farosas@suse.de>
Re: [PATCH] tests/functional/x86_64: Use the right Python interpreter & fix format string
Posted by Daniel P. Berrangé 3 weeks, 2 days ago
On Wed, Jan 14, 2026 at 11:11:01AM +0100, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> The bad_vmstate test currently fails if the host does not have a "python3"
> binary in $PATH because the vmstate-static-checker.py script is executed
> directly, so that it gets run via its shebang line. Use the right Python
> interpreter from sys.executable to fix this problem.
> 
> Additionally, there was another bug with the formatting of the error
> message in case of failures: The "+" operator can only concatenate strings,
> but not strings with integers. Use a proper format string here instead.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/functional/x86_64/test_bad_vmstate.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|