From 2291daae91a7e0d62c9ec82e93921d013b67757c Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Tue, 7 Sep 2021 13:52:50 +0100 Subject: [PATCH] CMake: greentea: Add skip reason Add parser to retrieve MBED_RAM_SIZE, MBED_CONF_TARGET_BOOT_STACK_SIZE, MBED_CONF_RTOS_MAIN_THREAD_STACK_SIZE values from mbed_config.cmake to calculate available stack which is used for if condition check for skip this test. --- .../stack_size_unification/CMakeLists.txt | 31 +++++++++++++++++++ .../mbed_hal/stack_size_unification/main.cpp | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/hal/tests/TESTS/mbed_hal/stack_size_unification/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/stack_size_unification/CMakeLists.txt index 16763f4c82..4cb613b561 100644 --- a/hal/tests/TESTS/mbed_hal/stack_size_unification/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/stack_size_unification/CMakeLists.txt @@ -3,9 +3,40 @@ include(mbed_greentea) +if("TARGET_CORTEX_A" IN_LIST MBED_TARGET_DEFINITIONS) + set(TEST_SKIPPED "Cortex-A target not supported for this test") +endif() + +macro(GetMemSize resultVar memRegion) + # ARGN holds all arguments to function after last named one + foreach(ITR ${ARGN}) + if(ITR MATCHES "${memRegion}*") + string(FIND ${ITR} "=" index) + MATH(EXPR index "${index}+1") + string(SUBSTRING ${ITR} ${index} -1 value) + set(${resultVar} ${value} PARENT_SCOPE) + return() + endif() + endforeach() +endmacro() + +GetMemSize(ram_size "MBED_CONF_TARGET_RAM_SIZE" ${MBED_CONFIG_DEFINITIONS}) +GetMemSize(boot_stack_size "MBED_CONF_TARGET_BOOT_STACK_SIZE" ${MBED_CONFIG_DEFINITIONS}) +GetMemSize(thread_stack_size "MBED_CONF_RTOS_MAIN_THREAD_STACK_SIZE" ${MBED_CONFIG_DEFINITIONS}) +MATH(EXPR total_ram_boot_stack_size "${ram_size}-${boot_stack_size}" OUTPUT_FORMAT HEXADECIMAL) +MATH(EXPR total_boot_thread_stack_size "${boot_stack_size}+${thread_stack_size}" OUTPUT_FORMAT HEXADECIMAL) + +if(${total_ram_boot_stack_size} LESS_EQUAL ${total_boot_thread_stack_size}) + set(TEST_SKIPPED "Insufficient stack for stack_size_unification tests") +endif() + mbed_greentea_add_test( TEST_NAME mbed-hal-stack-size-unification + TEST_INCLUDE_DIRS + . TEST_SOURCES main.cpp + TEST_SKIPPED + ${TEST_SKIPPED} ) diff --git a/hal/tests/TESTS/mbed_hal/stack_size_unification/main.cpp b/hal/tests/TESTS/mbed_hal/stack_size_unification/main.cpp index 6074023918..b538903d7f 100644 --- a/hal/tests/TESTS/mbed_hal/stack_size_unification/main.cpp +++ b/hal/tests/TESTS/mbed_hal/stack_size_unification/main.cpp @@ -20,7 +20,7 @@ #include "unity.h" #include "utest.h" -#ifdef TARGET_RENESAS +#ifdef TARGET_CORTEX_A #error [NOT_SUPPORTED] Cortex-A target not supported for this test #else