1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/core/thread_stack_alignment
Hugues Larrive 3c465836f2 examples and tests: add atmega8 to relevent Makefile.ci
using dist/tools/insufficient_memory/add_insufficient_memory_board.sh
2023-07-11 21:22:02 +02:00
..
tests tests: move core related applications to tests/core/ subdirectory 2023-05-10 15:41:38 +02:00
main.c tests: move core related applications to tests/core/ subdirectory 2023-05-10 15:41:38 +02:00
Makefile tests: move core related applications to tests/core/ subdirectory 2023-05-10 15:41:38 +02:00
Makefile.ci examples and tests: add atmega8 to relevent Makefile.ci 2023-07-11 21:22:02 +02:00
README.md tests: move core related applications to tests/core/ subdirectory 2023-05-10 15:41:38 +02:00

Testing for Correct Stack Alignment

This test application asks the linker to align a stack to 128 B (assuming this is the worst case alignment requirement). Not that features like the MPU may result in much higher alignment requirements than the CPU actually has, thus 128 B is not crazy as it may sound. For each offset from 0 to 127 it will then launch a thread using the aligned stack plus the current offset, thus iterating over all possible stack alignments.

The test thread run snprintf() to format a double, compares the output with the expected result, and exists to allow the subsequent thread to reuse the stack. This is a good test for two reasons: Variadic functions (such as snprintf()) on some platforms have different calling conventions that may more easily trigger alignment issues, and an FPU may have a higher alignment requirement than the CPU has.

The test is considered as passing if for all tested alignments the call to snprintf() produces the correct result and no crash happens on the way.

Finally, the test script will collect the output of the stack consumptions and give out the worst case penalty a user has to face