diff options
| author | Jakob Unterwurzacher | 2026-11-18 21:47:59 +0100 |
|---|---|---|
| committer | Jakob Unterwurzacher | 2026-11-19 21:16:19 +0100 |
| commit | 43e17fc6488ac088b51758a81dbc039f7c158f6a (patch) | |
| tree | a2c6eb5ddad6bd4a8d4619979d965e7c33676a22 /tests | |
| parent | 674559a0be5f76002eae1639286f2ad89b4d4414 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fsck/fsck_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
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) { |
