Skip to content

Commit c753271

Browse files
committed
ci(panic): add coredump tcb corrupted test
1 parent 369befb commit c753271

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

tools/test_apps/system/panic/main/include/test_panic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ void test_illegal_access(void);
6767

6868
void test_capture_dram(void);
6969

70+
void test_tcb_corrupted(void);
71+
7072
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
7173
void test_setup_coredump_summary(void);
7274
void test_coredump_summary(void);

tools/test_apps/system/panic/main/test_app_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ void app_main(void)
116116
HANDLE_TEST(test_name, test_assert_cache_disabled);
117117
HANDLE_TEST(test_name, test_assert_cache_write_back_error_can_print_backtrace);
118118
HANDLE_TEST(test_name, test_assert_cache_write_back_error_can_print_backtrace2);
119+
HANDLE_TEST(test_name, test_tcb_corrupted);
119120
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
120121
HANDLE_TEST(test_name, test_setup_coredump_summary);
121122
HANDLE_TEST(test_name, test_coredump_summary);

tools/test_apps/system/panic/main/test_panic.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,15 @@ void test_coredump_summary(void)
301301
}
302302
#endif
303303

304+
void test_tcb_corrupted(void)
305+
{
306+
uint32_t *tcb_ptr = (uint32_t *)xTaskGetIdleTaskHandleForCore(0);
307+
for (size_t i = 0; i < sizeof(StaticTask_t) / sizeof(uint32_t); ++i) {
308+
tcb_ptr[i] = 0xDEADBEE0;
309+
}
310+
vTaskDelay(2);
311+
}
312+
304313
/* NOTE: The following test verifies the behaviour for the
305314
* Xtensa-specific MPU instructions (Refer WDTLB, DSYNC, WDTIB, ISYNC)
306315
* used for memory protection.

tools/test_apps/system/panic/pytest_panic.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
22
# SPDX-License-Identifier: CC0-1.0
33
import re
4+
from typing import Any
45
from typing import List
56
from typing import Optional
7+
from typing import Pattern
8+
from typing import Sequence
69
from typing import Union
710

811
import pexpect
@@ -108,7 +111,7 @@ def get_default_backtrace(config: str) -> List[str]:
108111

109112

110113
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:
112115
if 'gdbstub' in config:
113116
dut.expect_exact('Entering gdb stub now.')
114117
dut.start_gdb_for_gdbstub()
@@ -1042,3 +1045,38 @@ def test_coredump_summary(dut: PanicTestDut) -> None:
10421045
@pytest.mark.parametrize('config', CONFIG_COREDUMP_SUMMARY_FLASH_ENCRYPTED, indirect=True)
10431046
def test_coredump_summary_flash_encrypted(dut: PanicTestDut, config: str) -> None:
10441047
_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

Comments
 (0)