tests/tracetool: Honor the Python interpreter that "configure" detected
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
@@ -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
@@ -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
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.pyexecutesscripts/tracetool.pydirectly, so that this script is run via its shebang line.
To fix the issue, pass the right Python interpreter totracetool-test.pyvia the PYTHON environment variable and use that to run thetracetool.pyscript.
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
@@ -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
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.pyexecutesscripts/tracetool.pydirectly, so that this script is run via its shebang line.
To fix the issue, pass the right Python interpreter totracetool-test.pyvia the PYTHON environment variable and use that to run thetracetool.pyscript.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"]
iffmt.find("stap")!= -1:
args += ["--binary=qemu", "--probe-prefix=qemu"]What about just
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"]
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
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.pyexecutesscripts/tracetool.pydirectly, so that this script is run via its shebang line.
To fix the issue, pass the right Python interpreter totracetool-test.pyvia the PYTHON environment variable and use that to run thetracetool.pyscript.- 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
index30006a99190..efc518a6b1e100755tests/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