// translateCPUProfile parses binary CPU profiling stack trace data // generated by runtime.CPUProfile() into a profile struct. // This is only used for testing. Real conversions stream the // data into the profileBuilder as it becomes available. // // count is the number of records in data. func translateCPUProfile(data []uint64, count int) (*profile.Profile, error) { … } // fmtJSON returns a pretty-printed JSON form for x. // It works reasonably well for printing protocol-buffer // data structures like profile.Profile. func fmtJSON(x any) string { … } func TestConvertCPUProfileNoSamples(t *testing.T) { … } func f1() { … } func f2() { … } // testPCs returns two PCs and two corresponding memory mappings // to use in test profiles. func testPCs(t *testing.T) (addr1, addr2 uint64, map1, map2 *profile.Mapping) { … } func TestConvertCPUProfile(t *testing.T) { … } func checkProfile(t *testing.T, p *profile.Profile, period int64, periodType *profile.ValueType, sampleType []*profile.ValueType, samples []*profile.Sample, defaultSampleType string) { … } var profSelfMapsTests … var profSelfMapsTestsWithDeleted … func TestProcSelfMaps(t *testing.T) { … } // TestMapping checks the mapping section of CPU profiles // has the HasFunctions field set correctly. If all PCs included // in the samples are successfully symbolized, the corresponding // mapping entry (in this test case, only one entry) should have // its HasFunctions field set true. // The test generates a CPU profile that includes PCs from C side // that the runtime can't symbolize. See ./testdata/mappingtest. func TestMapping(t *testing.T) { … } func symbolized(loc *profile.Location) bool { … } // TestFakeMapping tests if at least one mapping exists // (including a fake mapping), and their HasFunctions bits // are set correctly. func TestFakeMapping(t *testing.T) { … } // Make sure the profiler can handle an empty stack trace. // See issue 37967. func TestEmptyStack(t *testing.T) { … }