Skip to content

Commit cc64ecb

Browse files
committed
Refactor twister execution and cleanup logic in samples.sh and unittest.sh
1 parent e77c096 commit cc64ecb

2 files changed

Lines changed: 4 additions & 40 deletions

File tree

samples.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ rm -rf "$OUTPUT_DIR"
2525

2626
# Run twister with the specified test cases and output directory
2727
"$TWISTER_EXE" -O "$OUTPUT_DIR" -T "$TEST_CASES_DIR"
28+
TWISTER_RC=$?
2829

2930
# twister output directory cleanup files we do not archive
3031
find "$OUTPUT_DIR" -name 'CMakeFiles' -exec rm -rf {} \; 2>/dev/null
@@ -56,7 +57,7 @@ find "$OUTPUT_DIR" -name 'app' -exec rm -rf '{}' \; 2>/dev/null
5657
echo "Twister samples output cleanup completed successfully."
5758

5859
# Check if twister ran successfully
59-
if [ $? -eq 0 ]; then
60+
if [ $TWISTER_RC -eq 0 ]; then
6061
echo "Twister samples testing completed successfully."
6162
else
6263
echo "Twister samples testing failed."

unittest.sh

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,50 +22,13 @@ OUTPUT_DIR="$SCRIPT_DIR/twister-out.unit_testing"
2222

2323
# Set platform to unit testing to avoid building for ALL platforms
2424
TWISTER_PLATFORM="unit_testing"
25-
NATIVE_SIM_PLATFORM="native_sim"
26-
27-
cleanup_twister_output_dir() {
28-
local output_dir="$1"
29-
30-
find "$output_dir" -name 'CMakeFiles' -exec rm -rf {} \; 2>/dev/null
31-
find "$output_dir" -name 'modules' -exec rm -rf {} \; 2>/dev/null
32-
find "$output_dir" -name 'app' -exec rm -rf \
33-
'{}/../zephyr/arch
34-
{}/../zephyr/boards
35-
{}/../zephyr/cmake
36-
{}/../zephyr/CMakeFiles
37-
{}/../zephyr/dev_graph.dot
38-
{}/../zephyr/drivers
39-
{}/../zephyr/dts.cmake
40-
{}/../zephyr/edt.pickle
41-
{}/../zephyr/include
42-
{}/../zephyr/isrList.bin
43-
{}/../zephyr/kconfig
44-
{}/../zephyr/kernel
45-
{}/../zephyr/lib
46-
{}/../zephyr/libzephyr.a
47-
{}/../zephyr/misc
48-
{}/../zephyr/modules
49-
{}/../zephyr/soc
50-
{}/../zephyr/subsys
51-
{}/../Makefile
52-
{}/../Kconfig
53-
{}/../cmake_install.cmake
54-
{}/../CMakeCache.txt' \; 2>/dev/null
55-
find "$output_dir" -name 'app' -exec rm -rf '{}' \; 2>/dev/null
56-
}
5725

5826
# Remove the output directory
5927
rm -rf "$OUTPUT_DIR"
60-
rm -rf "$NATIVE_SIM_OUTPUT_DIR"
6128

6229
# Run twister with the specified test cases and output directory
6330
"$TWISTER_EXE" -O "$OUTPUT_DIR" -p "$TWISTER_PLATFORM" -T "$TEST_CASES_DIR"
64-
UNIT_TEST_RC=$?
65-
66-
# Run twister for native_sim-only functional tests
67-
"$TWISTER_EXE" -O "$NATIVE_SIM_OUTPUT_DIR" -p "$NATIVE_SIM_PLATFORM" -T "$NATIVE_SIM_TEST_CASES_DIR"
68-
NATIVE_SIM_RC=$?
31+
TWISTER_RC=$?
6932

7033
# twister output directory cleanup files we do not archive
7134
find "$OUTPUT_DIR" -name 'CMakeFiles' -exec rm -rf {} \; 2>/dev/null
@@ -97,7 +60,7 @@ find "$OUTPUT_DIR" -name 'app' -exec rm -rf '{}' \; 2>/dev/null
9760
echo "Twister unit_testing output cleanup completed successfully."
9861

9962
# Check if twister ran successfully
100-
if [ $? -eq 0 ]; then
63+
if [ $TWISTER_RC -eq 0 ]; then
10164
echo "Twister unit_testing completed successfully."
10265
else
10366
echo "Twister unit_testing failed."

0 commit comments

Comments
 (0)