Skip to content

cintegration: fake registry lifts PilotEmbeddedStart coverage#5

Merged
TeoSlayer merged 1 commit into
mainfrom
mock-embedded-start
May 28, 2026
Merged

cintegration: fake registry lifts PilotEmbeddedStart coverage#5
TeoSlayer merged 1 commit into
mainfrom
mock-embedded-start

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Summary

  • New stdlib-only cintegration/mockregistry/ binary that speaks the registry's length-prefixed JSON protocol (register, lookup, heartbeat, etc.) with canned replies — enough to satisfy pkg/daemon.Start() end-to-end.
  • harness.c now boots a real in-process embedded daemon pointed at the fake registry, then drives it through PilotInfo / PilotHealth / PilotEmbeddedStop and exercises every early-return / guard branch in PilotEmbeddedStart.
  • Five extra bad-handle / bad-JSON smoke tests scattered across the 71–83% bindings round out the diff (PilotDisconnect, PilotConnSetReadDeadline, PilotDialTimeout, PilotMemberTagsSet).

Coverage

function before after
embedded.go:PilotEmbeddedStart 13.6% 79.5%
embedded.go:PilotEmbeddedStop 46.2% 84.6%
embedded.go:defaults 0% 100%
embedded.go:unmarshalCString 66.7% 100%
libpilot total 68.5% 80.1%

89 pass, 0 fail.

Test plan

  • cd cintegration && make clean && make build — all binaries link
  • cd cintegration && make run — 89/89 pass
  • cd cintegration && make cover — total ≥ 80.0%
  • embedded_start_double_call exercises the singleton guard
  • STUN failure against 127.0.0.1:1 is treated as a warning (no failure)
  • No changes to libpilot production code (bindings.go, embedded.go, coverflush.go)

PilotEmbeddedStart boots an in-process pkg/daemon that dials a real
registry over TCP — without one, the //export short-circuits at
daemon.Start() and the harness never reaches the rest of the function
(13.6% coverage baseline).

Adds cintegration/mockregistry/, a stdlib-only fake registry that
speaks length-prefixed JSON and answers register / lookup / heartbeat
with canned data. Daemon Start succeeds end-to-end (STUN fails but is
non-fatal — discoverWithTempSocket falls back to the local addr).

Harness now drives:
- embedded_start_with_mock_registry — full boot success path
- embedded_info_via_driver — proves the IPC socket is live
- embedded_health_via_driver — second IPC round-trip
- embedded_start_double_call — already-started guard
- embedded_stop_after_start — clean teardown
- embedded_start_{null_config,missing_data_dir,missing_socket_path} —
  defaults() + early-return branches
- mock_dial_timeout(_bad_addr) — ParseSocketAddr success/error paths
- mock_member_tags_set_bad_json — json.Unmarshal error branch
- bad-handle smoke tests for the remaining 71–80% bindings

Coverage:
- libpilot total: 68.5% → 80.1%
- embedded.go PilotEmbeddedStart: 13.6% → 79.5%
- embedded.go PilotEmbeddedStop: 46.2% → 84.6%
- embedded.go defaults: 0% → 100%
- embedded.go unmarshalCString: 66.7% → 100%

89 pass, 0 fail.
@TeoSlayer TeoSlayer merged commit 4e04b0e into main May 28, 2026
1 check passed
@TeoSlayer TeoSlayer deleted the mock-embedded-start branch May 28, 2026 03:26
@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!

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