Skip to content

gconnman_agent_test.cpp: Fix memory leak when test fails - #49

Merged
EddyTheCo merged 1 commit into
mainfrom
agent_valgrind_test_leak
Aug 25, 2026
Merged

gconnman_agent_test.cpp: Fix memory leak when test fails#49
EddyTheCo merged 1 commit into
mainfrom
agent_valgrind_test_leak

Conversation

@EddyTheCo

@EddyTheCoEddyTheCo commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Use RAII smart pointer to take care of live management of GError object. Although the memory leak only happens when the test fail, it is good to always have Valgrind leaks equal to zero on the tests as reference.

Fixes#48

Summary by CodeRabbit

  • Tests
    • Improved test reliability and readability.
    • Added automatic cleanup for error handling in agent response tests.

Use RAII smart pointer to take care of live management of GError object.
Although the memory leak only happens when the test fail, it is good to
always have Valgrind leaks equal to zero on the tests as reference.
Fixes#48
Signed-off-by: Eduardo Gonzalez <eduardo.gonzalez@amarulasolutions.com>
@coderabbitai

coderabbitaiBot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1cb1ce5c-4afe-43f2-ae19-fb9a1ec2e8ea

📥 Commits

Reviewing files that changed from the base of the PR and between 6c21580 and 45709e6.

📒 Files selected for processing (1)
  • tests/gconnman_agent_test.cpp

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The agent tests retain the existing helper interface and replace raw GError access with std::unique_ptr ownership in two error-response tests.

Changes

Agent test memory management

Layer / File(s)Summary
RAII error handling in agent tests
tests/gconnman_agent_test.cpp
The call_agent declaration keeps its existing signature. ReportErrorIsAnswered and CancelIsAnswered use owning GError guards for diagnostic output.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk:⚪ Minimal · up to 45709

This change updates test cleanup to avoid a failure-path memory leak without changing product behavior; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly describes the memory leak fix in gconnman_agent_test.cpp.
Linked Issues check✅ PassedThe PR applies RAII management to GError in the two affected tests, addressing issue #48's memory leak objective.
Out of Scope Changes check✅ PassedThe changes are limited to RAII error management and formatting in the affected agent tests.
Docstring Coverage✅ PassedDocstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent_valgrind_test_leak

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🧩 Build Artifacts

✅ The following build artifacts were produced:

@AndreaRicchiAndreaRicchi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@EddyTheCo
EddyTheCo merged commit f63926c into mainAug 25, 2026
3 checks passed
@EddyTheCo
EddyTheCo deleted the agent_valgrind_test_leak branch August 25, 2026 13:53
Sign up for freeto 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.

memory leak on agent test

2 participants

@EddyTheCo@AndreaRicchi