|
1 | 1 | # SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD |
2 | 2 | # SPDX-License-Identifier: CC0-1.0 |
3 | 3 | import re |
| 4 | +from typing import Any |
4 | 5 | from typing import List |
5 | 6 | from typing import Optional |
| 7 | +from typing import Pattern |
| 8 | +from typing import Sequence |
6 | 9 | from typing import Union |
7 | 10 |
|
8 | 11 | import pexpect |
@@ -108,7 +111,7 @@ def get_default_backtrace(config: str) -> List[str]: |
108 | 111 |
|
109 | 112 |
|
110 | 113 | def common_test(dut: PanicTestDut, config: str, expected_backtrace: Optional[List[str]] = None, check_cpu_reset: Optional[bool] = True, |
111 | | - expected_coredump: Optional[List[Union[str, re.Pattern]]] = None) -> None: |
| 114 | + expected_coredump: Optional[Sequence[Union[str, Pattern[Any]]]] = None) -> None: |
112 | 115 | if 'gdbstub' in config: |
113 | 116 | dut.expect_exact('Entering gdb stub now.') |
114 | 117 | dut.start_gdb_for_gdbstub() |
@@ -1042,3 +1045,38 @@ def test_coredump_summary(dut: PanicTestDut) -> None: |
1042 | 1045 | @pytest.mark.parametrize('config', CONFIG_COREDUMP_SUMMARY_FLASH_ENCRYPTED, indirect=True) |
1043 | 1046 | def test_coredump_summary_flash_encrypted(dut: PanicTestDut, config: str) -> None: |
1044 | 1047 | _test_coredump_summary(dut, True, config == 'coredump_flash_encrypted') |
| 1048 | + |
| 1049 | + |
| 1050 | +@pytest.mark.parametrize('config', [pytest.param('coredump_flash_elf_sha', marks=TARGETS_ALL)], indirect=True) |
| 1051 | +@pytest.mark.generic |
| 1052 | +def test_tcb_corrupted(dut: PanicTestDut, target: str, config: str, test_func_name: str) -> None: |
| 1053 | + dut.run_test_func(test_func_name) |
| 1054 | + if dut.is_xtensa: |
| 1055 | + dut.expect_gme('LoadProhibited') |
| 1056 | + dut.expect_reg_dump(0) |
| 1057 | + dut.expect_corrupted_backtrace() |
| 1058 | + else: |
| 1059 | + dut.expect_gme('Load access fault') |
| 1060 | + dut.expect_reg_dump(0) |
| 1061 | + dut.expect_stack_dump() |
| 1062 | + |
| 1063 | + dut.expect_elf_sha256() |
| 1064 | + dut.expect_none('Guru Meditation') |
| 1065 | + |
| 1066 | + # TCB NAME |
| 1067 | + # ---------- ---------------- |
| 1068 | + if dut.is_multi_core: |
| 1069 | + regex_patterns = [rb'[0-9xa-fA-F] main', |
| 1070 | + rb'[0-9xa-fA-F] ipc0', |
| 1071 | + rb'[0-9xa-fA-F] ipc1'] |
| 1072 | + else: |
| 1073 | + regex_patterns = [rb'[0-9xa-fA-F] main'] |
| 1074 | + |
| 1075 | + coredump_pattern = [re.compile(pattern.decode('utf-8')) for pattern in regex_patterns] |
| 1076 | + |
| 1077 | + common_test( |
| 1078 | + dut, |
| 1079 | + config, |
| 1080 | + expected_backtrace=None, |
| 1081 | + expected_coredump=coredump_pattern |
| 1082 | + ) |
0 commit comments