mirror of https://github.com/ARMmbed/mbed-os.git
Add stack size unification test
Test checks stack sizes: - ISR stack: exactly 1KB (with exception for NORDIC - 2KB and RENESAS - Cortex A targets not supported for this test) - Main thread stack: exactly 4KB (with some exceptions - 3KB) - Thread stack: exactly 4KBpull/9092/head
parent
1739d7e6dd
commit
01ca8443a8
|
@ -0,0 +1,74 @@
|
||||||
|
/* mbed Microcontroller Library
|
||||||
|
* Copyright (c) 2018 ARM Limited
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include "mbed.h"
|
||||||
|
#include "greentea-client/test_env.h"
|
||||||
|
#include "unity.h"
|
||||||
|
#include "utest.h"
|
||||||
|
|
||||||
|
#ifdef TARGET_RENESAS
|
||||||
|
#error [NOT_SUPPORTED] Cortex-A target not supported for this test
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace utest::v1;
|
||||||
|
|
||||||
|
extern osThreadAttr_t _main_thread_attr;
|
||||||
|
extern uint32_t mbed_stack_isr_size;
|
||||||
|
|
||||||
|
/* Exception for Nordic boards - BLE requires 2KB ISR stack. */
|
||||||
|
#if defined(TARGET_NRF5x)
|
||||||
|
#define EXPECTED_ISR_STACK_SIZE (2048)
|
||||||
|
#else
|
||||||
|
#define EXPECTED_ISR_STACK_SIZE (1024)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TARGET_NUCLEO_F070RB) || defined(TARGET_NANO100) || defined(TARGET_STM32F072RB) || defined(TARGET_TMPM46B) || defined(TARGET_TMPM066)
|
||||||
|
#define EXPECTED_MAIN_THREAD_STACK_SIZE (3072)
|
||||||
|
#else
|
||||||
|
#define EXPECTED_MAIN_THREAD_STACK_SIZE (4096)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE (4096)
|
||||||
|
|
||||||
|
/* Test sizes of ISR stack, main thread stack, default user thread stack.
|
||||||
|
*
|
||||||
|
* On some platforms with lower RAM size (e.g. NUCLEO_F070RB - 16 KB RAM) it is impossible
|
||||||
|
* to create thread with default stack size to check its size, that is why we will
|
||||||
|
* check only macro which specifies default user thread stack.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void stack_size_unification_test()
|
||||||
|
{
|
||||||
|
TEST_ASSERT_EQUAL(EXPECTED_ISR_STACK_SIZE, mbed_stack_isr_size);
|
||||||
|
TEST_ASSERT_EQUAL(EXPECTED_MAIN_THREAD_STACK_SIZE, _main_thread_attr.stack_size);
|
||||||
|
TEST_ASSERT_EQUAL(EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE, OS_STACK_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
|
GREENTEA_SETUP(10, "default_auto");
|
||||||
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
|
}
|
||||||
|
|
||||||
|
Case cases[] = {
|
||||||
|
Case("Stack size unification test", stack_size_unification_test)
|
||||||
|
};
|
||||||
|
|
||||||
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return !Harness::run(specification);
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* mbed Microcontroller Library
|
||||||
|
* Copyright (c) 2017-2018 ARM Limited
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \addtogroup hal_rtc_tests
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MBED_STACK_SIZE_UNIFICATION_H
|
||||||
|
#define MBED_STACK_SIZE_UNIFICATION_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Test sizes of ISR stack, main thread stack, default user thread stack.
|
||||||
|
*
|
||||||
|
* Given is Mbed OS configuration.
|
||||||
|
* When ISR stack, main thread stack, default user thread stack sizes are defined.
|
||||||
|
* Then ISR stack size is equal to 1 KB,
|
||||||
|
* main thread stack size is equal to 4 KB,
|
||||||
|
* default user thread stack size is equal to 4 KB.
|
||||||
|
*
|
||||||
|
* NOTE:
|
||||||
|
* It is impossible to verify RTOS-less thread stack size since all tests are build with RTOS.
|
||||||
|
*/
|
||||||
|
void stack_size_unification_test(void);
|
||||||
|
|
||||||
|
/**@}*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @}*/
|
Loading…
Reference in New Issue