Skip to content

Commit

Permalink
shorten timeout of infinite loop tests to 2s (from default 30s)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Jan 31, 2018
1 parent 2eb026b commit 8c57d3e
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions fuzz_crashes_test.go
@@ -1,6 +1,9 @@
package markdown

import "testing"
import (
"testing"
"time"
)

// crashes found with go-fuzz

Expand Down Expand Up @@ -28,7 +31,16 @@ func TestCrash1(t *testing.T) {
// TODO: this enters infinite loop
func NoTestInfinite1(t *testing.T) {
test := "[[[[[[\n\t: ]]]]]]\n\n: " + "\n\n:(()"
Parse([]byte(test), nil)
c := make(chan bool, 1)
go func() {
Parse([]byte(test), nil)
c <- true
}()
select {
case <-c:
case <-time.After(2 * time.Second):
t.Fatalf("timed out")
}
}

// TODO: this enters infinite loop
Expand Down Expand Up @@ -67,5 +79,15 @@ runtime.main()
*/
func NoTestInfinite2(t *testing.T) {
test := ":\x00\x00\x00\x01V\n>* \x00\x80e\n\t* \n\n:\t"
Parse([]byte(test), nil)

c := make(chan bool, 1)
go func() {
Parse([]byte(test), nil)
c <- true
}()
select {
case <-c:
case <-time.After(2 * time.Second):
t.Fatalf("timed out")
}
}

0 comments on commit 8c57d3e

Please sign in to comment.