Skip to content

test: expand coverage for src/protocols/http2/http2_server.cpp #992

Description

@kcenon

Part of #953

What

Raise line coverage of src/protocols/http2/http2_server.cpp from 17.7% to >= 70%, and branch coverage from 7.4% to >= 60%.

Current state (2026-04-17 measurement, source PR #989):

  • Instrumented lines: 554 / ~971 LOC
  • Lines hit: 98 / 554 (17.7%)
  • Branches: 54 / 725 (7.4%)
  • Existing tests: tests/unit/http2_server_test.cpp (177 LOC, 13 cases) + tests/unit/http2_server_stream_test.cpp (448 LOC, 24 cases)

Branch coverage at 7.4% is the worst of the top-5 files. 37 GTEST cases across two test files exercise only a small fraction of the server-side state machine.

Why

  • HTTP/2 server is exposed to untrusted client input; untested branches = unverified defenses.
  • Many of the 7.4% uncovered branches are likely error-handling paths for malformed frames — exactly the code paths an attacker would probe.
  • Third-largest uncovered file.

Where

  • Source: src/protocols/http2/http2_server.cpp
  • Existing tests to extend: tests/unit/http2_server_test.cpp, tests/unit/http2_server_stream_test.cpp
  • Possibly add: tests/unit/http2_server_error_test.cpp (malformed frame handling, PROTOCOL_ERROR paths)

How

Approach

  1. Identify uncovered blocks via PR ci(coverage): enable messaging_bridge in coverage build #989 coverage artifact.
  2. Focus test additions on:
    • Preface validation (missing, wrong, truncated)
    • Frame parsing errors (invalid frame type, oversized payload)
    • Stream state violations (DATA on closed stream, HEADERS on existing stream)
    • Settings compliance (SETTINGS_MAX_CONCURRENT_STREAMS, SETTINGS_INITIAL_WINDOW_SIZE boundaries)
    • Flow control (WINDOW_UPDATE with 0, overflow, underflow)
  3. Fuzz-style parameterized inputs recommended; existing tests/unit/http2_server_stream_test.cpp already uses this pattern.

Acceptance Criteria

  • src/protocols/http2/http2_server.cpp line coverage >= 70%
  • src/protocols/http2/http2_server.cpp branch coverage >= 60%
  • New tests consolidated logically (one file per concern)
  • All tests pass on Ubuntu/macOS CI
  • ASAN/TSAN/UBSAN all green on new tests

Dependencies

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions