From: Thomas Huth <[email protected]>

The tracetool tests currently fail if the host installation does not
have a "python3" binary (and you compiled QEMU by selecting a different
one during the "configure" step). This happens because tracetool-test.py
executes scripts/tracetool.py directly, so that this script is run via
its shebang line.
To fix the issue, pass the right Python interpreter to tracetool-test.py
via the PYTHON environment variable and use that to run the tracetool.py
script.

Signed-off-by: Thomas Huth <[email protected]>
---
 tests/tracetool/meson.build       | 3 +++
 tests/tracetool/tracetool-test.py | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/tracetool/meson.build b/tests/tracetool/meson.build
index 09bbaaa86bf..7ff8ada7b23 100644
--- a/tests/tracetool/meson.build
+++ b/tests/tracetool/meson.build
@@ -15,6 +15,8 @@ backends = [
 
 # The tracetool-test.py program has portability problems on Windows.
 if host_machine.system() != 'windows'
+    test_env = environment()
+    test_env.set('PYTHON', python.full_path())
     foreach backend: backends
         test(backend,
              python,
@@ -23,6 +25,7 @@ if host_machine.system() != 'windows'
                     backend,
                     meson.current_source_dir(),
                     meson.current_build_dir()],
+             env: test_env,
              suite: ['tracetool'])
     endforeach
 endif
diff --git a/tests/tracetool/tracetool-test.py 
b/tests/tracetool/tracetool-test.py
index 30006a99190..9e62a81d4c3 100755
--- a/tests/tracetool/tracetool-test.py
+++ b/tests/tracetool/tracetool-test.py
@@ -36,7 +36,9 @@ def test_tracetool_one(tracetool, backend, fmt, src_dir, 
build_dir):
     actual_file = Path(build_dir, rel_filename)
     expect_file = Path(src_dir, rel_filename)
 
-    args = [tracetool, f"--format={fmt}", f"--backends={backend}", 
"--group=testsuite"]
+    python = os.environ.get("PYTHON", "python3")
+    args = [python, tracetool, f"--format={fmt}", f"--backends={backend}",
+            "--group=testsuite"]
 
     if fmt.find("stap") != -1:
         args += ["--binary=qemu", "--probe-prefix=qemu"]
-- 
2.52.0


Reply via email to