Skip to content

Commit 159f832

Browse files
authored
Merge pull request #14892 from rwalton-arm/greentea_ctest
Add CTest support for `mbed-drivers-ticker` greentea test
2 parents d4b1534 + 1a7a89a commit 159f832

File tree

23 files changed

+194
-47
lines changed

23 files changed

+194
-47
lines changed

.github/workflows/greentea_cmake.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: test building greentea tests with cmake
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build-greentea-cmake:
7+
runs-on: ubuntu-latest
8+
container: ghcr.io/armmbed/mbed-os-env:master-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
13+
- name: Install the latest mbed-tools
14+
run: |
15+
pip3 install --upgrade mbed-tools
16+
mbedtools --version
17+
18+
- name: Build NUCLEO_G031K8 with baremetal profile
19+
run: |
20+
rm -rf __build
21+
mbedtools configure -t GCC_ARM -m NUCLEO_G031K8 --mbed-os-path . --output-dir __build --app-config TESTS/configs/baremetal.json
22+
cmake -S . -B __build -GNinja -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DBUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_TEST_BAREMETAL=ON
23+
cmake --build __build
24+
25+
- name: Build ARM_MUSCA_S1 with full profile
26+
run: |
27+
rm -rf __build
28+
mbedtools configure -t GCC_ARM -m ARM_MUSCA_S1 --mbed-os-path . --output-dir __build
29+
cmake -S . -B __build -GNinja -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DBUILD_GREENTEA_TESTS=ON
30+
cmake --build __build

.github/workflows/test_building_multiple_executables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [pull_request]
55
jobs:
66
multiple-executables-example:
77
runs-on: ubuntu-latest
8-
container: mbedos/mbed-os-env:latest
8+
container: ghcr.io/armmbed/mbed-os-env:master-latest
99
steps:
1010
- name: Checkout
1111
uses: actions/checkout@v2

CMakeLists.txt

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55

66
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
77

8+
option(BUILD_GREENTEA_TESTS "Build greentea tests only." OFF)
9+
10+
if(BUILD_GREENTEA_TESTS)
11+
# Usually we rely on the application to set MBED_CONFIG_PATH and include
12+
# app.cmake. They are both required if we're building an application to run
13+
# on an mbed-target.
14+
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE STRING "")
15+
# TODO: Remove when https://github.com/ARMmbed/mbed-os/issues/14518 is fixed
16+
include(${CMAKE_CURRENT_LIST_DIR}/tools/cmake/app.cmake)
17+
endif()
18+
819
if(${CMAKE_CROSSCOMPILING})
920
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
1021
include(mbed_set_linker_script)
@@ -14,17 +25,19 @@ project(mbed-os)
1425

1526
# Add all paths to the list files within Mbed OS
1627
list(APPEND CMAKE_MODULE_PATH
17-
"${mbed-os_SOURCE_DIR}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_Cypress/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NXP/scripts"
28+
"${mbed-os_SOURCE_DIR}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_Cypress/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NXP/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NUVOTON/scripts/"
1829
)
1930

2031
add_subdirectory(extern)
2132

22-
option(BUILD_TESTING "Run unit tests only." OFF)
23-
24-
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
33+
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
2534
include(CTest)
26-
add_definitions(-DUNITTEST)
27-
add_subdirectory(UNITTESTS)
35+
36+
if((NOT BUILD_GREENTEA_TESTS) AND BUILD_TESTING)
37+
# Building unit tests only.
38+
add_definitions(-DUNITTEST)
39+
add_subdirectory(UNITTESTS)
40+
endif()
2841
endif()
2942

3043
add_library(mbed-core INTERFACE)
@@ -94,10 +107,12 @@ if(${CMAKE_CROSSCOMPILING})
94107

95108
# Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1
96109
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
97-
target_compile_definitions(${PROJECT_NAME}
98-
INTERFACE
99-
MBED_TEST_MODE
100-
)
110+
if(NOT BUILD_GREENTEA_TESTS)
111+
target_compile_definitions(${PROJECT_NAME}
112+
INTERFACE
113+
MBED_TEST_MODE
114+
)
115+
endif()
101116
endif()
102117

103118
# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker

connectivity/cellular/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
5-
add_subdirectory(tests/UNITTESTS)
5+
if(BUILD_GREENTEA_TESTS)
6+
# add greentea test
7+
else()
8+
add_subdirectory(tests/UNITTESTS)
9+
endif()
610
endif()
711

812
add_subdirectory(source/framework)

connectivity/lorawan/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
5-
add_subdirectory(tests/UNITTESTS)
5+
if(BUILD_GREENTEA_TESTS)
6+
# add greentea test
7+
else()
8+
add_subdirectory(tests/UNITTESTS)
9+
endif()
610
endif()
711

812
add_subdirectory(lorastack)

connectivity/netsocket/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
5-
add_subdirectory(tests/UNITTESTS)
5+
if(BUILD_GREENTEA_TESTS)
6+
# add greentea test
7+
else()
8+
add_subdirectory(tests/UNITTESTS)
9+
endif()
610
endif()
711

812
# TODO CMake: Perhaps move this/these file(s) into connectivity/drivers/cellular

drivers/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
5-
add_subdirectory(tests/UNITTESTS)
5+
if(BUILD_GREENTEA_TESTS)
6+
add_subdirectory(tests/TESTS)
7+
else()
8+
add_subdirectory(tests/UNITTESTS)
9+
endif()
610
endif()
711

812
target_include_directories(mbed-core

drivers/tests/TESTS/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_subdirectory(mbed_drivers/ticker)
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# Copyright (c) 2020 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
5-
6-
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../.. CACHE INTERNAL "")
7-
set(TEST_TARGET mbed-drivers-ticker)
8-
9-
include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake)
10-
11-
project(${TEST_TARGET})
4+
include(mbed_greentea)
125

136
mbed_greentea_add_test(
147
TEST_NAME
15-
${TEST_TARGET}
8+
mbed-drivers-ticker
169
TEST_SOURCES
1710
main.cpp
11+
HOST_TESTS_DIR
12+
"${CMAKE_CURRENT_LIST_DIR}/../../host_tests"
1813
)

events/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
5-
add_subdirectory(tests/UNITTESTS)
6-
else()
5+
if(BUILD_GREENTEA_TESTS)
6+
# add greentea test
7+
else()
8+
add_subdirectory(tests/UNITTESTS)
9+
endif()
10+
endif()
711

812
add_library(mbed-events INTERFACE)
913

@@ -28,4 +32,3 @@ target_compile_definitions(mbed-events
2832
INTERFACE
2933
MBED_CONF_EVENTS_PRESENT=1
3034
)
31-
endif()

0 commit comments

Comments
 (0)