From 85486bcccb506514d67034e39f3ed588b5900f1c Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 25 May 2022 11:09:56 -0400 Subject: [PATCH] image/jpeg: increase TestLargeImageWithShortData timeout by an order of magnitude MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Yuval Pavel Zholkover Reviewed-by: Robert Findley Auto-Submit: Bryan Mills TryBot-Result: Gopher Robot --- src/image/jpeg/reader_test.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/image/jpeg/reader_test.go b/src/image/jpeg/reader_test.go index bf07fadede..6fdb6c4449 100644 --- a/src/image/jpeg/reader_test.go +++ b/src/image/jpeg/reader_test.go @@ -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") } } -- 2.48.1