From 43e17fc6488ac088b51758a81dbc039f7c158f6a Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 18 Nov 2026 21:47:59 +0100 Subject: tests/fsck: check the number of corrupt files Only checking the exit code does not catch fsck missing some of the corruptions. TestBrokenFsV14 now expects 15 corrupt files (the old FUSE-based fsck found only 12, missing incomplete_file_1..3), and TestMalleableBase64 expects 3. Co-Authored-By: Claude Opus 5.5 --- tests/fsck/fsck_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/fsck') diff --git a/tests/fsck/fsck_test.go b/tests/fsck/fsck_test.go index de49819..2372c2d 100644 --- a/tests/fsck/fsck_test.go +++ b/tests/fsck/fsck_test.go @@ -2,6 +2,7 @@ package fsck import ( "encoding/base64" + "fmt" "os" "os/exec" "runtime" @@ -47,6 +48,17 @@ func TestBrokenFsV14(t *testing.T) { if code != exitcodes.FsckErrors { t.Errorf("wrong exit code, have=%d want=%d", code, exitcodes.FsckErrors) } + checkSummary(t, out, 15) +} + +// checkSummary verifies that the fsck output reports exactly `corrupt` +// corrupt files and no skipped files. +func checkSummary(t *testing.T, out string, corrupt int) { + t.Helper() + want := fmt.Sprintf("fsck summary: %d corrupt files, 0 files skipped", corrupt) + if !strings.Contains(out, want) { + t.Errorf("summary line %q not found in output", want) + } } func TestMalleableBase64(t *testing.T) { @@ -69,6 +81,7 @@ func TestMalleableBase64(t *testing.T) { if code != exitcodes.FsckErrors { t.Errorf("wrong exit code, have=%d want=%d", code, exitcodes.FsckErrors) } + checkSummary(t, out, 3) } func TestExampleFses(t *testing.T) { -- cgit v1.2.3