runtime/pprof: remove arbitrary sleeps in TestBlockProfile
runtime/pprof: remove arbitrary sleeps in TestBlockProfile

The "block" helpers in TestBlockProfile previously slept for an
arbitrary duration and assumed that that duration was long enough for
the parent goroutine to have registered as blocking. However —
especially on slow or overloaded builders — the current arbitrary
duration is sometimes not quite long enough.

Rather than increasing the duration to a different arbitrary value
(which would make the test slower but not actually eliminate the
possibility of flakes!), we can use the runtime's own accounting to
detect when the goroutine is actually blocked: we obtain a goroutine
dump from the runtime, and assume that blocking has been registered in
the profile only if the runtime shows the test goroutine in the
appropriate blocked state.

That not only makes the test more reliable, but also makes it
significantly lower-latency when run on a fast machine.

Fixes #6999
Fixes #37844

Change-Id: I465ed2afd406fd2b621419e1f06925f283525f25
Reviewed-on: https://go-review.googlesource.com/c/go/+/384534
Trust: Bryan Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
Trust: Benny Siegert <05f4aee36fd25d0de2a07789fd6e73398db492cc@gmail.com>
Run-TryBot: Bryan Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
TryBot-Result: Gopher Robot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Ian Lance Taylor <87e9c6d529889242b7e184afb632328636553ab4@golang.org>

nawawi/go,CAFxX/go,CAFxX/go,nawawi/go,golang/go,CAFxX/go,cloudflare/go,CAFxX/go,CAFxX/go,golang/go,cloudflare/go,cloudflare/go,CAFxX/go,nawawi/go,nawawi/go,cloudflare/go,nawawi/go,golang/go,cloudflare/go,nawawi/go,golang/go,golang/go,golang/go,CAFxX/go,nawawi/go,cloudflare/go,cloudflare/go,golang/go,nawawi/go,cloudflare/go,CAFxX/go,golang/go