diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 04c1a57c7..a92b5cc14 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -650,7 +650,7 @@ class SingleTestRunner: return ['java', '-jar'] + self.test.fname elif not self.test.is_cross_built and run_with_mono(self.test.fname[0]): return ['mono'] + self.test.fname - elif self.test.cmd_is_built and self.test.needs_exe_wrapper: + elif self.test.cmd_is_built and self.test.is_cross_built and self.test.needs_exe_wrapper: if self.test.exe_runner is None: # Can not run test on cross compiled executable # because there is no execute wrapper. diff --git a/run_unittests.py b/run_unittests.py index 84719d676..b9db708a5 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -7507,6 +7507,19 @@ class LinuxCrossArmTests(BaseLinuxCrossTests): '-Dbuild.pkg_config_path=' + os.path.join(testdir, 'build_extra_path'), '-Dpkg_config_path=' + os.path.join(testdir, 'host_extra_path'), ]) + + def test_run_native_test(self): + ''' + https://github.com/mesonbuild/meson/issues/7997 + check run native test in crossbuild without exe wrapper + ''' + testdir = os.path.join(self.unit_test_dir, '88 run native test') + stamp_file = os.path.join(self.builddir, 'native_test_has_run.stamp') + self.init(testdir) + self.build() + self.assertPathDoesNotExist(stamp_file) + self.run_tests() + self.assertPathExists(stamp_file) def should_run_cross_mingw_tests(): diff --git a/test cases/unit/88 run native test/main.c b/test cases/unit/88 run native test/main.c new file mode 100644 index 000000000..3213780df --- /dev/null +++ b/test cases/unit/88 run native test/main.c @@ -0,0 +1,17 @@ +#include + +int main (int argc, char * argv[]) +{ + const char *out = "SUCCESS!"; + + if (argc != 2) { + printf ("%s\n", out); + } else { + int ret; + FILE *f = fopen (argv[1], "w"); + ret = fwrite (out, sizeof (out), 1, f); + if (ret != 1) + return -1; + } + return 0; +} diff --git a/test cases/unit/88 run native test/meson.build b/test cases/unit/88 run native test/meson.build new file mode 100644 index 000000000..3bf419c14 --- /dev/null +++ b/test cases/unit/88 run native test/meson.build @@ -0,0 +1,6 @@ +project('run native test', ['c']) + +executable('terget_exe', 'main.c') + +native_exe = executable('native_exe', 'main.c', native: true) +test('native_exe', native_exe, args: ['native_test_has_run.stamp'])