tests: arch: common: add stack_unwind test
Added test for archs that support it. It triggers an exception and verify that the fatal message has stack unwind info. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
This commit is contained in:
parent
7398831884
commit
b8b98c2c29
9
tests/arch/common/stack_unwind/CMakeLists.txt
Normal file
9
tests/arch/common/stack_unwind/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Copyright (c) 2024 Meta
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||||
|
project(stack_unwind_test)
|
||||||
|
|
||||||
|
FILE(GLOB app_sources src/*.c)
|
||||||
|
target_sources(app PRIVATE ${app_sources})
|
11
tests/arch/common/stack_unwind/prj.conf
Normal file
11
tests/arch/common/stack_unwind/prj.conf
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
CONFIG_TEST=y
|
||||||
|
|
||||||
|
CONFIG_LOG=y
|
||||||
|
CONFIG_LOG_BUFFER_SIZE=2048
|
||||||
|
|
||||||
|
CONFIG_EXCEPTION_STACK_TRACE=y
|
||||||
|
CONFIG_OVERRIDE_FRAME_POINTER_DEFAULT=y
|
||||||
|
CONFIG_OMIT_FRAME_POINTER=n
|
||||||
|
CONFIG_DEBUG=y
|
||||||
|
CONFIG_DEBUG_INFO=y
|
||||||
|
CONFIG_DEBUG_OPTIMIZATIONS=y
|
39
tests/arch/common/stack_unwind/src/main.c
Normal file
39
tests/arch/common/stack_unwind/src/main.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Meta
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
|
|
||||||
|
static void func1(int a);
|
||||||
|
static void func2(int a);
|
||||||
|
|
||||||
|
static void func2(int a)
|
||||||
|
{
|
||||||
|
printf("%d: %s\n", a, __func__);
|
||||||
|
|
||||||
|
if (a >= 5) {
|
||||||
|
k_oops();
|
||||||
|
}
|
||||||
|
|
||||||
|
func1(a + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void func1(int a)
|
||||||
|
{
|
||||||
|
printf("%d: %s\n", a, __func__);
|
||||||
|
func2(a + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
printf("Hello World! %s\n", CONFIG_BOARD);
|
||||||
|
|
||||||
|
func1(1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
39
tests/arch/common/stack_unwind/testcase.yaml
Normal file
39
tests/arch/common/stack_unwind/testcase.yaml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
common:
|
||||||
|
harness: console
|
||||||
|
ignore_faults: true
|
||||||
|
ignore_qemu_crash: true
|
||||||
|
tags: kernel
|
||||||
|
tests:
|
||||||
|
arch.common.stack_unwind.riscv:
|
||||||
|
arch_allow: riscv
|
||||||
|
integration_platforms:
|
||||||
|
- qemu_riscv32
|
||||||
|
- qemu_riscv64
|
||||||
|
harness_config:
|
||||||
|
type: multi_line
|
||||||
|
regex:
|
||||||
|
- "E: call trace:"
|
||||||
|
- "E: 0: fp: \\w+ ra: \\w+"
|
||||||
|
- "E: 1: fp: \\w+ ra: \\w+"
|
||||||
|
arch.common.stack_unwind.x86:
|
||||||
|
arch_allow: x86
|
||||||
|
extra_configs:
|
||||||
|
- CONFIG_NO_OPTIMIZATIONS=y
|
||||||
|
integration_platforms:
|
||||||
|
- qemu_x86
|
||||||
|
- qemu_x86_64
|
||||||
|
harness_config:
|
||||||
|
type: multi_line
|
||||||
|
regex:
|
||||||
|
- "E: call trace:"
|
||||||
|
- "E: (E|R)IP: \\w+"
|
||||||
|
arch.common.stack_unwind.arm:
|
||||||
|
arch_allow:
|
||||||
|
- arm64
|
||||||
|
integration_platforms:
|
||||||
|
- qemu_cortex_a53
|
||||||
|
harness_config:
|
||||||
|
type: multi_line
|
||||||
|
regex:
|
||||||
|
- "E: backtrace 0: fp: \\w+ lr: \\w+"
|
||||||
|
- "E: backtrace 1: fp: \\w+ lr: \\w+"
|
Loading…
Reference in a new issue