]> Cypherpunks repositories - gostls13.git/commitdiff
image/jpeg: increase TestLargeImageWithShortData timeout by an order of magnitude
authorBryan C. Mills <bcmills@google.com>
Wed, 25 May 2022 15:09:56 +0000 (11:09 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 12 Jul 2022 21:23:11 +0000 (21:23 +0000)
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>

src/image/jpeg/reader_test.go

index bf07fadede5390a19a19e03206fd9b0e0fba9d5a..6fdb6c44490319f0a482943ba9507d1c1fa99801 100644 (file)
@@ -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")
        }
 }