Skip to content

Commit 2ef8c4e

Browse files
dcpleungfabiobaltieri
authored andcommitted
tests: debug/thread_analyzer: add some build tests
Add some build tests for thread_analyzer to catch build issues at CI. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
1 parent eec1044 commit 2ef8c4e

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(thread_analyzer_tests)
7+
8+
target_sources(app PRIVATE src/main.c)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_THREAD_ANALYZER=y
2+
CONFIG_THREAD_ANALYZER_AUTO=y
3+
4+
# log immediate mode requires a bit more stack to print
5+
CONFIG_THREAD_ANALYZER_AUTO_STACK_SIZE=2048
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2024 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
9+
#define EXTRA_THREAD_STACKSIZE 2048
10+
11+
struct k_thread extra_thread;
12+
K_THREAD_STACK_DEFINE(extra_stack, EXTRA_THREAD_STACKSIZE);
13+
14+
static void thread_entry(void *p1, void *p2, void *p3)
15+
{
16+
/* This thread does not have a name so thread analyzer will display
17+
* the memory address of the thread struct, which is needed for
18+
* the twister console harness to match (even if CONFIG_THREAD_NAME=y).
19+
*/
20+
while (true) {
21+
k_sleep(K_SECONDS(300));
22+
}
23+
}
24+
25+
int main(void)
26+
{
27+
k_thread_create(&extra_thread, extra_stack, EXTRA_THREAD_STACKSIZE,
28+
thread_entry, NULL, NULL, NULL, K_PRIO_PREEMPT(0),
29+
IS_ENABLED(CONFIG_USERSPACE) ? K_USER : 0,
30+
K_MSEC(0));
31+
return 0;
32+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
common:
2+
integration_platforms:
3+
- mps2/an385
4+
- qemu_x86_64
5+
tags:
6+
- debug
7+
- thread_analyzer
8+
platform_exclude:
9+
# native_sim prints nothing from thread analyzer so skips it for now.
10+
- native_sim
11+
tests:
12+
debug.thread_analyzer.printk:
13+
extra_configs:
14+
- CONFIG_THREAD_ANALYZER_USE_PRINTK=y
15+
harness: console
16+
harness_config:
17+
type: multi_line
18+
regex:
19+
- "(.*)0x([0-9a-fA-F]+)([ ]+) : STACK: unused [0-9]+ usage [0-9]+ / [0-9]+ (.*)"
20+
- "(.*)ISR0([ ]+) : STACK: unused [0-9]+ usage [0-9]+ / [0-9]+ (.*)"
21+
debug.thread_analyzer.printk.userspace:
22+
filter: CONFIG_ARCH_HAS_USERSPACE
23+
extra_configs:
24+
- CONFIG_THREAD_ANALYZER_USE_PRINTK=y
25+
- CONFIG_USERSPACE=y
26+
harness: console
27+
harness_config:
28+
type: multi_line
29+
regex:
30+
- "(.*)0x([0-9a-fA-F]+)([ ]+) : STACK: unused [0-9]+ usage [0-9]+ / [0-9]+ (.*)"
31+
- "(.*)ISR0([ ]+) : STACK: unused [0-9]+ usage [0-9]+ / [0-9]+ (.*)"
32+
debug.thread_analyzer.log_backend:
33+
extra_configs:
34+
- CONFIG_THREAD_ANALYZER_USE_LOG=y
35+
- CONFIG_LOG=y
36+
- CONFIG_LOG_MODE_IMMEDIATE=y
37+
harness: console
38+
harness_config:
39+
type: multi_line
40+
regex:
41+
- "(.*)0x([0-9a-fA-F]+)([ ]+) : STACK: unused [0-9]+ usage [0-9]+ / [0-9]+ (.*)"
42+
- "(.*)ISR0([ ]+) : STACK: unused [0-9]+ usage [0-9]+ / [0-9]+ (.*)"
43+
debug.thread_analyzer.log_backend.userspace:
44+
filter: CONFIG_ARCH_HAS_USERSPACE
45+
extra_configs:
46+
- CONFIG_USERSPACE=y
47+
- CONFIG_THREAD_ANALYZER_USE_LOG=y
48+
- CONFIG_LOG=y
49+
- CONFIG_LOG_MODE_IMMEDIATE=y
50+
harness: console
51+
harness_config:
52+
type: multi_line
53+
regex:
54+
- "(.*)0x([0-9a-fA-F]+)([ ]+) : STACK: unused [0-9]+ usage [0-9]+ / [0-9]+ (.*)"
55+
- "(.*)ISR0([ ]+) : STACK: unused [0-9]+ usage [0-9]+ / [0-9]+ (.*)"

0 commit comments

Comments
 (0)