Skip to content

Commit 2ddb22d

Browse files
committed
Add subsys.sh script and update CMakeLists.txt for bacnet_settings tests
- Introduced subsys.sh for running native_sim functional tests and cleanup. - Updated CMakeLists.txt to use dynamic source directory for includes and sources.
1 parent 253b99f commit 2ddb22d

3 files changed

Lines changed: 108 additions & 3 deletions

File tree

.github/workflows/zephyr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- uses: actions/checkout@v3
3737
- name: Run Docker image from GHCR
3838
env:
39-
DOCKER_RUN_TARGET: "/workspace/bacnet/west-ci.sh && /workspace/bacnet/samples.sh && /workspace/bacnet/unittest.sh"
39+
DOCKER_RUN_TARGET: "/workspace/bacnet/west-ci.sh && /workspace/bacnet/samples.sh && /workspace/bacnet/unittest.sh && /workspace/bacnet/subsys.sh"
4040
ZEPHYR_CONTAINER: "ghcr.io/zephyrproject-rtos/ci:v0.26-branch"
4141
run: |
4242
ls -alh

subsys.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
# Set the path to the twister executable
3+
TWISTER_EXE=""
4+
5+
# Set workspace virtual environment if available
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7+
WORKSPACE_VENV="$SCRIPT_DIR/../.venv"
8+
WORKSPACE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
9+
TWISTER_EXE="$WORKSPACE_DIR/zephyr/scripts/twister"
10+
11+
if [ -x "$WORKSPACE_VENV/bin/python3" ]; then
12+
VENV_SITE="$($WORKSPACE_VENV/bin/python3 -c 'import site; print(site.getsitepackages()[0])')"
13+
export PATH="$WORKSPACE_VENV/bin:$PATH"
14+
export PYTHONPATH="$VENV_SITE${PYTHONPATH:+:$PYTHONPATH}"
15+
fi
16+
17+
# Set the path to the test cases directory
18+
TEST_CASES_DIR="$SCRIPT_DIR/zephyr/tests/subsys"
19+
20+
# Set the output directory for test results
21+
OUTPUT_DIR="$SCRIPT_DIR/twister-out.subsys"
22+
23+
# Set platform to native_sim to run specific simulation tests
24+
TWISTER_PLATFORM="native_sim"
25+
26+
cleanup_twister_output_dir() {
27+
local output_dir="$1"
28+
29+
find "$output_dir" -name 'CMakeFiles' -exec rm -rf {} \; 2>/dev/null
30+
find "$output_dir" -name 'modules' -exec rm -rf {} \; 2>/dev/null
31+
find "$output_dir" -name 'app' -exec rm -rf \
32+
'{}/../zephyr/arch
33+
{}/../zephyr/boards
34+
{}/../zephyr/cmake
35+
{}/../zephyr/CMakeFiles
36+
{}/../zephyr/dev_graph.dot
37+
{}/../zephyr/drivers
38+
{}/../zephyr/dts.cmake
39+
{}/../zephyr/edt.pickle
40+
{}/../zephyr/include
41+
{}/../zephyr/isrList.bin
42+
{}/../zephyr/kconfig
43+
{}/../zephyr/kernel
44+
{}/../zephyr/lib
45+
{}/../zephyr/libzephyr.a
46+
{}/../zephyr/misc
47+
{}/../zephyr/modules
48+
{}/../zephyr/soc
49+
{}/../zephyr/subsys
50+
{}/../Makefile
51+
{}/../Kconfig
52+
{}/../cmake_install.cmake
53+
{}/../CMakeCache.txt' \; 2>/dev/null
54+
find "$output_dir" -name 'app' -exec rm -rf '{}' \; 2>/dev/null
55+
}
56+
57+
# Remove the output directory
58+
rm -rf "$OUTPUT_DIR"
59+
60+
# Run twister for native_sim-only functional subsys tests
61+
"$TWISTER_EXE" -O "$OUTPUT_DIR" -p "$TWISTER_PLATFORM" -T "$TEST_CASES_DIR"
62+
TWISTER_RC=$?
63+
64+
# twister output directory cleanup files we do not archive
65+
find "$OUTPUT_DIR" -name 'CMakeFiles' -exec rm -rf {} \; 2>/dev/null
66+
find "$OUTPUT_DIR" -name 'modules' -exec rm -rf {} \; 2>/dev/null
67+
find "$OUTPUT_DIR" -name 'app' -exec rm -rf \
68+
'{}/../zephyr/arch
69+
{}/../zephyr/boards
70+
{}/../zephyr/cmake
71+
{}/../zephyr/CMakeFiles
72+
{}/../zephyr/dev_graph.dot
73+
{}/../zephyr/drivers
74+
{}/../zephyr/dts.cmake
75+
{}/../zephyr/edt.pickle
76+
{}/../zephyr/include
77+
{}/../zephyr/isrList.bin
78+
{}/../zephyr/kconfig
79+
{}/../zephyr/kernel
80+
{}/../zephyr/lib
81+
{}/../zephyr/libzephyr.a
82+
{}/../zephyr/misc
83+
{}/../zephyr/modules
84+
{}/../zephyr/soc
85+
{}/../zephyr/subsys
86+
{}/../Makefile
87+
{}/../Kconfig
88+
{}/../cmake_install.cmake
89+
{}/../CMakeCache.txt' \; 2>/dev/null
90+
find "$OUTPUT_DIR" -name 'app' -exec rm -rf '{}' \; 2>/dev/null
91+
echo "Twister native_sim output cleanup completed successfully."
92+
93+
# Check if twister ran successfully
94+
if [ $TWISTER_RC -eq 0 ]; then
95+
echo "Twister native_sim completed successfully."
96+
else
97+
echo "Twister native_sim failed."
98+
exit 1
99+
fi

zephyr/tests/subsys/bacnet_settings/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ cmake_minimum_required(VERSION 3.20.0)
22
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
33
project(bacnet_settings)
44

5+
string(REGEX REPLACE
6+
"/zephyr/tests/[0-9a-zA-Z_/-]*$"
7+
"/zephyr"
8+
SRC_DIR
9+
${CMAKE_CURRENT_SOURCE_DIR})
10+
511
target_include_directories(app PRIVATE
6-
${CMAKE_CURRENT_SOURCE_DIR}/../../../include
12+
${SRC_DIR}/include
713
)
814

915
target_sources(app PRIVATE
1016
src/main.c
11-
${CMAKE_CURRENT_SOURCE_DIR}/../../../subsys/bacnet_settings/bacnet_storage.c
17+
${SRC_DIR}/subsys/bacnet_settings/bacnet_storage.c
1218
)
1319

1420
add_compile_definitions(

0 commit comments

Comments
 (0)