mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
client/pkg/testutil: add shouldSkip func for interestingGoroutines
interestingGoroutines uses so many strings.Contains checks to determine whether to continue, I think it can be avoided. This patch introduces shouldSkip func to do the checks in a loop to make the logic clearer. Signed-off-by: Jes Cok <xigua67damn@gmail.com>
This commit is contained in:
parent
caca5159f2
commit
06b50370fa
@ -130,28 +130,44 @@ func interestingGoroutines() (gs []string) {
|
||||
continue
|
||||
}
|
||||
stack := strings.TrimSpace(sl[1])
|
||||
if stack == "" ||
|
||||
strings.Contains(stack, "sync.(*WaitGroup).Done") ||
|
||||
strings.Contains(stack, "os.(*file).close") ||
|
||||
strings.Contains(stack, "os.(*Process).Release") ||
|
||||
strings.Contains(stack, "created by os/signal.init") ||
|
||||
strings.Contains(stack, "runtime/panic.go") ||
|
||||
strings.Contains(stack, "created by testing.RunTests") ||
|
||||
strings.Contains(stack, "created by testing.runTests") ||
|
||||
strings.Contains(stack, "created by testing.(*T).Run") ||
|
||||
strings.Contains(stack, "testing.Main(") ||
|
||||
strings.Contains(stack, "runtime.goexit") ||
|
||||
strings.Contains(stack, "go.etcd.io/etcd/client/pkg/v3/testutil.interestingGoroutines") ||
|
||||
strings.Contains(stack, "go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop") ||
|
||||
strings.Contains(stack, "github.com/golang/glog.(*loggingT).flushDaemon") ||
|
||||
strings.Contains(stack, "created by runtime.gc") ||
|
||||
strings.Contains(stack, "created by text/template/parse.lex") ||
|
||||
strings.Contains(stack, "runtime.MHeap_Scavenger") ||
|
||||
strings.Contains(stack, "rcrypto/internal/boring.(*PublicKeyRSA).finalize") ||
|
||||
strings.Contains(stack, "net.(*netFD).Close(") ||
|
||||
strings.Contains(stack, "testing.(*T).Run") {
|
||||
if stack == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
shouldSkip := func() bool {
|
||||
var uninterestingMsgs = [...]string{
|
||||
"sync.(*WaitGroup).Done",
|
||||
"os.(*file).close",
|
||||
"os.(*Process).Release",
|
||||
"created by os/signal.init",
|
||||
"runtime/panic.go",
|
||||
"created by testing.RunTests",
|
||||
"created by testing.runTests",
|
||||
"created by testing.(*T).Run",
|
||||
"testing.Main(",
|
||||
"runtime.goexit",
|
||||
"go.etcd.io/etcd/client/pkg/v3/testutil.interestingGoroutines",
|
||||
"go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop",
|
||||
"github.com/golang/glog.(*loggingT).flushDaemon",
|
||||
"created by runtime.gc",
|
||||
"created by text/template/parse.lex",
|
||||
"runtime.MHeap_Scavenger",
|
||||
"rcrypto/internal/boring.(*PublicKeyRSA).finalize",
|
||||
"net.(*netFD).Close(",
|
||||
"testing.(*T).Run",
|
||||
}
|
||||
for _, msg := range uninterestingMsgs {
|
||||
if strings.Contains(stack, msg) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}()
|
||||
|
||||
if shouldSkip {
|
||||
continue
|
||||
}
|
||||
|
||||
gs = append(gs, stack)
|
||||
}
|
||||
sort.Strings(gs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user