gem5-regression 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env python3
  2. from shell_helpers import LF
  3. import os
  4. import pathlib
  5. import subprocess
  6. import common
  7. from shell_helpers import LF
  8. class Main(common.LkmcCliFunction):
  9. def __init__(self):
  10. super().__init__(
  11. description='''\
  12. Run gem5 regression tests.
  13. https://cirosantilli.com/linux-kernel-module-cheat#gem5-regression-tests
  14. '''
  15. )
  16. self.add_argument(
  17. '--cmd',
  18. default='run',
  19. help='''
  20. List tests instead of running them.
  21. ''',
  22. )
  23. self.add_argument(
  24. 'extra_args',
  25. metavar='extra-args',
  26. nargs='*',
  27. )
  28. def timed_main(self):
  29. if self.env['cmd'] == 'run':
  30. extra_args = [
  31. '--base-dir', self.env['gem5_source_dir'], LF,
  32. '--bin-path', self.env['gem5_test_binaries_dir'], LF,
  33. '--build-dir', self.env['gem5_build_build_dir'], LF,
  34. '-j', str(self.env['nproc']), LF,
  35. '-t', str(self.env['nproc']), LF,
  36. ]
  37. else:
  38. extra_args = []
  39. return self.sh.run_cmd(
  40. [
  41. os.path.join(self.env['gem5_source_dir'], 'tests', 'main.py'), LF,
  42. self.env['cmd'], LF,
  43. '--isa', self.env['gem5_arch'], LF,
  44. '--variant', self.env['gem5_build_type'], LF,
  45. ] +
  46. extra_args +
  47. self.sh.add_newlines(self.env['extra_args']),
  48. cwd=os.path.join(self.env['gem5_source_dir'], 'tests'),
  49. raise_on_failure=False,
  50. )
  51. if __name__ == '__main__':
  52. Main().cli()