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

Function TestFindSymbols

internal/binutils/disasm_test.go:26–72  ·  view source on GitHub ↗

TestFindSymbols tests the FindSymbols routine using a hardcoded nm output.

(t *testing.T)

Source from the content-addressed store, hash-verified

24
25// TestFindSymbols tests the FindSymbols routine using a hardcoded nm output.
26func TestFindSymbols(t *testing.T) {
27 type testcase struct {
28 query, syms string
29 want []plugin.Sym
30 }
31
32 testsyms := `0000000000001000 t lineA001
330000000000001000 t lineA002
340000000000001000 t line1000
350000000000002000 t line200A
360000000000002000 t line2000
370000000000002000 t line200B
380000000000003000 t line3000
390000000000003000 t _ZNK4DumbclEPKc
400000000000003000 t lineB00C
410000000000003000 t line300D
420000000000004000 t _the_end
43 `
44 testcases := []testcase{
45 {
46 "line.*[AC]",
47 testsyms,
48 []plugin.Sym{
49 {Name: []string{"lineA001"}, File: "object.o", Start: 0x1000, End: 0x1FFF},
50 {Name: []string{"line200A"}, File: "object.o", Start: 0x2000, End: 0x2FFF},
51 {Name: []string{"lineB00C"}, File: "object.o", Start: 0x3000, End: 0x3FFF},
52 },
53 },
54 {
55 "Dumb::operator",
56 testsyms,
57 []plugin.Sym{
58 {Name: []string{"Dumb::operator()(char const*) const"}, File: "object.o", Start: 0x3000, End: 0x3FFF},
59 },
60 },
61 }
62
63 for _, tc := range testcases {
64 syms, err := findSymbols([]byte(tc.syms), "object.o", regexp.MustCompile(tc.query), 0)
65 if err != nil {
66 t.Fatalf("%q: findSymbols: %v", tc.query, err)
67 }
68 if err := checkSymbol(syms, tc.want); err != nil {
69 t.Errorf("%q: %v", tc.query, err)
70 }
71 }
72}
73
74func checkSymbol(got []*plugin.Sym, want []plugin.Sym) error {
75 if len(got) != len(want) {

Callers

nothing calls this directly

Calls 2

findSymbolsFunction · 0.85
checkSymbolFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…