forked from quic-go/quic-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quic_suite_test.go
51 lines (41 loc) · 981 Bytes
/
quic_suite_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package quic
import (
"bytes"
"io"
"log"
"runtime/pprof"
"strings"
"sync"
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
)
func TestQuicGo(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "QUIC Suite")
}
var mockCtrl *gomock.Controller
var _ = BeforeEach(func() {
mockCtrl = gomock.NewController(GinkgoT())
// reset the sync.Once
connMuxerOnce = *new(sync.Once)
})
var _ = BeforeSuite(func() {
log.SetOutput(io.Discard)
})
func areServersRunning() bool {
var b bytes.Buffer
pprof.Lookup("goroutine").WriteTo(&b, 1)
return strings.Contains(b.String(), "quic-go.(*baseServer).run")
}
func areTransportsRunning() bool {
var b bytes.Buffer
pprof.Lookup("goroutine").WriteTo(&b, 1)
return strings.Contains(b.String(), "quic-go.(*Transport).listen")
}
var _ = AfterEach(func() {
mockCtrl.Finish()
Eventually(areServersRunning).Should(BeFalse())
Eventually(areTransportsRunning()).Should(BeFalse())
})