aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/proc_test.go')
-rw-r--r--src/runtime/proc_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/runtime/proc_test.go b/src/runtime/proc_test.go
index 30798f723d..f3e90bcbd7 100644
--- a/src/runtime/proc_test.go
+++ b/src/runtime/proc_test.go
@@ -9,6 +9,7 @@ import (
"net"
"runtime"
"runtime/debug"
+ "strings"
"sync"
"sync/atomic"
"syscall"
@@ -336,6 +337,23 @@ func TestGCFairness(t *testing.T) {
}
}
+func TestNumGoroutine(t *testing.T) {
+ output := runTestProg(t, "testprog", "NumGoroutine")
+ want := "1\n"
+ if output != want {
+ t.Fatalf("want %q, got %q", want, output)
+ }
+
+ buf := make([]byte, 1<<20)
+ buf = buf[:runtime.Stack(buf, true)]
+
+ n := runtime.NumGoroutine()
+
+ if nstk := strings.Count(string(buf), "goroutine "); n != nstk {
+ t.Fatalf("NumGoroutine=%d, but found %d goroutines in stack dump", n, nstk)
+ }
+}
+
func TestPingPongHog(t *testing.T) {
if testing.Short() {
t.Skip("skipping in -short mode")