Skip to content

objpool: add an iterator test#10520

Merged
lgirdwood merged 1 commit intothesofproject:mainfrom
lyakh:objpool
Feb 5, 2026
Merged

objpool: add an iterator test#10520
lgirdwood merged 1 commit intothesofproject:mainfrom
lyakh:objpool

Conversation

@lyakh
Copy link
Collaborator

@lyakh lyakh commented Feb 4, 2026

Add an objpool test for its iterator function.

Copilot AI review requested due to automatic review settings February 4, 2026 15:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_iterate to 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.

Comment on lines +85 to +92
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;
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh can you use the macros ?

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one open

Comment on lines +85 to +92
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh can you use the macros ?

Copy link
Collaborator

@softwarecki softwarecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No additional comments from my side beyond what was already mentioned

@lgirdwood
Copy link
Member

We can update if needed in a subsequent PR

@lgirdwood lgirdwood merged commit 1a738c9 into thesofproject:main Feb 5, 2026
45 of 52 checks passed
@lyakh lyakh deleted the objpool branch February 6, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants