(t *testing.T)
| 961 | } |
| 962 | |
| 963 | func TestEmptyMappingMerge(t *testing.T) { |
| 964 | // Aggregate a profile with itself and once again with a factor of |
| 965 | // -2. Should end up with an empty profile (all samples for a |
| 966 | // location should add up to 0). |
| 967 | |
| 968 | prof1 := testProfile1.Copy() |
| 969 | prof2 := testProfile1NoMapping.Copy() |
| 970 | p1, err := Merge([]*Profile{prof2, prof1}) |
| 971 | if err != nil { |
| 972 | t.Errorf("merge error: %v", err) |
| 973 | } |
| 974 | prof2.Scale(-2) |
| 975 | prof, err := Merge([]*Profile{p1, prof2}) |
| 976 | if err != nil { |
| 977 | t.Errorf("merge error: %v", err) |
| 978 | } |
| 979 | |
| 980 | // Use aggregation to merge locations at function granularity. |
| 981 | if err := prof.Aggregate(false, true, false, false, false, false); err != nil { |
| 982 | t.Errorf("aggregating after merge: %v", err) |
| 983 | } |
| 984 | |
| 985 | samples := make(map[string]int64) |
| 986 | for _, s := range prof.Sample { |
| 987 | tb := locationHash(s) |
| 988 | samples[tb] = samples[tb] + s.Value[0] |
| 989 | } |
| 990 | for s, v := range samples { |
| 991 | if v != 0 { |
| 992 | t.Errorf("nonzero value for sample %s: %d", s, v) |
| 993 | } |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | func TestNormalizeBySameProfile(t *testing.T) { |
| 998 | pb := testProfile1.Copy() |
nothing calls this directly
no test coverage detected
searching dependent graphs…