aboutsummaryrefslogtreecommitdiffstats
path: root/symbolizer/nm_test.go
blob: 109c1d5bb2e224e720e402c917835d1baf8b9822 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2016 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package symbolizer

import (
	"os"
	"testing"
)

func TestSymbols(t *testing.T) {
	symbols, err := ReadSymbols(os.Args[0])
	if err != nil {
		t.Fatalf("failed to read symbols: %v", err)
	}
	t.Logf("Read %v symbols", len(symbols))
	s, ok := symbols["github.com/google/syzkaller/symbolizer.TestSymbols"]
	if !ok {
		t.Fatalf("symbols don't contain this function")
	}
	if len(s) != 1 {
		t.Fatalf("more than 1 symbol: %v", len(s))
	}
	if s[0].Addr == 0 {
		t.Fatalf("symbol address is 0")
	}
	if s[0].Size <= 10 || s[0].Size > 1<<20 {
		t.Fatalf("bogus symbol size: %v", s[0].Size)
	}
}