Skip to content

cintegration: mock daemon pushes datagrams + accepts inbound dials#4

Merged
TeoSlayer merged 1 commit into
mainfrom
mock-daemon-extension
May 28, 2026
Merged

cintegration: mock daemon pushes datagrams + accepts inbound dials#4
TeoSlayer merged 1 commit into
mainfrom
mock-daemon-extension

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Summary

  • Mock daemon reflects every cmdSendTo back to the same client as a cmdRecvFrom frame (sentinel srcPort=0xDEAD), so PilotRecvFrom finally exercises its happy path.
  • Mock daemon keeps a process-wide listenerRegistry keyed by bound port; when client B dials a port client A has bound, the mock pushes cmdAccept on A's socket, with a write-mutex on clientConn to keep cross-goroutine frames non-interleaved. boundPorts is cleaned up on disconnect.
  • Two new C tests in harness.c: test_mock_recv_from and test_mock_listener_accept (the latter opens two PilotConnect handles and drives Listen on A, Dial on B, Accept on A).

Coverage delta

Total 66.3% -> 68.5% (+2.2pp), both target endpoints off 0%:

function before after
PilotRecvFrom 0.0% 71.4%
PilotListenerAccept 30.0% 80.0%

PilotListenerAccept was already at 30% because test_accept_bad_handle hit its error branch; the new test drives the success branch.

Test plan

  • cd cintegration && make clean && make cover — 72/72 PASS, 0 FAIL
  • go tool cover -func=coverage.out | grep -E "RecvFrom|ListenerAccept" confirms the new percentages
  • No edits to libpilot production code (bindings.go, embedded.go); only cintegration/harness.c and cintegration/mockdaemon/main.go changed

Extends the harness to cover the two endpoints still stuck at the FFI-
bound ceiling:

PilotRecvFrom (0.0% -> 71.4%): the mock now reflects every cmdSendTo
back to the same client as a cmdRecvFrom frame, with srcPort=0xDEAD
as a sentinel. The harness sends a datagram, calls PilotRecvFrom, and
asserts the JSON envelope contains the reflected dst_port and the
sentinel src_port.

PilotListenerAccept (30.0% -> 80.0%): the mock keeps a process-wide
listenerRegistry keyed by bound port; when one connected client dials
a port another client has bound, the mock pushes a cmdAccept frame on
the listener's socket. clientConn carries a write mutex so frames from
the dial handler can't interleave with the listener's own replies.
Bound ports are cleaned up when the listener's connection drops.

The new test_mock_listener_accept opens two PilotConnect handles and
drives Listen on A, Dial on B, Accept on A end-to-end. Total coverage:
66.3% -> 68.5%.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TeoSlayer TeoSlayer merged commit 82d1083 into main May 28, 2026
2 checks passed
@TeoSlayer TeoSlayer deleted the mock-daemon-extension branch May 28, 2026 02:21
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.

2 participants