Skip to content

test: expand coverage for src/http/websocket_server.cpp #1053

Description

@kcenon

Part of #953

What

Raise coverage of src/http/websocket_server.cpp from the 2026-04-26 baseline (line 39.9%, branch 19.7%) to line >= 70% and branch >= 60%, measured under the coverage workflow (all BUILD_WITH_* flags, lcov --rc lcov_branch_coverage=1).

Why

  • src/http/websocket_server.cpp sits among the lowest-coverage files in the network_system source tree per the 2026-04-26 measurement on develop @ 05c1b7bb.
  • The uncovered region concentrates in error and boundary paths -- exactly the surfaces that regress during the ongoing Result<T> migration and API stabilization.
  • Bringing this file over the 70% line / 60% branch bar contributes directly to the Expand unit test coverage from 40% to 80% #953 acceptance criteria (80% line / 70% branch ecosystem-wide).

Where

How

Approach

  1. Re-measure current coverage for this file against develop HEAD and record in an issue comment before writing tests.
  2. Identify the uncovered branches and error paths using the lcov branch report.
  3. Add unit tests that exercise:
    • Frame validation errors (reserved bits, opcode, length)
    • Close handshake initiated by either side
    • Control-frame fragmentation rejection
    • Masking key handling on server-received frames
    • Per-message deflate failure paths (if applicable)
  4. Keep tests hermetic -- no network, no filesystem, no sleeps beyond a few ms for timer-driven code paths.
  5. Run ASAN/TSAN/UBSAN locally (or rely on CI) before requesting review.

Acceptance Criteria

  • Current-baseline coverage for src/http/websocket_server.cpp recorded as an issue comment
  • src/http/websocket_server.cpp line coverage >= 70% on develop after merge
  • src/http/websocket_server.cpp branch coverage >= 60% on develop after merge
  • All tests pass on Ubuntu/macOS/Windows CI
  • ASAN, TSAN, UBSAN sanitizer jobs green
  • No regressions in overall network_system coverage

Out of Scope

  • Refactoring src/http/websocket_server.cpp beyond what is strictly needed to make paths testable (seam insertion is acceptable; behavior changes are not).
  • Integration or end-to-end tests -- those live in separate files and are tracked elsewhere.
  • Sibling files listed in Expand unit test coverage from 40% to 80% #953 -- each gets its own sub-issue.

Dependencies

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions