-
Notifications
You must be signed in to change notification settings - Fork 3k
stack_size_unification test: set expected stack sizes from config #12979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stack_size_unification test: set expected stack sizes from config #12979
Conversation
73ab9a8
to
0ac17ea
Compare
#ifdef MBED_CONF_RTOS_MAIN_THREAD_STACK_SIZE | ||
#undef MBED_CONF_RTOS_MAIN_THREAD_STACK_SIZE | ||
#endif | ||
#define MBED_CONF_RTOS_MAIN_THREAD_STACK_SIZE 3072 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This affects only TMPM46B - see a few lines above.
We remove this macro-redefinition and override it properly in rtos/source/TARGET_CORTEX/mbed_lib.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| NUCLEO_F303K8-ARMC6 | NUCLEO_F303K8 | tests-mbed_hal-stack_size_unification | Stack size unification test | 1 | 0 | OK | 0.06 |
|
||
#if defined(TARGET_NUCLEO_F070RB) || defined(TARGET_STM32F072RB) || defined(TARGET_TMPM46B) || defined(TARGET_TMPM066) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of NUCLEO_F070RB, STM32F072RB and TMPM46B have thread stack sizes overriden in rtos/source/TARGET_CORTEX/mbed_lib.json, so we don't need target-dependent code here. As for TARGET_TMPM066, it's not supported anymore).
Thanks for testing! |
@LDong-Arm, thank you for your changes. |
@@ -76,6 +76,9 @@ | |||
"STM32F072RB": { | |||
"main-thread-stack-size": 3072 | |||
}, | |||
"TMPM46B": { | |||
"main-thread-stack-size": 3072 | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to specify this per target?
Or can we set the stack-size depending on the total RAM? (which would be target independent)
EDIT: and of course let the user override it in mbed_app.json
if they want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking RAM size is ideal, and we do have target.mbed_ram_size
for this purpose.
The trouble is, we only have it defined for a few targets. For most other targets, the RAM and ROM sizes are hardcoded in the linker scripts (e.g. scatter files) - only the linker knows the RAM, not the application/libraries/...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, 17 targets have it defined: https://github.com/ARMmbed/mbed-os/blob/master/targets/targets.json
Okay it's more than a few, but still far from a good coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, thanks for clarifying it
This PR is great anyway as it helps us with some clean-up. More could be done in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I'd like to see the sizes defined - it can help us to disable certain Greentea test cases for ultra-constrained targets for which we even struggle to compile some very basic tests... @evedon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best would be to generate the linker script (having set per toolchain and that is it) so having the size defined is one way forward there :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great @LDong-Arm. Thanks for the PR.
CI started |
CI failed with
Looks unrelated to this PR? |
CI restarted It was a bug on master. |
@0xc0170 Thanks but could you please keep this on hold? There's a slight issue I'll fix tomorrow |
Test run: SUCCESSSummary: 6 of 6 test jobs passed |
|
||
#define EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE (4096) | ||
#define EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE (MBED_CONF_RTOS_THREAD_STACK_SIZE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the test case below, we use this macro to verify OS_STACK_SIZE
:
TEST_ASSERT_EQUAL(EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE, OS_STACK_SIZE);
where OS_STACK_SIZE
is conditional
mbed-os/rtos/source/TARGET_CORTEX/mbed_rtx_conf.h
Lines 31 to 35 in 9a8c9e2
#if defined(MBED_CONF_APP_THREAD_STACK_SIZE) | |
#define OS_STACK_SIZE MBED_CONF_APP_THREAD_STACK_SIZE | |
#else | |
#define OS_STACK_SIZE MBED_CONF_RTOS_THREAD_STACK_SIZE | |
#endif |
The trouble is, to get the assertion to pass in all scenarios, our expectation needs to be conditional in the same way. But isn't it a duplication? I'm not sure there's any value in comparing two macros in a Greentea test to begin with...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, we should remove this assertion from the test case - which is out of this PR's initial scope (i.e. fixing line 34). But still this line of diff doesn't make things worse than before (i.e. hardcoded 4096).
@0xc0170 If this PR blocks any release, maybe we can get it in as it is?
@adbridge This Greentea test fix is required for all targets with a non-default stack size, particularly bare-metal-only targets with small memories. Is it critical for the release? |
Patch updates can wait until the next release |
This PR does not contain release version label after merging. |
Summary of changes
Use macros defined by the build system to set expected stack sizes in stack_size_unification test so that
Credits to @jeromecoutant for raising this.
Impact of changes
The test passes even if a target (i.e. one that has low memory) overrides the default stack sizes.
Migration actions required
Documentation
None.
Pull request type
Test results
Tested on
target.boot-stack-size
manually changed, with both the full profile and the bare metal profile.Reviewers
@evedon @ARMmbed/mbed-os-core @mprse @MarceloSalazar