Skip to content

Commit

Permalink
add support for out of tree native unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsheirman committed Oct 8, 2024
1 parent 6448f1a commit 655c103
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions stack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ IF(NOT CMAKE_BUILD_TYPE MATCHES Debug)
ENDIF()

PROJECT (${PROJECT_NAME})
enable_testing()

#Set the c standard to use
INSERT_C_FLAGS(BEFORE -std=gnu99 -fno-common)
Expand Down
5 changes: 5 additions & 0 deletions stack/cmake/toolchains/gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
# Toolchain setup gcc
#######################################

# -fshort enums is required as this seems to be default with gcc-arm-none-eabi and we do some static asserts using this assumption
# we also set these for c++ as this otherwise gives problems when linking mocks (C) against our test code (C++)

SET(CMAKE_C_FLAGS_DEBUG "-g -fshort-enums -Wno-typedef-redefinition -Wno-switch -Wno-gnu-variable-sized-type-not-at-end")
SET(CMAKE_CXX_FLAGS_DEBUG "-fshort-enums -g")
2 changes: 1 addition & 1 deletion stack/modules/d7ap_fs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ MODULE_HEADER_DEFINE(
MODULE_BUILD_SETTINGS_FILE()

#Export the module-specific header files to the application by using
EXPORT_GLOBAL_INCLUDE_DIRECTORIES(.)
EXPORT_GLOBAL_INCLUDE_DIRECTORIES(inc)

#By convention, each module should generate a single 'static' library that can be included by the application
ADD_LIBRARY(d7ap_fs STATIC
Expand Down
8 changes: 8 additions & 0 deletions stack/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ limitations under the License.

#Add the 'BUILD_UNIT_TESTS' option
OPTION(BUILD_UNIT_TESTS "Build unit tests applications" ON)

SET(TESTS_EXTRA_TESTS_DIR "" CACHE STRING "Path to directory containing extra, out of tree tests (optional)")


LIST_SUBDIRS(TEST_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
IF(NOT(TESTS_EXTRA_TESTS_DIR STREQUAL ""))
LIST_SUBDIRS(EXTRA_TESTS_DIRS ${TESTS_EXTRA_TESTS_DIR})
LIST(APPEND TEST_DIRS ${EXTRA_TESTS_DIRS})
ENDIF()

#Add conditional options for all subdirs (which are individual applications)
FOREACH(__dir ${TEST_DIRS})
Expand Down

0 comments on commit 655c103

Please sign in to comment.