Skip to content

test: expand coverage for src/protocols/http2/http2_client.cpp #991

Description

@kcenon

Part of #953

What

Raise line coverage of src/protocols/http2/http2_client.cpp from 18.6% to >= 70%, and branch coverage from 9.7% to >= 60%.

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

  • Instrumented lines: 576 / ~1181 LOC
  • Lines hit: 107 / 576 (18.6%)
  • Branches: 95 / 979 (9.7%)
  • Existing tests: tests/unit/http2_client_test.cpp — 316 LOC, 29 GTEST cases

Branch coverage under 10% is especially alarming for an HTTP/2 client — most conditional paths (HPACK decode edge cases, stream state transitions, settings negotiation, GOAWAY handling) are unverified.

Why

  • HTTP/2 clients are consumed by pacs_system and messaging_system downstream; wire-level bugs propagate.
  • 9.7% branch coverage means the implementation is almost entirely tested along a single happy path.
  • Second-largest uncovered implementation file in the project.

Where

  • Source: src/protocols/http2/http2_client.cpp
  • Headers: include/kcenon/network/protocols/http2/ (verify exact path)
  • Existing tests to extend: tests/unit/http2_client_test.cpp
  • Possibly add: tests/unit/http2_client_frame_test.cpp, tests/unit/http2_client_error_test.cpp

How

Approach

  1. Use PR ci(coverage): enable messaging_bridge in coverage build #989's coverage artifact (coverage_html/src/protocols/http2/http2_client.cpp.gcov.html) to identify dead blocks.
  2. Focus test additions on:
    • SETTINGS frame negotiation edge cases
    • HPACK header decoding (dynamic table updates, huffman decode errors)
    • Stream lifecycle (RST_STREAM, WINDOW_UPDATE, flow control)
    • Connection-level errors (PROTOCOL_ERROR, COMPRESSION_ERROR, GOAWAY)
  3. Prefer parameterized tests for frame-type dispatch.

Acceptance Criteria

  • src/protocols/http2/http2_client.cpp line coverage >= 70%
  • src/protocols/http2/http2_client.cpp branch coverage >= 60%
  • New tests added to tests/unit/http2_client_*.cpp
  • All tests pass on Ubuntu/macOS CI
  • ASAN/TSAN/UBSAN all green on the new tests

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions