mirror of https://github.com/ARMmbed/mbed-os.git
CMake: Add option to enable greentea tests
Add an option to enable the greentea tests independently from the unit tests. We can't just use the typical BUILD_TESTING option to enable greentea tests. BUILD_TESTING enables unit tests and fetches googletest, which are compiled for the host. Greentea tests are cross compiled and require a toolchain file. For this reason we add a new option just to enable greentea tests, preventing build failures triggered by the unit tests and googletest.pull/14892/head
parent
d4b15348a9
commit
7842320ab7
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
|
||||||
|
|
||||||
|
option(BUILD_GREENTEA_TESTS "Build greentea tests only." OFF)
|
||||||
|
|
||||||
if(${CMAKE_CROSSCOMPILING})
|
if(${CMAKE_CROSSCOMPILING})
|
||||||
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
|
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
|
||||||
include(mbed_set_linker_script)
|
include(mbed_set_linker_script)
|
||||||
|
@ -19,13 +21,15 @@ list(APPEND CMAKE_MODULE_PATH
|
||||||
|
|
||||||
add_subdirectory(extern)
|
add_subdirectory(extern)
|
||||||
|
|
||||||
option(BUILD_TESTING "Run unit tests only." OFF)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
if((NOT BUILD_GREENTEA_TESTS) AND BUILD_TESTING)
|
||||||
|
# Building unit tests only.
|
||||||
add_definitions(-DUNITTEST)
|
add_definitions(-DUNITTEST)
|
||||||
add_subdirectory(UNITTESTS)
|
add_subdirectory(UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(mbed-core INTERFACE)
|
add_library(mbed-core INTERFACE)
|
||||||
|
|
||||||
|
@ -94,11 +98,13 @@ if(${CMAKE_CROSSCOMPILING})
|
||||||
|
|
||||||
# Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1
|
# Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(NOT BUILD_GREENTEA_TESTS)
|
||||||
target_compile_definitions(${PROJECT_NAME}
|
target_compile_definitions(${PROJECT_NAME}
|
||||||
INTERFACE
|
INTERFACE
|
||||||
MBED_TEST_MODE
|
MBED_TEST_MODE
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
|
# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
|
||||||
# script, because of path length limitations on Windows. We set the response file and bind the path
|
# script, because of path length limitations on Windows. We set the response file and bind the path
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(source/framework)
|
add_subdirectory(source/framework)
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(lorastack)
|
add_subdirectory(lorastack)
|
||||||
add_subdirectory(system)
|
add_subdirectory(system)
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# TODO CMake: Perhaps move this/these file(s) into connectivity/drivers/cellular
|
# TODO CMake: Perhaps move this/these file(s) into connectivity/drivers/cellular
|
||||||
target_sources(mbed-cellular
|
target_sources(mbed-cellular
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(mbed-core
|
target_include_directories(mbed-core
|
||||||
INTERFACE
|
INTERFACE
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
add_subdirectory(tests/UNITTESTS)
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
else()
|
else()
|
||||||
|
add_subdirectory(tests/UNITTESTS)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(mbed-events INTERFACE)
|
add_library(mbed-events INTERFACE)
|
||||||
|
|
||||||
|
@ -28,4 +32,3 @@ target_compile_definitions(mbed-events
|
||||||
INTERFACE
|
INTERFACE
|
||||||
MBED_CONF_EVENTS_PRESENT=1
|
MBED_CONF_EVENTS_PRESENT=1
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(TARGET_FLASH_CMSIS_ALGO EXCLUDE_FROM_ALL)
|
add_subdirectory(TARGET_FLASH_CMSIS_ALGO EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# List of all optional platform libraries available.
|
# List of all optional platform libraries available.
|
||||||
add_library(mbed-psa INTERFACE)
|
add_library(mbed-psa INTERFACE)
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(mbed-core
|
target_include_directories(mbed-core
|
||||||
INTERFACE
|
INTERFACE
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if("DATAFLASH" IN_LIST MBED_TARGET_LABELS)
|
if("DATAFLASH" IN_LIST MBED_TARGET_LABELS)
|
||||||
add_subdirectory(COMPONENT_DATAFLASH)
|
add_subdirectory(COMPONENT_DATAFLASH)
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(fat)
|
add_subdirectory(fat)
|
||||||
add_subdirectory(littlefs)
|
add_subdirectory(littlefs)
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(tdbstore)
|
add_subdirectory(tdbstore)
|
||||||
add_subdirectory(filesystemstore)
|
add_subdirectory(filesystemstore)
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(mbed-storage-filesystemstore
|
target_include_directories(mbed-storage-filesystemstore
|
||||||
INTERFACE
|
INTERFACE
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
if(BUILD_GREENTEA_TESTS)
|
||||||
|
# add greentea test
|
||||||
|
else()
|
||||||
add_subdirectory(tests/UNITTESTS)
|
add_subdirectory(tests/UNITTESTS)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(mbed-storage-tdbstore
|
target_include_directories(mbed-storage-tdbstore
|
||||||
INTERFACE
|
INTERFACE
|
||||||
|
|
Loading…
Reference in New Issue