Skip to contentSkip to conversation

tests/tracetool: Honor the Python interpreter that "configure" detected

PATCH Superseded Thomas Huth 3 participants 4 messages Jan 14 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/tracetool: Honor the Python interpreter that "configure" detected

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.

---
 tests/tracetool/meson.build       | 3 +++
 tests/tracetool/tracetool-test.py | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)
tests/tracetool/meson.build +3 -0
index 09bbaaa86bf..7ff8ada7b23 100644
@@ -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
tests/tracetool/tracetool-test.py +3 -1
index 30006a99190..9e62a81d4c3 100755
@@ -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"]
Signature · 1 line
2.52.0
#1 lore raw
Quoted 11 lines · Thomas Huth

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.

Review

Quoted 7 lines
(quoted diff) +3 -1
-    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"]

What about just

tests/tracetool/tracetool-test.py +1 -1
index 30006a99190..efc518a6b1e 100755
@@ -36,7 +36,7 @@ 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"]
+    args = [sys.executable, tracetool, f"--format={fmt}", f"--backends={backend}", "--group=testsuite"]
 
     if fmt.find("stap") != -1:
         args += ["--binary=qemu", "--probe-prefix=qemu"]

(only the second half of the commit message needs changing).

Even if you keep using PYTHON, which makes sense, I would change the default to sys.executable.

Paolo

#2 lore raw
Quoted 36 lines · Paolo Bonzini
Quoted 11 lines · Thomas Huth

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.

Quoted 7 lines

-    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"]

What about just

tests/tracetool/tracetool-test.py +0 -0
index 30006a99190..efc518a6b1e 100755
@@ -36,7 +36,7 @@ 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"]
+    args = [sys.executable, tracetool, f"--format={fmt}", f"-- backends={backend}", "--group=testsuite"]

Quoted 7 lines

     if fmt.find("stap") != -1:
         args += ["--binary=qemu", "--probe-prefix=qemu"]

(only the second half of the commit message needs changing).

Even if you keep using PYTHON, which makes sense, I would change the default to sys.executable.

Fine for me, too! ... Stefan, do you have any preferences?

Thomas

#3 lore raw
Quoted 42 lines · Thomas Huth
Quoted 40 lines · Paolo Bonzini
Quoted 13 lines · Thomas Huth

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.

- args = [tracetool, f"--format={fmt}", f"--backends={backend}", "--
group=testsuite"]

Review

Quoted 5 lines
(quoted diff) +3 -0
+    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"]

What about just

tests/tracetool/tracetool- renamed from tests/tracetool/tracetool-test.py +0 -0

test.py
index 30006a99190..efc518a6b1e 100755

tests/tracetool/tracetool-test.py +0 -0
@@ -36,7 +36,7 @@ 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"]
+ args = [sys.executable, tracetool, f"--format={fmt}", f"--
backends={backend}", "--group=testsuite"]

      if fmt.find("stap") != -1:
          args += ["--binary=qemu", "--probe-prefix=qemu"]
Quoted 6 lines
Quoted 4 lines

(only the second half of the commit message needs changing).

Even if you keep using PYTHON, which makes sense, I would change the default to sys.executable.

Fine for me, too! ... Stefan, do you have any preferences?

I like the minimal patch with just sys.executable and no PYTHON environment variable.

Thanks,
Stefan