package proftest
import "github.com/google/pprof/internal/proftest"
Package proftest provides some utility routines to test other packages related to profiles.
Index ¶
- func Diff(b1, b2 []byte) (data []byte, err error)
- func EncodeJSON(x interface{}) []byte
- func LargeProfile(tb testing.TB) []byte
- type TestUI
Functions ¶
func Diff ¶
Diff compares two byte arrays using the diff tool to highlight the differences. It is meant for testing purposes to display the differences between expected and actual output.
func EncodeJSON ¶
func EncodeJSON(x interface{}) []byte
EncodeJSON encodes a value into a byte array. This is intended for testing purposes.
func LargeProfile ¶
LargeProfile returns a large profile that may be useful in benchmarks.
If the flag --large_profile is set, the contents of the file named by the flag are returned. Otherwise an embedded profile (~1.2MB) for a synthetic program is returned.
Types ¶
type TestUI ¶
type TestUI struct {
T testing.TB
Ignore int
AllowRx string
NumAllowRxMatches int
Input []string
// contains filtered or unexported fields
}
TestUI implements the plugin.UI interface, triggering test failures if more than Ignore errors not matching AllowRx are printed. Also tracks the number of times the error matches AllowRx in NumAllowRxMatches.
func (*TestUI) IsTerminal ¶
IsTerminal indicates if the UI is an interactive terminal.
func (*TestUI) Print ¶
func (ui *TestUI) Print(args ...interface{})
Print messages are discarded by the test UI.
func (*TestUI) PrintErr ¶
func (ui *TestUI) PrintErr(args ...interface{})
PrintErr messages may trigger an error failure. A fixed number of error messages are permitted when appropriate.
func (*TestUI) ReadLine ¶
ReadLine returns no input, as no input is expected during testing.
func (*TestUI) SetAutoComplete ¶
SetAutoComplete is not supported by the test UI.
func (*TestUI) WantBrowser ¶
WantBrowser indicates whether a browser should be opened with the -http option.
Source Files ¶
- Version
- v0.0.0-20250607225305-033d6d78b36a (latest)
- Published
- Jun 7, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 10 months ago –
Tools for package owners.