app_test.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #!/usr/bin/env python
  2. import re
  3. from test_panic_util.test_panic_util import panic_test, get_dut, run_all
  4. @panic_test()
  5. def test_panic_task_wdt(env, extra_data):
  6. with get_dut(env, "panic", "test_task_wdt", qemu_wdt_enable=True) as dut:
  7. dut.expect("Task watchdog got triggered. The following tasks did not reset the watchdog in time:")
  8. dut.expect("CPU 0: main")
  9. dut.expect(re.compile(r"abort\(\) was called at PC [0-9xa-f]+ on core 0"))
  10. dut.expect_none("register dump:")
  11. dut.expect("Backtrace:")
  12. dut.expect_elf_sha256()
  13. dut.expect_none("CORRUPTED", "Guru Meditation")
  14. dut.expect("Rebooting...")
  15. @panic_test()
  16. def test_panic_int_wdt(env, extra_data):
  17. with get_dut(env, "panic", "test_int_wdt", qemu_wdt_enable=True) as dut:
  18. dut.expect_gme("Interrupt wdt timeout on CPU0")
  19. dut.expect_reg_dump(0)
  20. dut.expect("Backtrace:")
  21. dut.expect_none("CORRUPTED", "Guru Meditation")
  22. dut.expect_reg_dump(1)
  23. dut.expect("Backtrace:")
  24. dut.expect_elf_sha256()
  25. dut.expect_none("CORRUPTED", "Guru Meditation")
  26. dut.expect("Rebooting...")
  27. @panic_test()
  28. def test_cache_error(env, extra_data):
  29. with get_dut(env, "panic", "test_cache_error") as dut:
  30. dut.expect("Re-enable cpu cache.")
  31. dut.expect_gme("Cache disabled but cached memory region accessed")
  32. dut.expect_reg_dump(0)
  33. dut.expect("Backtrace:")
  34. dut.expect_elf_sha256()
  35. dut.expect_none("CORRUPTED", "Guru Meditation")
  36. dut.expect("Rebooting...")
  37. @panic_test()
  38. def test_panic_int_wdt_cache_disabled(env, extra_data):
  39. with get_dut(env, "panic", "test_int_wdt_cache_disabled", qemu_wdt_enable=True) as dut:
  40. dut.expect("Re-enable cpu cache.")
  41. dut.expect_gme("Interrupt wdt timeout on CPU0")
  42. dut.expect_reg_dump(0)
  43. dut.expect("Backtrace:")
  44. dut.expect_none("CORRUPTED", "Guru Meditation")
  45. dut.expect_reg_dump(1)
  46. dut.expect("Backtrace:")
  47. dut.expect_elf_sha256()
  48. dut.expect_none("CORRUPTED", "Guru Meditation")
  49. dut.expect("Rebooting...")
  50. @panic_test()
  51. def test_panic_abort(env, extra_data):
  52. with get_dut(env, "panic", "test_abort") as dut:
  53. dut.expect(re.compile(r"abort\(\) was called at PC [0-9xa-f]+ on core 0"))
  54. dut.expect_none("register dump:")
  55. dut.expect("Backtrace:")
  56. dut.expect_none("CORRUPTED", "Guru Meditation")
  57. dut.expect("Rebooting...")
  58. @panic_test()
  59. def test_panic_storeprohibited(env, extra_data):
  60. with get_dut(env, "panic", "test_storeprohibited") as dut:
  61. dut.expect_gme("StoreProhibited")
  62. dut.expect_reg_dump(0)
  63. dut.expect("Backtrace:")
  64. dut.expect_elf_sha256()
  65. dut.expect_none("CORRUPTED", "Guru Meditation")
  66. dut.expect("Rebooting...")
  67. @panic_test()
  68. def test_panic_stack_overflow(env, extra_data):
  69. with get_dut(env, "panic", "test_stack_overflow") as dut:
  70. dut.expect_gme("Unhandled debug exception")
  71. dut.expect("Stack canary watchpoint triggered (main)")
  72. dut.expect_reg_dump(0)
  73. dut.expect("Backtrace:")
  74. dut.expect_elf_sha256()
  75. dut.expect_none("CORRUPTED", "Guru Meditation")
  76. dut.expect("Rebooting...")
  77. @panic_test()
  78. def test_panic_illegal_instruction(env, extra_data):
  79. with get_dut(env, "panic", "test_illegal_instruction") as dut:
  80. dut.expect_gme("IllegalInstruction")
  81. dut.expect_reg_dump(0)
  82. dut.expect("Backtrace:")
  83. dut.expect_elf_sha256()
  84. dut.expect_none("CORRUPTED", "Guru Meditation")
  85. dut.expect("Rebooting...")
  86. @panic_test()
  87. def test_panic_instr_fetch_prohibited(env, extra_data):
  88. with get_dut(env, "panic", "test_instr_fetch_prohibited") as dut:
  89. dut.expect_gme("InstrFetchProhibited")
  90. dut.expect_reg_dump(0)
  91. dut.expect("Backtrace:")
  92. # At the moment the backtrace is corrupted, need to jump over the first PC in case of InstrFetchProhibited.
  93. # Fix this and change expect to expect_none.
  94. dut.expect("CORRUPTED")
  95. dut.expect_elf_sha256()
  96. dut.expect_none("Guru Meditation")
  97. dut.expect("Rebooting...")
  98. @panic_test()
  99. def test_coredump_uart_abort(env, extra_data):
  100. with get_dut(env, "coredump_uart", "test_abort") as dut:
  101. dut.expect(re.compile(r"abort\(\) was called at PC [0-9xa-f]+ on core 0"))
  102. dut.expect("Backtrace:")
  103. dut.expect_elf_sha256()
  104. dut.expect_none("CORRUPTED", "Guru Meditation", "Re-entered core dump")
  105. dut.expect(dut.COREDUMP_UART_END)
  106. dut.expect("Rebooting...")
  107. dut.process_coredump_uart()
  108. # TODO: check the contents of core dump output
  109. @panic_test()
  110. def test_coredump_flash_abort(env, extra_data):
  111. with get_dut(env, "coredump_flash", "test_abort") as dut:
  112. dut.expect(re.compile(r"abort\(\) was called at PC [0-9xa-f]+ on core 0"))
  113. dut.expect("Backtrace:")
  114. dut.expect_elf_sha256()
  115. dut.expect_none("CORRUPTED", "Guru Meditation", "Re-entered core dump")
  116. dut.expect("Rebooting...")
  117. dut.process_coredump_flash()
  118. # TODO: check the contents of core dump output
  119. if __name__ == '__main__':
  120. run_all(__file__)