symbolizer: use fixed prebuilt binary in test

With commit 94c95d3e52ed55ef57e60ace559b684e4d5ebcbf
go command strips symbols from empheral test binaries.
Thus the test started failing.
Use a simple fixed binary in the test.
This commit is contained in:
Dmitry Vyukov 2017-05-26 14:01:56 +02:00
parent 0fcd5fd3dd
commit 9833d36f8b
2 changed files with 31 additions and 13 deletions

View File

@ -4,27 +4,45 @@
package symbolizer
import (
"os"
"testing"
)
func TestSymbols(t *testing.T) {
symbols, err := ReadSymbols(os.Args[0])
symbols, err := ReadSymbols("testdata/nm.test.out")
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(symbols) != 5 {
t.Fatalf("got %v symbols, want 5", len(symbols))
}
if len(s) != 1 {
t.Fatalf("more than 1 symbol: %v", len(s))
{
s := symbols["barfoo"]
if len(s) != 1 {
t.Fatalf("got %v barfoo symbols, want 1", len(s))
}
if s[0].Addr != 0x400507 {
t.Fatalf("bad barfoo address: 0x%x", s[0].Addr)
}
if s[0].Size != 0x30 {
t.Fatalf("bad barfoo size: 0x%x", s[0].Size)
}
}
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)
{
s := symbols["foobar"]
if len(s) != 2 {
t.Fatalf("got %v foobar symbols, want 2", len(s))
}
if s[0].Addr != 0x4004ed {
t.Fatalf("bad foobar[0] address: 0x%x", s[0].Addr)
}
if s[0].Size != 0x10 {
t.Fatalf("bad foobar[0] size: 0x%x", s[0].Size)
}
if s[1].Addr != 0x4004fa {
t.Fatalf("bad foobar[1] address: 0x%x", s[1].Addr)
}
if s[1].Size != 0x10 {
t.Fatalf("bad foobar[1] size: 0x%x", s[1].Size)
}
}
}

BIN
symbolizer/testdata/nm.test.out vendored Executable file

Binary file not shown.