-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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+" |