mirror of
https://github.com/golang/go
synced 2024-10-02 22:25:08 +00:00
image/jpeg: increase TestLargeImageWithShortData timeout by an order of magnitude
Also dump goroutines on failure. The original bug report in #10413 reported a hang of “several minutes”. An apparently-spurious failure was observed in https://build.golang.org/log/e5ac3ce3fb7d04ec13e5bbfadea8bb5869a4dd1e, with a delay of only 3.64s. Moreover, if the test does fail due to a regression, we will want a goroutine dump to diagnose where it got stuck. The current call to t.Fatalf does not produce such a dump, so is not nearly as useful if the failure only occasionally reproduces. Updates #10413. Change-Id: I6ab9d112f14f438a0c54e02ec95934627acdc64b Reviewed-on: https://go-review.googlesource.com/c/go/+/408355 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
27794c4d4a
commit
85486bcccb
|
@ -13,6 +13,7 @@ import (
|
|||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -247,18 +248,16 @@ func TestLargeImageWithShortData(t *testing.T) {
|
|||
"\x20\x36\x9f\x78\x64\x75\xe6\xab\x7d\xb2\xde\x29\x70\xd3\x20\x27" +
|
||||
"\xde\xaf\xa4\xf0\xca\x9f\x24\xa8\xdf\x46\xa8\x24\x84\x96\xe3\x77" +
|
||||
"\xf9\x2e\xe0\x0a\x62\x7f\xdf\xd9"
|
||||
c := make(chan error, 1)
|
||||
go func() {
|
||||
_, err := Decode(strings.NewReader(input))
|
||||
c <- err
|
||||
}()
|
||||
select {
|
||||
case err := <-c:
|
||||
if err == nil {
|
||||
t.Fatalf("got nil error, want non-nil")
|
||||
}
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Fatalf("timed out")
|
||||
|
||||
timer := time.AfterFunc(30*time.Second, func() {
|
||||
debug.SetTraceback("all")
|
||||
panic("TestLargeImageWithShortData stuck in Decode")
|
||||
})
|
||||
defer timer.Stop()
|
||||
|
||||
_, err := Decode(strings.NewReader(input))
|
||||
if err == nil {
|
||||
t.Fatalf("got nil error, want non-nil")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue