]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: limit TestCgoCCodeSIGPROF test to 1 second
authorIan Lance Taylor <iant@golang.org>
Fri, 11 Mar 2016 06:01:41 +0000 (22:01 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 11 Mar 2016 06:43:01 +0000 (06:43 +0000)
Still fails about 20% of the time on my laptop.

Fixes #14766.

Change-Id: I169ab728c6022dceeb91188f5ad466ed6413c062
Reviewed-on: https://go-review.googlesource.com/20590
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/testdata/testprogcgo/aprof.go

index cf52107a30bfb41e019bb779a9710dd23b141e98..b4b71f28619f4260520ceb159b3f10556fa8d685 100644 (file)
@@ -17,6 +17,7 @@ import (
        "bytes"
        "fmt"
        "runtime/pprof"
+       "time"
 )
 
 func init() {
@@ -31,7 +32,13 @@ func CgoCCodeSIGPROF() {
        go func() {
                for {
                        <-c
+                       start := time.Now()
                        for i := 0; i < 1e7; i++ {
+                               if i%1000 == 0 {
+                                       if time.Since(start) > time.Second {
+                                               break
+                                       }
+                               }
                                C.GoNop()
                        }
                        c <- true