zstd_test.go 427 B

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