Skip to content

fix(renode): address review follow-ups from PR #533#558

Merged
mangelajo merged 3 commits intomainfrom
fix/renode-driver-review-followups
Apr 15, 2026
Merged

fix(renode): address review follow-ups from PR #533#558
mangelajo merged 3 commits intomainfrom
fix/renode-driver-review-followups

Conversation

@ambient-code
Copy link
Copy Markdown
Contributor

@ambient-code ambient-code Bot commented Apr 15, 2026

Summary

Addresses the open follow-up items from issue #556 (Renode driver review of PR #533).

MEDIUM fixes

  • close() leaks SocketStream: Added RenodeMonitor.close_sync() that uses SocketAttribute.raw_socket for best-effort synchronous socket cleanup during driver teardown
  • Private attribute traversal across sibling drivers: Added RenodePower.is_running property and send_monitor_command() public method — RenodeFlasher.flash() and Renode.monitor_cmd() no longer access _process/_monitor directly
  • Shared mutable parent state for firmware loading: Added Renode.set_firmware() method as the explicit interface instead of RenodeFlasher writing parent._firmware_path/_load_command directly
  • off() inconsistent state on terminate() failure: Wrapped process cleanup in try/finally so _process is always reset to None, even if terminate() raises ProcessLookupError
  • Test gaps — error/cleanup paths: Added tests for on() mid-startup failure cleanup, connect() persistent OSErrorTimeoutError, _read_until_prompt with empty receive()ConnectionError
  • Idempotency tests lack assertions: test_power_on_idempotent and test_power_off_idempotent now assert that Popen/RenodeMonitor were NOT called

LOW fixes

  • Dead hasattr guard: Replaced with power.is_running (which checks _process is not None and _monitor is not None)
  • on() method too long: Extracted monitor setup into _configure_simulation()
  • TOCTOU race in _find_free_port(): Added comment documenting the race and noting Renode doesn't yet support Unix domain sockets
  • Decorative separator comments in tests: Removed all six # 5.x ... section separators
  • Minor test coverage gaps: Added tests for _find_renode() when binary not on PATH, RenodePower.read() NotImplementedError, monitor_cmd() success path, close() timeout-kill branch, close_sync(), is_running property, set_firmware()

Test plan

  • ruff check passes on all changed files
  • ruff format --check passes on all changed files
  • CI runs existing + new unit tests
  • CI runs E2E test (test_driver_renode_e2e) where Renode is installed

Closes #556

🤖 Generated with Claude Code

Ambient Code Bot and others added 3 commits April 15, 2026 12:22
Closes #556

MEDIUM fixes:
- Fix close() SocketStream leak: add RenodeMonitor.close_sync() using
  SocketAttribute.raw_socket for best-effort synchronous cleanup
- Eliminate private attribute traversal across sibling drivers: add
  RenodePower.is_running property and send_monitor_command() public
  method so RenodeFlasher and Renode no longer access _process/_monitor
- Make shared firmware state explicit: add Renode.set_firmware() method
  instead of directly writing parent._firmware_path/_load_command
- Fix off() inconsistent state on terminate() failure: wrap process
  cleanup in try/finally so _process is always reset to None
- Add error/cleanup path tests: on() mid-startup failure cleanup,
  connect() persistent OSError timeout, _read_until_prompt empty receive
- Fix idempotency tests: add assertions that Popen/RenodeMonitor are
  NOT called on duplicate on()/off() calls

LOW fixes:
- Replace dead hasattr guard with power.is_running check
- Extract _configure_simulation() from on() to reduce method length
- Add TOCTOU race comment to _find_free_port()
- Remove decorative separator comments from tests
- Add test coverage: _find_renode not on PATH, read() NotImplementedError,
  monitor_cmd() success path, close() timeout-kill, close_sync(),
  is_running property, set_firmware()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ProcessLookupError is expected when the process has already exited.
The try/finally ensures _process is reset to None, but the exception
must also be caught to prevent it from propagating to callers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove spurious '@' prefix from LoadELF file path argument that
  caused a parameter mismatch error in Renode
- Add "There was an error" and "Parameters did not match" to monitor
  error markers so these failures are caught immediately
- Strip leading whitespace from response lines before checking error
  markers so indented error messages are not missed
- Add tests for parameter mismatch detection and leading whitespace

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 69501bcd-d783-4acc-8f44-14ced2432ef7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/renode-driver-review-followups

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 and usage tips.

@mangelajo mangelajo merged commit 4ba92e8 into main Apr 15, 2026
38 of 41 checks passed
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.

Renode driver: follow-up items from PR #533 review

1 participant