MCPcopy
hub / github.com/grpc/grpc-go / TestCheckRegisterIgnore

Function TestCheckRegisterIgnore

internal/leakcheck/leakcheck_test.go:71–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestCheckRegisterIgnore(t *testing.T) {
72 RegisterIgnoreGoroutine("ignoredTestingLeak")
73 go ignoredTestingLeak(3 * time.Second)
74 const leakCount = 3
75 ch := make(chan struct{})
76 for i := 0; i < leakCount; i++ {
77 go func() { <-ch }()
78 }
79 if leaked := interestingGoroutines(); len(leaked) != leakCount {
80 t.Errorf("interestingGoroutines() = %d, want length %d", len(leaked), leakCount)
81 }
82 e := &testLogger{}
83 ctx, cancel := context.WithTimeout(context.Background(), time.Second)
84 defer cancel()
85 if CheckGoroutines(ctx, e); e.errorCount < leakCount {
86 t.Errorf("CheckGoroutines() = %d, want count %d", e.errorCount, leakCount)
87 t.Logf("leaked goroutines:\n%v", strings.Join(e.errors, "\n"))
88 }
89 close(ch)
90 ctx, cancel = context.WithTimeout(context.Background(), 3*time.Second)
91 defer cancel()
92 CheckGoroutines(ctx, t)
93}
94
95// TestTrackTimers verifies that only leaked timers are reported and expired,
96// stopped timers are ignored.

Callers

nothing calls this directly

Calls 7

RegisterIgnoreGoroutineFunction · 0.85
ignoredTestingLeakFunction · 0.85
interestingGoroutinesFunction · 0.85
CheckGoroutinesFunction · 0.85
JoinMethod · 0.80
ErrorfMethod · 0.65
LogfMethod · 0.65

Tested by

no test coverage detected