run_cross_test.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python3
  2. # Copyright 2013-2016 The Meson development team
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. '''Runs the basic test suite through a cross compiler.
  13. This is now just a wrapper around run_project_tests.py with specific arguments
  14. '''
  15. import argparse
  16. import subprocess
  17. from mesonbuild import mesonlib
  18. from mesonbuild.coredata import version as meson_version
  19. from pathlib import Path
  20. import json
  21. import os
  22. def runtests(cross_file, failfast, cross_only, test_list, env=None):
  23. tests = ['--only'] + test_list
  24. if not cross_only:
  25. tests.append('native')
  26. cmd = mesonlib.python_command + ['run_project_tests.py', '--backend', 'ninja']
  27. if failfast:
  28. cmd += ['--failfast']
  29. cmd += tests
  30. cmd += ['--cross-file', cross_file]
  31. if cross_only:
  32. cmd += ['--native-file', 'cross/none.txt']
  33. return subprocess.call(cmd, env=env)
  34. def main():
  35. parser = argparse.ArgumentParser()
  36. parser.add_argument('--failfast', action='store_true')
  37. parser.add_argument('--cross-only', action='store_true')
  38. parser.add_argument('cross_file')
  39. options = parser.parse_args()
  40. cf_path = Path(options.cross_file)
  41. try:
  42. data = json.loads(cf_path.read_text(encoding='utf-8'))
  43. real_cf = cf_path.resolve().parent / data['file']
  44. assert real_cf.exists()
  45. env = os.environ.copy()
  46. env.update(data['env'])
  47. return runtests(real_cf.as_posix(), options.failfast, options.cross_only, data['tests'], env=env)
  48. except Exception:
  49. return runtests(options.cross_file, options.failfast, options.cross_only, ['common'])
  50. if __name__ == '__main__':
  51. print('Meson build system', meson_version, 'Cross Tests')
  52. raise SystemExit(main())