|
1 | 1 | #!/usr/bin/env python
|
2 |
| -import re |
3 |
| -from test_panic_util.test_panic_util import panic_test, get_dut, run_all |
| 2 | +import panic_tests as test |
| 3 | +from test_panic_util.test_panic_util import panic_test, run_all |
4 | 4 |
|
5 | 5 |
|
| 6 | +# test_task_wdt |
| 7 | + |
6 | 8 | @panic_test()
|
7 | 9 | def test_panic_task_wdt(env, extra_data):
|
8 |
| - with get_dut(env, "panic", "test_task_wdt", qemu_wdt_enable=True) as dut: |
9 |
| - dut.expect("Task watchdog got triggered. The following tasks did not reset the watchdog in time:") |
10 |
| - dut.expect("CPU 0: main") |
11 |
| - dut.expect(re.compile(r"abort\(\) was called at PC [0-9xa-f]+ on core 0")) |
12 |
| - dut.expect_none("register dump:") |
13 |
| - dut.expect("Backtrace:") |
14 |
| - dut.expect_elf_sha256() |
15 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
16 |
| - dut.expect("Rebooting...") |
| 10 | + test.task_wdt_inner(env, "panic") |
| 11 | + |
| 12 | + |
| 13 | +@panic_test() |
| 14 | +def test_coredump_task_wdt_uart_elf_crc(env, extra_data): |
| 15 | + test.task_wdt_inner(env, "coredump_uart_elf_crc") |
| 16 | + |
| 17 | + |
| 18 | +@panic_test() |
| 19 | +def test_coredump_task_wdt_uart_bin_crc(env, extra_data): |
| 20 | + test.task_wdt_inner(env, "coredump_uart_bin_crc") |
| 21 | + |
17 | 22 |
|
| 23 | +@panic_test() |
| 24 | +def test_coredump_task_wdt_flash_elf_sha(env, extra_data): |
| 25 | + test.task_wdt_inner(env, "coredump_flash_elf_sha") |
| 26 | + |
| 27 | + |
| 28 | +@panic_test() |
| 29 | +def test_coredump_task_wdt_flash_bin_crc(env, extra_data): |
| 30 | + test.task_wdt_inner(env, "coredump_flash_bin_crc") |
| 31 | + |
| 32 | + |
| 33 | +# test_int_wdt |
18 | 34 |
|
19 | 35 | @panic_test()
|
20 | 36 | def test_panic_int_wdt(env, extra_data):
|
21 |
| - with get_dut(env, "panic", "test_int_wdt", qemu_wdt_enable=True) as dut: |
22 |
| - dut.expect_gme("Interrupt wdt timeout on CPU0") |
23 |
| - dut.expect_reg_dump(0) |
24 |
| - dut.expect("Backtrace:") |
25 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
26 |
| - dut.expect_reg_dump(1) |
27 |
| - dut.expect("Backtrace:") |
28 |
| - dut.expect_elf_sha256() |
29 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
30 |
| - dut.expect("Rebooting...") |
| 37 | + test.int_wdt_inner(env, "panic") |
31 | 38 |
|
32 | 39 |
|
33 | 40 | @panic_test()
|
34 |
| -def test_cache_error(env, extra_data): |
35 |
| - with get_dut(env, "panic", "test_cache_error") as dut: |
36 |
| - dut.expect("Re-enable cpu cache.") |
37 |
| - dut.expect_gme("Cache disabled but cached memory region accessed") |
38 |
| - dut.expect_reg_dump(0) |
39 |
| - dut.expect("Backtrace:") |
40 |
| - dut.expect_elf_sha256() |
41 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
42 |
| - dut.expect("Rebooting...") |
| 41 | +def test_coredump_int_wdt_uart_elf_crc(env, extra_data): |
| 42 | + test.int_wdt_inner(env, "coredump_uart_elf_crc") |
43 | 43 |
|
44 | 44 |
|
| 45 | +@panic_test() |
| 46 | +def test_coredump_int_wdt_uart_bin_crc(env, extra_data): |
| 47 | + test.int_wdt_inner(env, "coredump_uart_bin_crc") |
| 48 | + |
| 49 | + |
| 50 | +@panic_test() |
| 51 | +def test_coredump_int_wdt_flash_elf_sha(env, extra_data): |
| 52 | + test.int_wdt_inner(env, "coredump_flash_elf_sha") |
| 53 | + |
| 54 | + |
| 55 | +@panic_test() |
| 56 | +def test_coredump_int_wdt_flash_bin_crc(env, extra_data): |
| 57 | + test.int_wdt_inner(env, "coredump_flash_bin_crc") |
| 58 | + |
| 59 | + |
| 60 | +# test_int_wdt_cache_disabled |
| 61 | + |
45 | 62 | @panic_test()
|
46 | 63 | def test_panic_int_wdt_cache_disabled(env, extra_data):
|
47 |
| - with get_dut(env, "panic", "test_int_wdt_cache_disabled", qemu_wdt_enable=True) as dut: |
48 |
| - dut.expect("Re-enable cpu cache.") |
49 |
| - dut.expect_gme("Interrupt wdt timeout on CPU0") |
50 |
| - dut.expect_reg_dump(0) |
51 |
| - dut.expect("Backtrace:") |
52 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
53 |
| - dut.expect_reg_dump(1) |
54 |
| - dut.expect("Backtrace:") |
55 |
| - dut.expect_elf_sha256() |
56 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
57 |
| - dut.expect("Rebooting...") |
| 64 | + test.int_wdt_cache_disabled_inner(env, "panic") |
58 | 65 |
|
59 | 66 |
|
60 | 67 | @panic_test()
|
61 |
| -def test_panic_abort(env, extra_data): |
62 |
| - with get_dut(env, "panic", "test_abort") as dut: |
63 |
| - dut.expect(re.compile(r"abort\(\) was called at PC [0-9xa-f]+ on core 0")) |
64 |
| - dut.expect_none("register dump:") |
65 |
| - dut.expect("Backtrace:") |
66 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
67 |
| - dut.expect("Rebooting...") |
| 68 | +def test_coredump_int_wdt_cache_disabled_uart_elf_crc(env, extra_data): |
| 69 | + test.int_wdt_cache_disabled_inner(env, "coredump_uart_elf_crc") |
68 | 70 |
|
69 | 71 |
|
70 | 72 | @panic_test()
|
71 |
| -def test_panic_storeprohibited(env, extra_data): |
72 |
| - with get_dut(env, "panic", "test_storeprohibited") as dut: |
73 |
| - dut.expect_gme("StoreProhibited") |
74 |
| - dut.expect_reg_dump(0) |
75 |
| - dut.expect("Backtrace:") |
76 |
| - dut.expect_elf_sha256() |
77 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
78 |
| - dut.expect("Rebooting...") |
| 73 | +def test_coredump_int_wdt_cache_disabled_uart_bin_crc(env, extra_data): |
| 74 | + test.int_wdt_cache_disabled_inner(env, "coredump_uart_bin_crc") |
| 75 | + |
| 76 | + |
| 77 | +@panic_test() |
| 78 | +def test_coredump_int_wdt_cache_disabled_flash_elf_sha(env, extra_data): |
| 79 | + test.int_wdt_cache_disabled_inner(env, "coredump_flash_elf_sha") |
| 80 | + |
| 81 | + |
| 82 | +@panic_test() |
| 83 | +def test_coredump_int_wdt_cache_disabled_flash_bin_crc(env, extra_data): |
| 84 | + test.int_wdt_cache_disabled_inner(env, "coredump_flash_bin_crc") |
| 85 | + |
| 86 | + |
| 87 | +# test_cache_error |
| 88 | + |
| 89 | +@panic_test() |
| 90 | +def test_panic_cache_error(env, extra_data): |
| 91 | + test.cache_error_inner(env, "panic") |
| 92 | + |
| 93 | + |
| 94 | +@panic_test() |
| 95 | +def test_coredump_cache_error_uart_elf_crc(env, extra_data): |
| 96 | + test.cache_error_inner(env, "coredump_uart_elf_crc") |
79 | 97 |
|
80 | 98 |
|
| 99 | +@panic_test() |
| 100 | +def test_coredump_cache_error_uart_bin_crc(env, extra_data): |
| 101 | + test.cache_error_inner(env, "coredump_uart_bin_crc") |
| 102 | + |
| 103 | + |
| 104 | +@panic_test() |
| 105 | +def test_coredump_cache_error_flash_elf_sha(env, extra_data): |
| 106 | + test.cache_error_inner(env, "coredump_flash_elf_sha") |
| 107 | + |
| 108 | + |
| 109 | +@panic_test() |
| 110 | +def test_coredump_cache_error_flash_bin_crc(env, extra_data): |
| 111 | + test.cache_error_inner(env, "coredump_flash_bin_crc") |
| 112 | + |
| 113 | + |
| 114 | +# test_stack_overflow |
| 115 | + |
81 | 116 | @panic_test()
|
82 | 117 | def test_panic_stack_overflow(env, extra_data):
|
83 |
| - with get_dut(env, "panic", "test_stack_overflow") as dut: |
84 |
| - dut.expect_gme("Unhandled debug exception") |
85 |
| - dut.expect("Stack canary watchpoint triggered (main)") |
86 |
| - dut.expect_reg_dump(0) |
87 |
| - dut.expect("Backtrace:") |
88 |
| - dut.expect_elf_sha256() |
89 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
90 |
| - dut.expect("Rebooting...") |
| 118 | + test.stack_overflow_inner(env, "panic") |
91 | 119 |
|
92 | 120 |
|
93 | 121 | @panic_test()
|
94 |
| -def test_panic_illegal_instruction(env, extra_data): |
95 |
| - with get_dut(env, "panic", "test_illegal_instruction") as dut: |
96 |
| - dut.expect_gme("IllegalInstruction") |
97 |
| - dut.expect_reg_dump(0) |
98 |
| - dut.expect("Backtrace:") |
99 |
| - dut.expect_elf_sha256() |
100 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
101 |
| - dut.expect("Rebooting...") |
| 122 | +def test_coredump_stack_overflow_uart_elf_crc(env, extra_data): |
| 123 | + test.stack_overflow_inner(env, "coredump_uart_elf_crc") |
| 124 | + |
| 125 | + |
| 126 | +@panic_test() |
| 127 | +def test_coredump_stack_overflow_uart_bin_crc(env, extra_data): |
| 128 | + test.stack_overflow_inner(env, "coredump_uart_bin_crc") |
102 | 129 |
|
103 | 130 |
|
| 131 | +@panic_test() |
| 132 | +def test_coredump_stack_overflow_flash_elf_sha(env, extra_data): |
| 133 | + test.stack_overflow_inner(env, "coredump_flash_elf_sha") |
| 134 | + |
| 135 | + |
| 136 | +@panic_test() |
| 137 | +def test_coredump_stack_overflow_flash_bin_crc(env, extra_data): |
| 138 | + test.stack_overflow_inner(env, "coredump_flash_bin_crc") |
| 139 | + |
| 140 | + |
| 141 | +# test_instr_fetch_prohibited |
| 142 | + |
104 | 143 | @panic_test()
|
105 | 144 | def test_panic_instr_fetch_prohibited(env, extra_data):
|
106 |
| - with get_dut(env, "panic", "test_instr_fetch_prohibited") as dut: |
107 |
| - dut.expect_gme("InstrFetchProhibited") |
108 |
| - dut.expect_reg_dump(0) |
109 |
| - dut.expect("Backtrace:") |
110 |
| - # At the moment the backtrace is corrupted, need to jump over the first PC in case of InstrFetchProhibited. |
111 |
| - # Fix this and change expect to expect_none. |
112 |
| - dut.expect("CORRUPTED") |
113 |
| - dut.expect_elf_sha256() |
114 |
| - dut.expect_none("Guru Meditation") |
115 |
| - dut.expect("Rebooting...") |
116 |
| - |
117 |
| - |
118 |
| -@panic_test() |
119 |
| -def test_coredump_uart_abort(env, extra_data): |
120 |
| - with get_dut(env, "coredump_uart", "test_abort") as dut: |
121 |
| - dut.expect(re.compile(r"abort\(\) was called at PC [0-9xa-f]+ on core 0")) |
122 |
| - dut.expect("Backtrace:") |
123 |
| - dut.expect_elf_sha256() |
124 |
| - dut.expect_none("CORRUPTED", "Guru Meditation", "Re-entered core dump") |
125 |
| - dut.expect(dut.COREDUMP_UART_END) |
126 |
| - dut.expect("Rebooting...") |
127 |
| - dut.process_coredump_uart() |
128 |
| - # TODO: check the contents of core dump output |
129 |
| - |
130 |
| - |
131 |
| -@panic_test() |
132 |
| -def test_coredump_uart_int_wdt(env, extra_data): |
133 |
| - with get_dut(env, "coredump_uart", "test_int_wdt") as dut: |
134 |
| - dut.expect_gme("Interrupt wdt timeout on CPU0") |
135 |
| - dut.expect_reg_dump(0) |
136 |
| - dut.expect("Backtrace:") |
137 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
138 |
| - dut.expect_reg_dump(1) |
139 |
| - dut.expect("Backtrace:") |
140 |
| - dut.expect_elf_sha256() |
141 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
142 |
| - dut.expect("Rebooting...") |
143 |
| - dut.process_coredump_uart() |
144 |
| - # TODO: check the contents of core dump output |
145 |
| - |
146 |
| - |
147 |
| -@panic_test() |
148 |
| -def test_coredump_flash_abort(env, extra_data): |
149 |
| - with get_dut(env, "coredump_flash", "test_abort") as dut: |
150 |
| - dut.expect(re.compile(r"abort\(\) was called at PC [0-9xa-f]+ on core 0")) |
151 |
| - dut.expect("Backtrace:") |
152 |
| - dut.expect_elf_sha256() |
153 |
| - dut.expect_none("CORRUPTED", "Guru Meditation", "Re-entered core dump") |
154 |
| - dut.expect("Rebooting...") |
155 |
| - dut.process_coredump_flash() |
156 |
| - # TODO: check the contents of core dump output |
157 |
| - |
158 |
| - |
159 |
| -@panic_test() |
160 |
| -def test_coredump_flash_int_wdt(env, extra_data): |
161 |
| - with get_dut(env, "coredump_flash", "test_int_wdt") as dut: |
162 |
| - dut.expect_gme("Interrupt wdt timeout on CPU0") |
163 |
| - dut.expect_reg_dump(0) |
164 |
| - dut.expect("Backtrace:") |
165 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
166 |
| - dut.expect_reg_dump(1) |
167 |
| - dut.expect("Backtrace:") |
168 |
| - dut.expect_elf_sha256() |
169 |
| - dut.expect_none("CORRUPTED", "Guru Meditation") |
170 |
| - dut.expect("Rebooting...") |
171 |
| - dut.process_coredump_flash() |
172 |
| - # TODO: check the contents of core dump output |
| 145 | + test.instr_fetch_prohibited_inner(env, "panic") |
| 146 | + |
| 147 | + |
| 148 | +@panic_test() |
| 149 | +def test_coredump_instr_fetch_prohibited_uart_elf_crc(env, extra_data): |
| 150 | + test.instr_fetch_prohibited_inner(env, "coredump_uart_elf_crc") |
| 151 | + |
| 152 | + |
| 153 | +@panic_test() |
| 154 | +def test_coredump_instr_fetch_prohibited_uart_bin_crc(env, extra_data): |
| 155 | + test.instr_fetch_prohibited_inner(env, "coredump_uart_bin_crc") |
| 156 | + |
| 157 | + |
| 158 | +@panic_test() |
| 159 | +def test_coredump_instr_fetch_prohibited_flash_elf_sha(env, extra_data): |
| 160 | + test.instr_fetch_prohibited_inner(env, "coredump_flash_elf_sha") |
| 161 | + |
| 162 | + |
| 163 | +@panic_test() |
| 164 | +def test_coredump_instr_fetch_prohibited_flash_bin_crc(env, extra_data): |
| 165 | + test.instr_fetch_prohibited_inner(env, "coredump_flash_bin_crc") |
| 166 | + |
| 167 | + |
| 168 | +# test_illegal_instruction |
| 169 | + |
| 170 | +@panic_test() |
| 171 | +def test_panic_illegal_instruction(env, extra_data): |
| 172 | + test.illegal_instruction_inner(env, "panic") |
| 173 | + |
| 174 | + |
| 175 | +@panic_test() |
| 176 | +def test_coredump_illegal_instruction_uart_elf_crc(env, extra_data): |
| 177 | + test.illegal_instruction_inner(env, "coredump_uart_elf_crc") |
| 178 | + |
| 179 | + |
| 180 | +@panic_test() |
| 181 | +def test_coredump_illegal_instruction_uart_bin_crc(env, extra_data): |
| 182 | + test.illegal_instruction_inner(env, "coredump_uart_bin_crc") |
| 183 | + |
| 184 | + |
| 185 | +@panic_test() |
| 186 | +def test_coredump_illegal_instruction_flash_elf_sha(env, extra_data): |
| 187 | + test.illegal_instruction_inner(env, "coredump_flash_elf_sha") |
| 188 | + |
| 189 | + |
| 190 | +@panic_test() |
| 191 | +def test_coredump_illegal_instruction_flash_bin_crc(env, extra_data): |
| 192 | + test.illegal_instruction_inner(env, "coredump_flash_bin_crc") |
| 193 | + |
| 194 | + |
| 195 | +# test_storeprohibited |
| 196 | + |
| 197 | +@panic_test() |
| 198 | +def test_panic_storeprohibited(env, extra_data): |
| 199 | + test.storeprohibited_inner(env, "panic") |
| 200 | + |
| 201 | + |
| 202 | +@panic_test() |
| 203 | +def test_coredump_storeprohibited_uart_elf_crc(env, extra_data): |
| 204 | + test.storeprohibited_inner(env, "coredump_uart_elf_crc") |
| 205 | + |
| 206 | + |
| 207 | +@panic_test() |
| 208 | +def test_coredump_storeprohibited_uart_bin_crc(env, extra_data): |
| 209 | + test.storeprohibited_inner(env, "coredump_uart_bin_crc") |
| 210 | + |
| 211 | + |
| 212 | +@panic_test() |
| 213 | +def test_coredump_storeprohibited_flash_elf_sha(env, extra_data): |
| 214 | + test.storeprohibited_inner(env, "coredump_flash_elf_sha") |
| 215 | + |
| 216 | + |
| 217 | +@panic_test() |
| 218 | +def test_coredump_storeprohibited_flash_bin_crc(env, extra_data): |
| 219 | + test.storeprohibited_inner(env, "coredump_flash_bin_crc") |
| 220 | + |
| 221 | + |
| 222 | +# test_abort |
| 223 | + |
| 224 | +@panic_test() |
| 225 | +def test_panic_abort(env, extra_data): |
| 226 | + test.abort_inner(env, "panic") |
| 227 | + |
| 228 | + |
| 229 | +@panic_test() |
| 230 | +def test_coredump_abort_uart_elf_crc(env, extra_data): |
| 231 | + test.abort_inner(env, "coredump_uart_elf_crc") |
| 232 | + |
| 233 | + |
| 234 | +@panic_test() |
| 235 | +def test_coredump_abort_uart_bin_crc(env, extra_data): |
| 236 | + test.abort_inner(env, "coredump_uart_bin_crc") |
| 237 | + |
| 238 | + |
| 239 | +@panic_test() |
| 240 | +def test_coredump_abort_flash_elf_sha(env, extra_data): |
| 241 | + test.abort_inner(env, "coredump_flash_elf_sha") |
| 242 | + |
| 243 | + |
| 244 | +@panic_test() |
| 245 | +def test_coredump_abort_flash_bin_crc(env, extra_data): |
| 246 | + test.abort_inner(env, "coredump_flash_bin_crc") |
173 | 247 |
|
174 | 248 |
|
175 | 249 | if __name__ == '__main__':
|
|
0 commit comments