1package zstd 2 3import ( 4 "fmt" 5 "os" 6 "runtime" 7 "runtime/pprof" 8 "testing" 9 "time" 10) 11 12func TestMain(m *testing.M) { 13 ec := m.Run() 14 if ec == 0 && runtime.NumGoroutine() > 1 { 15 n := 0 16 for n < 60 { 17 n++ 18 time.Sleep(time.Second) 19 if runtime.NumGoroutine() == 1 { 20 os.Exit(0) 21 } 22 } 23 fmt.Println("goroutines:", runtime.NumGoroutine()) 24 pprof.Lookup("goroutine").WriteTo(os.Stderr, 1) 25 os.Exit(1) 26 } 27 os.Exit(ec) 28} 29