Sebastian Huber created a merge request: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1599

Project:Branches: sebhub/rtems:up/test-heap-internals to rtems/rtos/rtems:main
Author: Sebastian Huber

## Summary

Issue #5830: Tests depend on the internals of the first-fit heap

**Problem:** 21 tests depend on the first-fit heap by accident. They use small 
areas with exact segment sizes, the block header, the order of two blocks or an 
internal heap function. A heap with another block layout or more overhead makes 
them fail.

**Fix:** Derive each segment size from `rtems_region_get_free_information()` 
and give each region a static area of 8 KiB. Replace the internal calls by 
public interfaces such as `malloc_usable_size()`, `malloc_info()` and 
`rtems_workspace_get_information()`. Move the tests of the `_Heap_*` functions 
from `malloctest` to the new program `heap01`.

**Review hints:**

- The leak check of the T test framework compares only the used blocks. A heap 
may merge its free blocks in another order without a leak.
- `tm20` derives its large segment from the free information, so that it fits 
only into the empty region. This keeps the "not available" and the "caller 
blocks" paths.
- `spfatal36` allocates with `_Workspace_Allocate()`, since the public greedy 
directive needs an executing thread for the allocator mutex.

## Test

| BSP | Result |
| --- | --- |
| `sparc/gr740` on SIS | 21 changed tests pass, no warning |
| `arm/xilinx_zynq_a9_qemu` on Qemu | 21 changed tests pass, no warning |
| `aarch64/a53_lp64_qemu` on Qemu | 21 changed tests pass, no warning |

The same tests pass on the three BSPs with a red-black tree heap in place of 
the first-fit heap.

## AI Details
<!-- Make sure you have read our statement at 
https://www.rtems.org/generative-ai/ -->

### Prompt used

None as a single prompt. The work was done in an interactive Claude Code 
session on the RTEMS tree. The task was to make the test suite independent of 
the heap implementation. Each change was directed and reviewed.

### AI model used

Claude Opus 5.5 (claude-opus-5-5), through Claude Code.

### How AI was used for the contribution

- ( ) Formatting
- (x) Test creation.
- (x) Code comments.
- ( ) The entire contribution was generated using AI
- ( ) AI code completion such as Copilot in VSCode.

The analysis and the test changes were produced in that session under my 
direction, and the commit messages were drafted there.

### Access

I have not used a product which claims copyright in its output, and I have 
legitimate access to the one I used.

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1599
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-d24fr7wp5p04d0t9fjwzbcgqx-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to