Skip to content

Commit a25fcdc

Browse files
CMake: Add MBED_TEST_MODE test application
MBED_TEST_MODE is required for backward compatibilty with CLI1. This adds a test to ensure that the macro is created when using CLI2 for testing. This also adds a test in `.travis.yml` that checks whether CMake defines the macro when BUILD_TESTING is on.
1 parent 6309f9b commit a25fcdc

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ matrix:
109109
':!*tests/*' ':!*targets/*' ':!*TARGET_*' ':!*unsupported/*' \
110110
':!*events/tests/*' ':!*drivers/tests/*'
111111
112-
### Docs Tests ###
112+
- <<: *basic-vm
113+
name: "CMake MBED_TEST_MODE check"
114+
env: NAME=mbed_test_mode_check
115+
script:
116+
- mbedtools configure -p tools/cmake/tests/mbed_test_mode -t GCC_ARM -m K64F --mbed-os-path .
117+
- cmake -S tools/cmake/tests/mbed_test_mode -B tools/cmake/tests/mbed_test_mode/cmake_build/K64F/develop/GCC_ARM/ -GNinja -DCMAKE_BUILD_TYPE=develop
118+
- cmake --build tools/cmake/tests/mbed_test_mode/cmake_build/K64F/develop/GCC_ARM/
119+
120+
### Docs Tests ###
113121
- &docs-vm
114122
stage: "Docs"
115123
name: "astyle"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
5+
6+
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../.. CACHE INTERNAL "")
7+
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE STATIC "")
8+
9+
include(${MBED_PATH}/tools/cmake/app.cmake)
10+
11+
add_executable(mbed-test-mode-check)
12+
project(mbed-test-mode-check)
13+
14+
set(PROJECT_NAME ${CMAKE_PROJECT_NAME} CACHE INTERNAL "")
15+
include(CTest)
16+
17+
target_sources(mbed-test-mode-check
18+
PRIVATE
19+
main.cpp
20+
)
21+
22+
add_subdirectory(
23+
${MBED_PATH} build
24+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2021 Arm Limited and Contributors. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#if BUILD_TESTING && !defined(MBED_TEST_MODE)
8+
#error "MBED_TEST_MODE not defined with BUILD_TESTING on"
9+
#else
10+
int main(){
11+
return 1;
12+
}
13+
#endif

0 commit comments

Comments
 (0)