diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:30:08 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:30:08 +0200 |
| commit | 01b0cfe2055e23cf03870d9a9f60648037b4005e (patch) | |
| tree | de9b82c31eec73b86f40e68c91489c3efd877da5 /internal/extract/tools_test.go | |
| parent | 11a2c57c6eeaff0ef963fc6f8b74caa27b147bdb (diff) | |
| download | krino-01b0cfe2055e23cf03870d9a9f60648037b4005e.tar.gz krino-01b0cfe2055e23cf03870d9a9f60648037b4005e.zip | |
tests run on OpenBSD; a tool's error message survives one large write; lock pids beyond 32 bits name no process
Diffstat (limited to 'internal/extract/tools_test.go')
| -rw-r--r-- | internal/extract/tools_test.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/extract/tools_test.go b/internal/extract/tools_test.go index 756903d..5af80fb 100644 --- a/internal/extract/tools_test.go +++ b/internal/extract/tools_test.go @@ -212,13 +212,17 @@ func TestCallerCancelReturnsPromptly(t *testing.T) { // it at all must not cost unbounded memory. func TestStderrFloodBounded(t *testing.T) { bin := t.TempDir() - fakeTool(t, bin, "pdftotext", `head -c 10000000 /dev/zero | tr '\0' x >&2; exit 1`) + // dd, not head -c: OpenBSD's head has no -c. + fakeTool(t, bin, "pdftotext", `dd if=/dev/zero bs=10000 count=1000 2>/dev/null | tr '\0' x >&2; exit 1`) e := newWithPath(bin) _, err := e.run(context.Background(), maxToolOutput, "pdftotext") if err == nil { t.Fatal("stderr flood: want an error") } + if !strings.Contains(err.Error(), strings.Repeat("x", 100)) { + t.Fatalf("stderr flood: the message %q does not come from the flood", err) + } if max := len("pdftotext failed: ") + 200; len(err.Error()) > max { t.Errorf("stderr flood: message is %d bytes, want <=%d", len(err.Error()), max) } @@ -231,7 +235,7 @@ func TestStderrFloodBounded(t *testing.T) { // result. func TestMaxReadCapsToolOutput(t *testing.T) { bin := t.TempDir() - fakeTool(t, bin, "pdftotext", `yes aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | head -c 200000`) + fakeTool(t, bin, "pdftotext", `dd if=/dev/zero bs=1000 count=200 2>/dev/null | tr '\0' a`) e := newWithPath(bin) if _, err := text(t, e, file(t, "small.pdf", []byte("%PDF-1.4")), 1024); !errors.Is(err, ErrTooLarge) { t.Fatalf("got %v, want ErrTooLarge (max-read 1024 should have capped a 200000-byte tool output)", err) |
