test-boot 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env python3
  2. import common
  3. import shell_helpers
  4. from shell_helpers import LF
  5. class Main(common.TestCliFunction):
  6. def __init__(self):
  7. super().__init__(
  8. description='''\
  9. Test and benchmark the Linux kernel boot. Use inits that exit immediately.
  10. '''
  11. )
  12. self.add_argument(
  13. '--size',
  14. default=1,
  15. type=int,
  16. help='''\
  17. See ./test --help for --size.
  18. '''
  19. )
  20. def _bench(self, **kwargs):
  21. words = []
  22. for line in self.run.get_cli(**kwargs):
  23. words.extend(line)
  24. extra_params = shell_helpers.ShellHelpers().cmd_to_string(words + [LF])
  25. run_args = kwargs.copy()
  26. run_args.update(self.common_args)
  27. self.run_test(self.run, run_args, extra_params)
  28. def timed_main(self):
  29. # TODO bring this benchmark code back to life. Likely should go inside run with an option
  30. #gem5_insts() (
  31. # printf "instructions $(./gem5-stat --arch "$1" sim_insts)\n" >> "$self.env['test_boot_benchmark_file']"
  32. # newline
  33. #)
  34. #
  35. #qemu_insts() (
  36. # common_arch="$1"
  37. # ./qemu-trace2txt --arch "$common_arch"
  38. # common_qemu_trace_txt_file="$("$getvar" --arch "$common_arch" qemu_trace_txt_file)"
  39. # printf "instructions $(wc -l "${common_qemu_trace_txt_file}" | cut -d' ' -f1)\n" >> "$self.env['test_boot_benchmark_file']"
  40. # newline
  41. #)
  42. #
  43. #rm -f "${self.env['test_boot_benchmark_file']}"
  44. self.run = self.import_path_main('run')
  45. self.common_args = self.get_common_args()
  46. self.common_args['ctrl_c_host'] = True
  47. self.common_args['quit_after_boot'] = True
  48. if (self.env['emulator'] == 'qemu' or
  49. (self.env['emulator'] == 'gem5' and self.env['size'] >= 2)):
  50. self._bench()
  51. if self.env['host_arch'] == self.env['arch']:
  52. # TODO: find out why it fails.
  53. if self.env['emulator'] != 'gem5':
  54. self._bench(kvm=True)
  55. if self.env['emulator'] == 'qemu' and self.env['size'] >= 2:
  56. self._bench(trace='exec_tb')
  57. if self.env['emulator'] == 'gem5' and self.env['size'] >= 3:
  58. if self.env['arch'] == 'x86_64':
  59. cpu_types = [
  60. # TODO segfault
  61. #'DerivO3CPU'
  62. ]
  63. elif self.env['is_arm']:
  64. cpu_types = [
  65. 'DerivO3CPU',
  66. 'HPI',
  67. ]
  68. for cpu_type in cpu_types:
  69. self._bench(
  70. extra_emulator_args=[
  71. '--cpu-type', cpu_type,
  72. '--caches',
  73. '--l2cache',
  74. '--l1d_size', '1024kB',
  75. '--l1i_size', '1024kB',
  76. '--l2_size', '1024kB',
  77. '--l3_size', '1024kB',
  78. ],
  79. )
  80. if self.env['arch'] == 'aarch64':
  81. # Do a fuller testing for aarch64.
  82. for build_type in ['debug', 'fast']:
  83. self._bench(gem5_build_type=build_type)
  84. # Requires patching the executable.
  85. # self._bench(gem5_script='biglittle')
  86. if __name__ == '__main__':
  87. Main().cli()