]> Cypherpunks repositories - gostls13.git/commit
runtime/pprof: try to use real stack in TestTryAdd
authorMichael Pratt <mpratt@google.com>
Tue, 7 Apr 2020 16:12:44 +0000 (12:12 -0400)
committerMichael Pratt <mpratt@google.com>
Mon, 13 Apr 2020 20:37:04 +0000 (20:37 +0000)
commit796475ce1f7c4be3b7171cacea225cc313083c6d
treec6098adfc9b0dc7af7f2023c887e81e2a4fd9a91
parent6f3a9515b6bb879472f3b3443a052b07ed11ee2f
runtime/pprof: try to use real stack in TestTryAdd

TestTryAdd is particularly brittle because it tests some real cases by
constructing fake sample stack frames. If those frames don't correctly
represent what the runtime would generate then they may fail to catch
regressions.

Instead, call runtime.Callers at the bottom of real function calls to
generate real frames as a base for truncation, etc in tests. Several of
these tests still have to fake parts of the frames to test the right
thing, but this is a bit less fragile.

This change is equivalent to the original
0dfb0513ec6a0e97db166bd91a2dc0a1ceb154f7 (golang.org/cl/227484), except
that the test skips if the test functions aren't inline (e.g., noopt
builders).

Change-Id: Ie9e32b5660cfe28a924f9cfcddcd887ea2effd66
Reviewed-on: https://go-review.googlesource.com/c/go/+/227922
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/runtime/pprof/pprof_test.go