| 1 |
#!/usr/bin/env python3 |
| 2 |
# SPDX-License-Identifier: Apache-2.0 |
| 3 |
# Copyright 2013-2016 The Meson development team |
| 4 |
|
| 5 |
'''Runs the basic test suite through a cross compiler. |
| 6 |
|
| 7 |
This is now just a wrapper around run_project_tests.py with specific arguments |
| 8 |
''' |
| 9 |
|
| 10 |
import argparse |
| 11 |
import subprocess |
| 12 |
from mesonbuild import mesonlib |
| 13 |
from mesonbuild.coredata import version as meson_version |
| 14 |
from pathlib import Path |
| 15 |
import json |
| 16 |
import os |
| 17 |
|
| 18 |
|
| 19 |
def runtests(cross_file, failfast, cross_only, test_list, env=None): |
| 20 |
tests = ['--only'] + test_list |
| 21 |
if not cross_only: |
| 22 |
tests.append('native') |
| 23 |
cmd = mesonlib.python_command + ['run_project_tests.py', '--backend', 'ninja'] |
| 24 |
if failfast: |
| 25 |
cmd += ['--failfast'] |
| 26 |
cmd += tests |
| 27 |
cmd += ['--cross-file', cross_file] |
| 28 |
if cross_only: |
| 29 |
cmd += ['--native-file', 'cross/none.txt'] |
| 30 |
return subprocess.call(cmd, env=env) |
| 31 |
|
| 32 |
def main(): |
| 33 |
parser = argparse.ArgumentParser() |
| 34 |
parser.add_argument('--failfast', action='store_true') |
| 35 |
parser.add_argument('--cross-only', action='store_true') |
| 36 |
parser.add_argument('cross_file') |
| 37 |
options = parser.parse_args() |
| 38 |
cf_path = Path(options.cross_file) |
| 39 |
try: |
| 40 |
data = json.loads(cf_path.read_text(encoding='utf-8')) |
| 41 |
real_cf = cf_path.resolve().parent / data['file'] |
| 42 |
assert real_cf.exists() |
| 43 |
env = os.environ.copy() |
| 44 |
env.update(data['env']) |
| 45 |
return runtests(real_cf.as_posix(), options.failfast, options.cross_only, data['tests'], env=env) |
| 46 |
except Exception: |
| 47 |
return runtests(options.cross_file, options.failfast, options.cross_only, ['common']) |
| 48 |
|
| 49 |
if __name__ == '__main__': |
| 50 |
print('Meson build system', meson_version, 'Cross Tests') |
| 51 |
raise SystemExit(main()) |