]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: reduce delays in finalizer test.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Thu, 19 Dec 2013 20:37:44 +0000 (21:37 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Thu, 19 Dec 2013 20:37:44 +0000 (21:37 +0100)
The runtime tests are executed 4 times in all.bash
and there is currently a 5-second delay each time.

R=golang-dev, minux.ma, khr, bradfitz
CC=golang-dev
https://golang.org/cl/42450043

src/pkg/runtime/mfinal_test.go

index 4a34cd61bd24a810b5a03ca3b50d2ca395df5cf6..ffcffbd4befa0bc5239985e3e2da13ca7d7fb0b4 100644 (file)
@@ -46,13 +46,15 @@ func TestFinalizerType(t *testing.T) {
        }
 
        for _, tt := range finalizerTests {
+               done := make(chan bool, 1)
                go func() {
                        v := new(int)
                        *v = 97531
                        runtime.SetFinalizer(tt.convert(v), tt.finalizer)
                        v = nil
+                       done <- true
                }()
-               time.Sleep(1 * time.Second)
+               <-done
                runtime.GC()
                select {
                case <-ch:
@@ -73,6 +75,7 @@ func TestFinalizerInterfaceBig(t *testing.T) {
                t.Skipf("Skipping on non-amd64 machine")
        }
        ch := make(chan bool)
+       done := make(chan bool, 1)
        go func() {
                v := &bigValue{0xDEADBEEFDEADBEEF, true, "It matters not how strait the gate"}
                old := *v
@@ -87,8 +90,9 @@ func TestFinalizerInterfaceBig(t *testing.T) {
                        close(ch)
                })
                v = nil
+               done <- true
        }()
-       time.Sleep(1 * time.Second)
+       <-done
        runtime.GC()
        select {
        case <-ch: