aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-10-01 11:19:08 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-05-18 13:53:58 -0700
commit0ec94ca0629415d4b555e8ef38a5093a65e0539e (patch)
treed8bb83c50d30eaa5f70931018f7458210a1c4489 /mesonbuild
parentcb6662b57299c3644719593115b2ffb828679c36 (diff)
downloadmeson-0ec94ca0629415d4b555e8ef38a5093a65e0539e.zip
meson-0ec94ca0629415d4b555e8ef38a5093a65e0539e.tar.gz
meson-0ec94ca0629415d4b555e8ef38a5093a65e0539e.tar.bz2
backends: Consider arguments passed to a test when cross compiling
Otherwise a wrapper script which takes an executable as an argument will mistakenly run when that executable is cross compiled. This does not wrap said executable in an exe_wrapper, just skip it. Fixes #5982
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/backends.py18
-rw-r--r--mesonbuild/mtest.py7
2 files changed, 20 insertions, 5 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 5ef7f44..ceea94a 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -119,7 +119,8 @@ class TestSerialisation:
needs_exe_wrapper: bool, is_parallel: bool, cmd_args: T.List[str],
env: build.EnvironmentVariables, should_fail: bool,
timeout: T.Optional[int], workdir: T.Optional[str],
- extra_paths: T.List[str], protocol: TestProtocol, priority: int):
+ extra_paths: T.List[str], protocol: TestProtocol, priority: int,
+ cmd_is_built: bool):
self.name = name
self.project_name = project
self.suite = suite
@@ -138,6 +139,8 @@ class TestSerialisation:
self.protocol = protocol
self.priority = priority
self.needs_exe_wrapper = needs_exe_wrapper
+ self.cmd_is_built = cmd_is_built
+
def get_backend_from_name(backend: str, build: T.Optional[build.Build] = None, interpreter: T.Optional['Interpreter'] = None) -> T.Optional['Backend']:
if backend == 'ninja':
@@ -788,6 +791,15 @@ class Backend:
# E.g. an external verifier or simulator program run on a generated executable.
# Can always be run without a wrapper.
test_for_machine = MachineChoice.BUILD
+
+ # we allow passing compiled executables to tests, which may be cross built.
+ # We need to consider these as well when considering whether the target is cross or not.
+ for a in t.cmd_args:
+ if isinstance(a, build.BuildTarget):
+ if a.for_machine is MachineChoice.HOST:
+ test_for_machine = MachineChoice.HOST
+ break
+
is_cross = self.environment.is_cross_build(test_for_machine)
if is_cross and self.environment.need_exe_wrapper():
exe_wrapper = self.environment.get_exe_wrapper()
@@ -801,6 +813,7 @@ class Backend:
extra_paths = self.determine_windows_extra_paths(exe, extra_bdeps)
else:
extra_paths = []
+
cmd_args = []
for a in unholder(t.cmd_args):
if isinstance(a, build.BuildTarget):
@@ -823,7 +836,8 @@ class Backend:
exe_wrapper, self.environment.need_exe_wrapper(),
t.is_parallel, cmd_args, t.env,
t.should_fail, t.timeout, t.workdir,
- extra_paths, t.protocol, t.priority)
+ extra_paths, t.protocol, t.priority,
+ isinstance(exe, build.Executable))
arr.append(ts)
return arr
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index e04d365..8806932 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -615,14 +615,15 @@ class SingleTestRunner:
# Can not run test on cross compiled executable
# because there is no execute wrapper.
return None
- else:
+ elif self.test.cmd_is_built:
+ # If the command is not built (ie, its a python script),
+ # then we don't check for the exe-wrapper
if not self.test.exe_runner.found():
msg = 'The exe_wrapper defined in the cross file {!r} was not ' \
'found. Please check the command and/or add it to PATH.'
raise TestException(msg.format(self.test.exe_runner.name))
return self.test.exe_runner.get_command() + self.test.fname
- else:
- return self.test.fname
+ return self.test.fname
def run(self) -> TestRun:
cmd = self._get_cmd()