Skip to content

Commit 36ec7c8

Browse files
committed
Add: Tests on native sim
1 parent 62bd1a5 commit 36ec7c8

File tree

14 files changed

+111
-2
lines changed

14 files changed

+111
-2
lines changed

‎.vscode/settings.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@
6767
"label": "$(trash) Clean",
6868
"task": "Clean",
6969
"tooltip": "Delete build directory"
70+
},
71+
{
72+
"label": "$(beaker) Run tests",
73+
"task": "Run tests",
74+
"tooltip": "Build and run all tests on native sim"
7075
}
7176
],
7277
"cortex-debug.variableUseNaturalFormat": false,

‎.vscode/tasks.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,26 @@
115115
},
116116
"problemMatcher": []
117117
},
118+
{
119+
"label": "Run tests",
120+
"type": "shell",
121+
"command": "sh",
122+
"args": [
123+
"-c",
124+
"(cd ${workspaceFolder}/project/apps/he_app/tests && west build -b native_sim --pristine && west build -t run) && (cd ${workspaceFolder}/project/apps/hp_app/tests && west build -b native_sim --pristine && west build -t run)"
125+
],
126+
"group": {
127+
"kind": "test",
128+
"isDefault": true
129+
},
130+
"options": {
131+
"cwd": "${workspaceFolder}"
132+
},
133+
"presentation": {
134+
"clear": true
135+
},
136+
"problemMatcher": []
137+
},
118138
{
119139
"label": "Maintenance",
120140
"type": "shell",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.20.0)
2+
3+
set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../../base.conf
4+
${CMAKE_CURRENT_SOURCE_DIR}/../../../tests.conf
5+
)
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
8+
project(test_heApp)
9+
10+
# Use same include directories as the app
11+
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../)
12+
13+
# tests suite
14+
target_sources(
15+
app
16+
PRIVATE tests.c
17+
)
18+
19+

‎project/apps/he_app/tests/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
menu "Zephyr"
2+
source "Kconfig.zephyr"
3+
endmenu

‎project/apps/he_app/tests/prj.conf‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Test-specific configuration for native_sim
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests:
2+
project.he_app:
3+
platform_allow:
4+
- native_sim
5+
integration_platforms:
6+
- native_sim
7+
8+
tags: [he_app]
9+
harness: ztest

‎project/apps/he_app/tests/tests.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <zephyr/kernel.h>
2+
#include <zephyr/ztest.h>
3+
#include <stddef.h>
4+
5+
ZTEST(he_app_tests, test_basic_assert_true)
6+
{
7+
zassert_true(true, "This should always pass");
8+
}
9+
10+
ZTEST_SUITE(he_app_tests, NULL, NULL, NULL, NULL, NULL);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required(VERSION 3.20.0)
2+
3+
set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../../base.conf
4+
${CMAKE_CURRENT_SOURCE_DIR}/../../../tests.conf
5+
)
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
8+
project(test_hpApp)
9+
10+
# Use same include directories as the app
11+
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../)
12+
13+
# tests suite
14+
target_sources(
15+
app
16+
PRIVATE tests.c
17+
)

‎project/apps/hp_app/tests/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
menu "Zephyr"
2+
source "Kconfig.zephyr"
3+
endmenu

‎project/apps/hp_app/tests/prj.conf‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Test-specific configuration for native_sim

0 commit comments

Comments
 (0)