aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/libregrtest/utils.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-10-01 00:37:23 +0200
committerGitHub <noreply@github.com>2023-09-30 22:37:23 +0000
commit53eb9a676f8c59b206dfc536b7590f6563ad65e0 (patch)
tree818bf98fb768d9f230b6375b9fff7102ce6849dc /Lib/test/libregrtest/utils.py
parentd3728ddc572fff7ffcc95301bf5265717dbaf476 (diff)
downloadcpython-53eb9a676f8c59b206dfc536b7590f6563ad65e0.tar.gz
cpython-53eb9a676f8c59b206dfc536b7590f6563ad65e0.zip
gh-110152: regrtest handles cross compilation and HOSTRUNNER (#110156)
* _add_python_opts() now handles cross compilation and HOSTRUNNER. * display_header() now tells if Python is cross-compiled, display HOSTRUNNER, and get the host platform. * Remove Tools/scripts/run_tests.py script. * Remove "make hostrunnertest": use "make buildbottest" or "make test" instead.
Diffstat (limited to 'Lib/test/libregrtest/utils.py')
-rw-r--r--Lib/test/libregrtest/utils.py39
1 files changed, 37 insertions, 2 deletions
diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py
index dc1fa51b80d..d2c274d9970 100644
--- a/Lib/test/libregrtest/utils.py
+++ b/Lib/test/libregrtest/utils.py
@@ -5,7 +5,9 @@ import math
import os.path
import platform
import random
+import shlex
import signal
+import subprocess
import sys
import sysconfig
import tempfile
@@ -523,7 +525,18 @@ def adjust_rlimit_nofile():
f"{new_fd_limit}: {err}.")
-def display_header(use_resources: tuple[str, ...]):
+def get_host_runner():
+ if (hostrunner := os.environ.get("_PYTHON_HOSTRUNNER")) is None:
+ hostrunner = sysconfig.get_config_var("HOSTRUNNER")
+ return hostrunner
+
+
+def is_cross_compiled():
+ return ('_PYTHON_HOST_PLATFORM' in os.environ)
+
+
+def display_header(use_resources: tuple[str, ...],
+ python_cmd: tuple[str, ...] | None):
# Print basic platform information
print("==", platform.python_implementation(), *sys.version.split())
print("==", platform.platform(aliased=True),
@@ -537,13 +550,35 @@ def display_header(use_resources: tuple[str, ...]):
print("== encodings: locale=%s, FS=%s"
% (locale.getencoding(), sys.getfilesystemencoding()))
-
if use_resources:
print(f"== resources ({len(use_resources)}): "
f"{', '.join(sorted(use_resources))}")
else:
print("== resources: (all disabled, use -u option)")
+ cross_compile = is_cross_compiled()
+ if cross_compile:
+ print("== cross compiled: Yes")
+ if python_cmd:
+ cmd = shlex.join(python_cmd)
+ print(f"== host python: {cmd}")
+
+ get_cmd = [*python_cmd, '-m', 'platform']
+ proc = subprocess.run(
+ get_cmd,
+ stdout=subprocess.PIPE,
+ text=True,
+ cwd=os_helper.SAVEDCWD)
+ stdout = proc.stdout.replace('\n', ' ').strip()
+ if stdout:
+ print(f"== host platform: {stdout}")
+ elif proc.returncode:
+ print(f"== host platform: <command failed with exit code {proc.returncode}>")
+ else:
+ hostrunner = get_host_runner()
+ if hostrunner:
+ print(f"== host runner: {hostrunner}")
+
# This makes it easier to remember what to set in your local
# environment when trying to reproduce a sanitizer failure.
asan = support.check_sanitizer(address=True)