(t *testing.T)
| 1591 | } |
| 1592 | |
| 1593 | func 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 | |
| 1628 | type mockObjTool struct{} |
| 1629 |
nothing calls this directly
no test coverage detected
searching dependent graphs…