Skip to content

Commit e588f80

Browse files
authored
Merge pull request #14902 from LDong-Arm/greentea_skip
CMake: tests: Support skipping unsupported test with reason
2 parents 4125fd0 + 6776069 commit e588f80

File tree

5 files changed

+62
-16
lines changed

5 files changed

+62
-16
lines changed

drivers/tests/TESTS/mbed_drivers/ticker/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33

44
include(mbed_greentea)
55

6+
if(NOT "DEVICE_USTICKER=1" IN_LIST MBED_TARGET_DEFINITIONS)
7+
set(TEST_SKIPPED "Microsecond ticker required")
8+
endif()
9+
610
mbed_greentea_add_test(
711
TEST_NAME
812
mbed-drivers-ticker
913
TEST_SOURCES
1014
main.cpp
1115
HOST_TESTS_DIR
1216
"${CMAKE_CURRENT_LIST_DIR}/../../host_tests"
17+
TEST_SKIPPED
18+
${TEST_SKIPPED}
1319
)

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,8 @@ target_link_libraries(mbed-psa
7373

7474
add_subdirectory(test_abstraction_layers)
7575

76+
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
77+
if(BUILD_GREENTEA_TESTS)
78+
add_subdirectory(TESTS)
79+
endif()
80+
endif()
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(attestation/test)
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
4+
include(mbed_greentea)
55

6-
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "")
7-
set(TEST_TARGET mbed-platform-psa-attestation)
8-
9-
include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake)
10-
11-
project(${TEST_TARGET})
6+
if(MBED_GREENTEA_TEST_BAREMETAL)
7+
set(TEST_SKIPPED "RTOS required")
8+
endif()
129

1310
mbed_greentea_add_test(
1411
TEST_NAME
15-
${TEST_TARGET}
12+
mbed-platform-psa-attestation
1613
TEST_SOURCES
1714
main.cpp
15+
TEST_SKIPPED
16+
${TEST_SKIPPED}
1817
)

tools/cmake/mbed_greentea.cmake

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,35 @@ endif()
2020
# TEST_SOURCES - Test suite sources
2121
# TEST_REQUIRED_LIBS - Test suite required libraries
2222
# HOST_TESTS_DIR - Path to the "host_tests" directory
23+
# TEST_SKIPPED - Reason if suite is skipped
2324
#
2425
# calling the macro:
26+
# if(MBED_GREENTEA_TEST_BAREMETAL)
27+
# set(skip_reason "RTOS required")
28+
# endif()
2529
# mbed_greentea_add_test(
26-
# TEST_NAME mbed-platform-system-reset
27-
# TEST_INCLUDE_DIRS mbed_store
28-
# TEST_SOURCES foo.cpp bar.cpp
29-
# TEST_REQUIRED_LIBS mbed-kvstore mbed-xyz
30-
# HOST_TESTS_DIR ${CMAKE_CURRENT_LIST_DIR}/host_tests
30+
# TEST_NAME
31+
# mbed-platform-system-reset
32+
# TEST_INCLUDE_DIRS
33+
# mbed_store
34+
# TEST_SOURCES
35+
# foo.cpp
36+
# bar.cpp
37+
# TEST_REQUIRED_LIBS
38+
# mbed-kvstore
39+
# mbed-xyz
40+
# HOST_TESTS_DIR
41+
# ${CMAKE_CURRENT_LIST_DIR}/host_tests
42+
# TEST_SKIPPED
43+
# ${skip_reason}
3144
# )
3245

33-
macro(mbed_greentea_add_test)
46+
function(mbed_greentea_add_test)
3447
set(options)
35-
set(singleValueArgs TEST_NAME)
48+
set(singleValueArgs
49+
TEST_NAME
50+
TEST_SKIPPED
51+
)
3652
set(multipleValueArgs
3753
TEST_INCLUDE_DIRS
3854
TEST_SOURCES
@@ -46,6 +62,22 @@ macro(mbed_greentea_add_test)
4662
${ARGN}
4763
)
4864

65+
if(NOT "${MBED_GREENTEA_TEST_SKIPPED}" STREQUAL "")
66+
add_test(
67+
NAME
68+
${MBED_GREENTEA_TEST_NAME}
69+
COMMAND
70+
${CMAKE_COMMAND} -E echo
71+
"Skipping ${MBED_GREENTEA_TEST_NAME}:"
72+
"${MBED_GREENTEA_TEST_SKIPPED}"
73+
)
74+
set_tests_properties(${MBED_GREENTEA_TEST_NAME}
75+
PROPERTIES
76+
SKIP_REGULAR_EXPRESSION "."
77+
)
78+
return()
79+
endif()
80+
4981
# TODO: After we convert all greentea tests to use CTest, remove this
5082
# add_subdirectory call. We will attach the tests to the mbed-os project,
5183
# rather than creating a new project for each test that depends on mbed-os.
@@ -119,4 +151,4 @@ macro(mbed_greentea_add_test)
119151
set(CMAKE_VERBOSE_MAKEFILE ON)
120152
endif()
121153

122-
endmacro()
154+
endfunction()

0 commit comments

Comments
 (0)