MCPcopy
hub / github.com/uber-go/goleak / TestAll

Function TestAll

internal/stack/stacks_test.go:42–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestAll(t *testing.T) {
43 // We use a global channel so that the function below does not
44 // receive any arguments, so we can test that parseFirstFunc works
45 // regardless of arguments on the stack.
46 _allDone = make(chan struct{})
47 defer close(_allDone)
48
49 for i := 0; i < 5; i++ {
50 go waitForDone()
51 }
52
53 cur := Current()
54 got := All()
55
56 // Retry until the background stacks are not runnable/running.
57 for {
58 if !isBackgroundRunning(cur, got) {
59 break
60 }
61 runtime.Gosched()
62 got = All()
63 }
64
65 // We have exactly 7 gorotuines:
66 // "main" goroutine
67 // test goroutine
68 // 5 goroutines started above.
69 require.Len(t, got, 7)
70 sort.Sort(byGoroutineID(got))
71
72 assert.Contains(t, got[0].Full(), "testing.(*T).Run")
73 assert.Contains(t, got[0].allFunctions, "testing.(*T).Run")
74
75 assert.Contains(t, got[1].Full(), "TestAll")
76 assert.Contains(t, got[1].allFunctions, "go.uber.org/goleak/internal/stack.TestAll")
77
78 for i := 0; i < 5; i++ {
79 assert.Contains(t, got[2+i].Full(), "stack.waitForDone")
80 }
81}
82
83func TestCurrent(t *testing.T) {
84 const pkgPrefix = "go.uber.org/goleak/internal/stack"

Callers

nothing calls this directly

Calls 7

waitForDoneFunction · 0.85
CurrentFunction · 0.85
AllFunction · 0.85
byGoroutineIDTypeAlias · 0.85
LenMethod · 0.80
FullMethod · 0.80
isBackgroundRunningFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…