| index f68344a40..ec256989b 100644 |
| --- a/internal/demobuild/transfer_test.go |
| +++ b/internal/demobuild/transfer_test.go |
| @@ -5,6 +5,7 @@ package demobuild |
| import ( |
| "bytes" |
| "context" |
| + "debug/elf" |
| "encoding/binary" |
| "encoding/json" |
| "errors" |
| @@ -289,22 +290,31 @@ func panicked(f func()) (p any) { |
| return nil |
| } |
| |
| -// A panic while root validates an output (here a real one, inside |
| -// debug/elf, from the build's own bytes) unwinds through Run. net/http |
| -// recovers it and the service lives on, so the turn must come back with |
| -// the unwinding or every later build waits out its deadline. |
| -func TestDemoBuildOutputTransferValidationPanicReleases(t *testing.T) { |
| +// A hostile output that panics debug/elf (a real panic, from the build's |
| +// own bytes) is a failed build like any other: Run answers ErrBuild and |
| +// hands the turn back, and nothing unwinds into net/http to write a stack |
| +// trace per anonymous build into root's log. |
| +func TestDemoBuildOutputPanickingELFIsErrBuild(t *testing.T) { |
| + if panicked(func() { elf.NewFile(bytes.NewReader(shstrndxPanicELF())) }) == nil { |
| + t.Fatal("the fixture no longer panics debug/elf; this test needs another panic source") |
| + } |
| + if _, err := ValidateOutput(bytes.NewReader(shstrndxPanicELF())); !errors.Is(err, ErrBuild) { |
| + t.Fatalf("ValidateOutput: err=%v", err) |
| + } |
| ctx, dir := finishedBuild(t, shstrndxPanicELF()) |
| - p := panicked(func() { |
| - out, err := Run(ctx, dir, testLock(t)) |
| + var err error |
| + if p := panicked(func() { |
| + var out BuildOutput |
| + out, err = Run(ctx, dir, testLock(t)) |
| out.Release() |
| - t.Logf("no panic: err=%v", err) |
| - }) |
| - if p == nil { |
| - t.Fatal("the fixture no longer panics debug/elf; this test needs another panic source") |
| + }); p != nil { |
| + t.Fatalf("validation panicked out of Run: %v", p) |
| + } |
| + if !errors.Is(err, ErrBuild) { |
| + t.Fatalf("Run: err=%v", err) |
| } |
| if !transferFree(t) { |
| - t.Fatalf("a validation panic (%v) kept the output turn", p) |
| + t.Fatal("a refused output kept the output turn") |
| } |
| } |
| |