Skip to content

Add code coverage#220

Merged
colemancda merged 41 commits into
masterfrom
feature/code-coverage
Jul 18, 2026
Merged

Add code coverage#220
colemancda merged 41 commits into
masterfrom
feature/code-coverage

Conversation

@colemancda

@colemancda colemancda commented Jul 18, 2026

Copy link
Copy Markdown
Member

Adds code coverage measurement, reporting, and CI enforcement — and, along the way, raises coverage from a 70.68% baseline to 88.35%, fixes several source bugs the new tests uncovered, and makes the unit tests actually run on more platforms in CI.

Coverage tooling

  • Scripts/coverage.sh runs the suite with coverage, exports LCOV (coverage.lcov) and Cobertura (coverage.xml) reports scoped to this package's own sources under Sources/ (dependencies and tests excluded), and fails if line coverage drops below the threshold.
  • New Code Coverage GitHub Actions job runs the script on macOS, uploads the Cobertura report to GitHub Code Quality for per-PR display, and archives both reports.
  • Threshold is ratcheted up as coverage grows; currently 87% (measured 88.35%).
  • COVERAGE_PLAN.md documents the phased path toward 95%.

New tests (70.68% → 88.35%)

  • HCI: round-trip encode/decode/reject tests for ~110 previously-untested command/event types (classic, LE connection, LE advertising, LE privacy/test-mode).
  • GATT/ATT: untested ATT PDUs, GATT service/characteristic types, the GATTDatabase value-type API, and end-to-end GATTClientGATTServer procedures (reads, long reads, read-by-type, short/long/no-response writes, error responses) over the in-memory L2CAP transport.
  • GAP: service-solicitation UUID lists, Security Manager OOB/TK, Simple Pairing hash/randomizer.

Source bug fixes (found by the new tests)

  • HCIReadLMPHandleReturn validated against the wrong length and misordered its fields — could never decode through the HCI transport.
  • HCILEGenerateDHKey encoded 65 bytes instead of 64 (duplicated two bytes, dropped one).
  • HCILEReadLocalResolvableAddressReturn / HCILEReadPeerResolvableAddressReturn read 8 bytes from a 6-byte payload — trapped out-of-bounds on any valid response.
  • HCILETransmitterTest omitted the Length_Of_Test_Data byte.
  • GATTDatabase.add(service:) never recorded included-service handles, tripping an assertion (a debug-build trap) for any service with included services.

Deduplication

  • The shared Hexadecimal, Integer, System, String, and Bool extensions were copied internal into every target. Consolidated one package-access copy each into the core Bluetooth target and removed 12 duplicate files (~1,200 lines).

CI: run the unit tests on more platforms

  • Windows: now runs swift test (previously build-only).
  • Android: the full suite now runs on the x86_64 emulator (the only Android ABI GitHub-hosted runners can hardware-accelerate), and the tests are cross-compiled for aarch64 and armv7 as a compile-verification step. This mirrors the official Swift Android SDK CI — hosted runners have no KVM for ARM emulators and armv7 emulator images are unavailable, so arm ABIs are build-verified rather than executed.

Note: the new Android/Windows CI jobs and the coverage-upload step could not be exercised locally; the local suite (macOS) is green at 88.35%.

@github-code-quality

github-code-quality Bot commented Jul 18, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Swift

Swift / code-coverage/llvm-cov

The overall coverage in the branch is 88%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File e6cd0d1 +/-
Sources/Bluetoo...asurement.swift 100%
Sources/Bluetoo...h/UInt128.swift 96%
Sources/Bluetoo...ainerData.swift 95%
Sources/Bluetoo...toothUUID.swift 95%
Sources/Bluetoo...TDatabase.swift 92%
Sources/Bluetoo...isingData.swift 92%
Sources/Bluetoo.../ATTError.swift 88%
Sources/Bluetoo...ATTClient.swift 85%
Sources/Bluetoo...onnection.swift 81%
Sources/Bluetoo...ATTServer.swift 79%

Updated July 18, 2026 05:16 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@colemancda
colemancda merged commit e69baf6 into master Jul 18, 2026
47 of 49 checks passed
@colemancda
colemancda deleted the feature/code-coverage branch July 18, 2026 05:42
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.

1 participant