Skip to content

test: DriverSuper 送信系・途絶監視・厳格フレーム探索のテストを追加#484

Open
sksat (sksat) wants to merge 1 commit into
feature/driver-super-unit-testfrom
feature/driver-super-test-followup
Open

test: DriverSuper 送信系・途絶監視・厳格フレーム探索のテストを追加#484
sksat (sksat) wants to merge 1 commit into
feature/driver-super-unit-testfrom
feature/driver-super-test-followup

Conversation

@sksat

Copy link
Copy Markdown
Member

モチベーション

#473 の検証(gcov 計測)で、送信系・受信/テレメ途絶監視・厳格フレーム探索が完全に未テストであることが判明した(HAL の tx 記録や時刻制御の mock フックは用意されていたのに未使用だった)。この follow-up でそれらを埋める。

Note: #473 の stacked PR です。#473 マージ後に base が main へ切り替わります。

追加テスト(18 ケース、合計 93 + DISABLED 1)

送信系(test_send.cpp 新規、10 ケース)

  • CDS_send_general_cmd: HAL に届くフレーム内容・send_status(OK / DISABLE / TX_ERR / VALIDATE_ERR)・カウンタ・送信時刻
  • tx フレーム未設定時の no-op、HAL tx エラー伝播、初期化後の不正再設定が送信時 validation で弾かれること
  • CDS_send_req_tlm_cmd: カウンタ 2 種、req_tlm_cmd_tx_count_after_last_txテレメフレーム確定でリセットされる仕様の検証

受信途絶・テレメ途絶監視(test_frame_analysis.cpp に 5 ケース)

  • 閾値超過で LOST / 閾値内で OK / 監視無効なら経過に関わらず OK(rx は super 単位、tlm fix は stream 単位)

厳格フレーム探索(同 3 ケース)

  • validation でヘッダ必須であること
  • 確定フレーム内部に重なったヘッダ候補を strict モードでは拾い、通常モードではスキップすること

mock の拡張

  • mock_hal_set_tx_result(): HAL tx の返り値注入(TX_ERR 経路用)

カバレッジ

Test plan

  • ローカル: cargo test -p c2a-core-component-driver で 93 ケース pass(32bit ビルド)
  • CI rust job green

🤖 Generated with Claude Code

Follow-up to the DriverSuper unit tests: coverage measurement showed the
tx path, rx/tlm disruption monitoring and strict frame search were
completely untested (the HAL tx recorder and time-advance mock hooks
existed but were never used). Add 18 cases:

- CDS_send_general_cmd / CDS_send_req_tlm_cmd: HAL frame content,
  send_status (OK / DISABLE / TX_ERR / VALIDATE_ERR), counters, tx time,
  and the req_tlm_cmd_tx_count_after_last_tx reset on frame fix
- rx disruption: LOST after threshold, OK within, OK when unmonitored
- tlm disruption (per stream): LOST after threshold, OK with recent fix
- strict frame search: validation requires a header; an overlapped
  header inside a fixed frame is found in strict mode and skipped in
  normal mode

mock_hal gains tx-result injection (mock_hal_set_tx_result) for the
TX_ERR path.

driver_super.c line coverage: 67.8% -> 82.4%; remaining untested code is
trivial getters/disablers and the CCP converters to be split in #483.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

DriverSuper(component_driver/driver_super.c)の未カバー領域だった「送信系」「受信/テレメ途絶監視」「厳格フレーム探索」を、既存のC++/GoogleTestベースの単体テスト基盤に追加してカバレッジを補完するPRです(#473 のフォローアップ)。

Changes:

  • 送信API(CDS_send_general_cmd / CDS_send_req_tlm_cmd)のユニットテストを新規追加
  • 厳格フレーム探索(strict frame search)と、rx/tlm途絶監視のユニットテストを追加
  • HALモックにTX戻り値注入(エラー経路用)のフックを追加し、CMakeに新規テストを登録

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
component_driver/tests/test_send.cpp 送信系のテスト(送信成功/無効stream/no-op/TX_ERR/VALIDATE_ERR/req_tlmカウンタ挙動)を新規追加
component_driver/tests/test_frame_analysis.cpp strict frame search の挙動と rx/tlm 途絶監視のテストケースを追加
component_driver/tests/mocks/mock_hal_handler_registry.h mock_hal_set_tx_result() を公開してTXエラー注入を可能化
component_driver/tests/mocks/mock_hal_handler_registry.c TXエラー注入(返り値差し替え)を実装
component_driver/tests/CMakeLists.txt 新規 test_send ターゲットを追加

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants