Support native tests in crossbuild

pull/7902/head
Oleg B 4 years ago committed by GitHub
parent 7437d9862a
commit b8052f9e50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mesonbuild/mtest.py
  2. 13
      run_unittests.py
  3. 17
      test cases/unit/88 run native test/main.c
  4. 6
      test cases/unit/88 run native test/meson.build

@ -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.

@ -7508,6 +7508,19 @@ class LinuxCrossArmTests(BaseLinuxCrossTests):
'-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():
return shutil.which('x86_64-w64-mingw32-gcc') and not (is_windows() or is_cygwin())

@ -0,0 +1,17 @@
#include <stdio.h>
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;
}

@ -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'])
Loading…
Cancel
Save