Merge pull request #14902 from LDong-Arm/greentea_skip

CMake: tests: Support skipping unsupported test with reason
pull/14993/head
Jaeden Amero 2021-08-11 14:44:07 +01:00 committed by GitHub
commit e588f80d13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 16 deletions

View File

@ -3,6 +3,10 @@
include(mbed_greentea)
if(NOT "DEVICE_USTICKER=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "Microsecond ticker required")
endif()
mbed_greentea_add_test(
TEST_NAME
mbed-drivers-ticker
@ -10,4 +14,6 @@ mbed_greentea_add_test(
main.cpp
HOST_TESTS_DIR
"${CMAKE_CURRENT_LIST_DIR}/../../host_tests"
TEST_SKIPPED
${TEST_SKIPPED}
)

View File

@ -73,3 +73,8 @@ target_link_libraries(mbed-psa
add_subdirectory(test_abstraction_layers)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
if(BUILD_GREENTEA_TESTS)
add_subdirectory(TESTS)
endif()
endif()

View File

@ -0,0 +1,4 @@
# Copyright (c) 2021 Arm Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_subdirectory(attestation/test)

View File

@ -1,18 +1,17 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
include(mbed_greentea)
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "")
set(TEST_TARGET mbed-platform-psa-attestation)
include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake)
project(${TEST_TARGET})
if(MBED_GREENTEA_TEST_BAREMETAL)
set(TEST_SKIPPED "RTOS required")
endif()
mbed_greentea_add_test(
TEST_NAME
${TEST_TARGET}
mbed-platform-psa-attestation
TEST_SOURCES
main.cpp
TEST_SKIPPED
${TEST_SKIPPED}
)

View File

@ -20,19 +20,35 @@ endif()
# TEST_SOURCES - Test suite sources
# TEST_REQUIRED_LIBS - Test suite required libraries
# HOST_TESTS_DIR - Path to the "host_tests" directory
# TEST_SKIPPED - Reason if suite is skipped
#
# calling the macro:
# if(MBED_GREENTEA_TEST_BAREMETAL)
# set(skip_reason "RTOS required")
# endif()
# mbed_greentea_add_test(
# TEST_NAME mbed-platform-system-reset
# TEST_INCLUDE_DIRS mbed_store
# TEST_SOURCES foo.cpp bar.cpp
# TEST_REQUIRED_LIBS mbed-kvstore mbed-xyz
# HOST_TESTS_DIR ${CMAKE_CURRENT_LIST_DIR}/host_tests
# TEST_NAME
# mbed-platform-system-reset
# TEST_INCLUDE_DIRS
# mbed_store
# TEST_SOURCES
# foo.cpp
# bar.cpp
# TEST_REQUIRED_LIBS
# mbed-kvstore
# mbed-xyz
# HOST_TESTS_DIR
# ${CMAKE_CURRENT_LIST_DIR}/host_tests
# TEST_SKIPPED
# ${skip_reason}
# )
macro(mbed_greentea_add_test)
function(mbed_greentea_add_test)
set(options)
set(singleValueArgs TEST_NAME)
set(singleValueArgs
TEST_NAME
TEST_SKIPPED
)
set(multipleValueArgs
TEST_INCLUDE_DIRS
TEST_SOURCES
@ -46,6 +62,22 @@ macro(mbed_greentea_add_test)
${ARGN}
)
if(NOT "${MBED_GREENTEA_TEST_SKIPPED}" STREQUAL "")
add_test(
NAME
${MBED_GREENTEA_TEST_NAME}
COMMAND
${CMAKE_COMMAND} -E echo
"Skipping ${MBED_GREENTEA_TEST_NAME}:"
"${MBED_GREENTEA_TEST_SKIPPED}"
)
set_tests_properties(${MBED_GREENTEA_TEST_NAME}
PROPERTIES
SKIP_REGULAR_EXPRESSION "."
)
return()
endif()
# TODO: After we convert all greentea tests to use CTest, remove this
# add_subdirectory call. We will attach the tests to the mbed-os project,
# rather than creating a new project for each test that depends on mbed-os.
@ -119,4 +151,4 @@ macro(mbed_greentea_add_test)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
endmacro()
endfunction()