Add a fault-injection test for the signal transport drain

Offen
#517 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
c, macos

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
C
Sterne
287
Forks
33
Ø Merge
2 T. 17 Std.
Gemergte PRs (30 T.)
18

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus sysprog21/elfuse

Alle Issues in sysprog21/elfuse

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.