MCPcopy Create free account
hub / github.com/google/pprof / TestProfileCopier

Function TestProfileCopier

internal/driver/driver_test.go:1593–1626  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1591}
1592
1593func TestProfileCopier(t *testing.T) {
1594 type testCase struct {
1595 name string
1596 prof *profile.Profile
1597 }
1598 for _, c := range []testCase{
1599 {"cpu", cpuProfile()},
1600 {"heap", heapProfile()},
1601 {"contention", contentionProfile()},
1602 {"symbolz", symzProfile()},
1603 {"long_name_funcs", longNameFuncsProfile()},
1604 {"large", largeProfile(t)},
1605 } {
1606 t.Run(c.name, func(t *testing.T) {
1607 copier := makeProfileCopier(c.prof)
1608
1609 // Muck with one copy to check that fresh copies are unaffected
1610 tmp := copier.newCopy()
1611 tmp.Sample = tmp.Sample[:0]
1612
1613 // Get new copy and check it is same as the original.
1614 want := c.prof.String()
1615 got := copier.newCopy().String()
1616 if got != want {
1617 t.Errorf("New copy is not same as original profile")
1618 diff, err := proftest.Diff([]byte(want), []byte(got))
1619 if err != nil {
1620 t.Fatalf("Diff: %v", err)
1621 }
1622 t.Logf("Diff:\n%s\n", string(diff))
1623 }
1624 })
1625 }
1626}
1627
1628type mockObjTool struct{}
1629

Callers

nothing calls this directly

Calls 10

DiffFunction · 0.92
heapProfileFunction · 0.85
contentionProfileFunction · 0.85
symzProfileFunction · 0.85
longNameFuncsProfileFunction · 0.85
largeProfileFunction · 0.85
makeProfileCopierFunction · 0.85
newCopyMethod · 0.80
cpuProfileFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…