Add a fault-injection test for the signal transport drain

オープン
#517 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, macos

調査の方向性

Start with drain_signal_transport and transport_read_chunk in src/syscall/proc.c, then trace preempt_thread_main and drain_after_wait to understand retries and warning behavior. Add a host unit test using a scratch transport file and fault hooks for the listed host calls. Verify retry state, record handling, warning frequency, failed truncation, and the first-flock size bound under concurrent appends.

索引モデルが issue の本文から書いたものです。

説明

Problem

drain_signal_transport in src/syscall/proc.c has failure paths that no test reaches: open failing with an error other than ENOENT, the flock, fstat or pread in transport_read_chunk failing, and a failed ftruncate. On a failure the drain keeps the records, sets transport_retry, and the SIGALRM tick in preempt_thread_main retries it. Since #505, sys_wait4 and sys_waitid also retry a failed drain once inline (drain_after_wait) before they return, and the warning is logged once per run of failures (transport_read_failing). The size bound added in #505 (a drain stops at the file size it saw under its first flock) is also only checked by reading: no test keeps a sender appending while a drain runs.

A guest test cannot make these host calls fail, so a regression on any of these paths would pass make check and make test-matrix.

Proposal

Add a host unit test that drives the drain against a scratch transport file with the host calls it makes wrapped behind a small fault hook (fail the next N calls of open, flock, fstat, pread or ftruncate with a chosen errno). It would check that:

  • no record is lost or handled twice across a failed and a retried drain;
  • transport_retry is set after each kind of failure and cleared by a drain that succeeds;
  • the warning is logged once per run of failures;
  • a failed truncate leaves the offset at the end, so the next drain does not handle the same records again;
  • a drain ends at the size it saw under its first flock while another thread keeps appending, and the next drain picks up the rest.

Alternatives

A guest test under a second elfuse build that injects the failures. That build would not run in CI.

Origin

Follow-up from #505 (https://github.com/sysprog21/elfuse/pull/505#discussion_r4542048059). Related: #507.

主要言語
C
スター
287
フォーク
33
平均マージ
2日 17時間
マージ済み PR(30日)
18

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sysprog21/elfuse のほかの issue

sysprog21/elfuse の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。