Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new ztest unit test that exercises objpool_iterate() and validates callback sequencing and early-stop behavior.
Changes:
- Introduces a small test payload struct and iterator callback for validating iteration behavior.
- Adds
test_objpool_iterateto allocate a few objects, iterate until a condition is met, and assert the stop point.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| static bool test_objpool_cb(void *data, void *arg) | ||
| { | ||
| struct test_objpool_data *odata = data; | ||
|
|
||
| zassert_equal(test_objpool_check++, odata->cnt, "Counter mismatch"); | ||
| zassert_equal((unsigned int)arg, 2, "Wrong argument"); | ||
|
|
||
| return odata->cnt == (unsigned int)arg; |
There was a problem hiding this comment.
The test passes an integer as a pointer ((void *)2) and later casts the callback arg back with (unsigned int)arg. This is non-portable and can trigger pointer/integer size warnings (and truncation) on 64-bit builds, potentially failing with -Werror. Use the project’s pointer/int conversion helpers (e.g. UINT_TO_POINTER() when passing and POINTER_TO_UINT()/uintptr_t when reading) or pass a real pointer to a typed value, and update the comparisons accordingly.
kv2019i
left a comment
There was a problem hiding this comment.
One minor note, otherwise looks good (and great to have more tests).
Add an objpool test for its iterator function. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Add an objpool test for its iterator function.