1
0
mirror of https://github.com/golang/go synced 2024-09-30 03:34:51 -06:00

debug/elf: run relocation tests in parallel

Also don't restart DWARF reading from beginning when we are testing
multiple entries.

Also reformat relocationTests slice to use indexed literals.

Change-Id: Ia5f17214483394d0ef033be516df61f0bdc521b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/251637
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This commit is contained in:
Ian Lance Taylor 2020-08-29 14:11:18 -07:00
parent 4fc3896e79
commit ba0fab3cb7

View File

@ -304,7 +304,8 @@ var relocationTests = []relocationTest{
{
"testdata/go-relocation-test-gcc441-x86-64.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -317,13 +318,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: uint64(0x6), Class: dwarf.ClassAddress},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc441-x86.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -336,13 +339,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: uint64(0x5), Class: dwarf.ClassAddress},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc424-x86-64.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -355,13 +360,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: uint64(0x6), Class: dwarf.ClassAddress},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc482-aarch64.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -374,13 +381,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: int64(0x24), Class: dwarf.ClassConstant},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc492-arm.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -393,13 +402,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: int64(0x28), Class: dwarf.ClassConstant},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-clang-arm.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -412,13 +423,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrLowpc, Val: uint64(0x0), Class: dwarf.ClassAddress},
{Attr: dwarf.AttrHighpc, Val: int64(48), Class: dwarf.ClassConstant},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc5-ppc.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -431,13 +444,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: int64(0x44), Class: dwarf.ClassConstant},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc482-ppc64le.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -450,13 +465,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: uint64(0x24), Class: dwarf.ClassAddress},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc492-mips64.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -469,13 +486,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: int64(100), Class: dwarf.ClassConstant},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc531-s390x.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -488,13 +507,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: int64(58), Class: dwarf.ClassConstant},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc620-sparc64.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -507,13 +528,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: int64(0x2c), Class: dwarf.ClassConstant},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc492-mipsle.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -526,13 +549,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: int64(0x58), Class: dwarf.ClassConstant},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc540-mips.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -545,13 +570,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: uint64(0x5c), Class: dwarf.ClassAddress},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc493-mips64le.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -564,13 +591,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: int64(100), Class: dwarf.ClassConstant},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-gcc720-riscv64.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -583,13 +612,15 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrHighpc, Val: uint64(0x2c), Class: dwarf.ClassAddress},
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
},
}},
},
},
},
},
{
"testdata/go-relocation-test-clang-x86.obj",
[]relocationTestEntry{
{0, &dwarf.Entry{
{
entry: &dwarf.Entry{
Offset: 0xb,
Tag: dwarf.TagCompileUnit,
Children: true,
@ -600,13 +631,16 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
{Attr: dwarf.AttrCompDir, Val: "/tmp", Class: dwarf.ClassString},
},
}},
},
},
},
},
{
"testdata/gcc-amd64-openbsd-debug-with-rela.obj",
[]relocationTestEntry{
{203, &dwarf.Entry{
{
entryNumber: 203,
entry: &dwarf.Entry{
Offset: 0xc62,
Tag: dwarf.TagMember,
Children: false,
@ -617,8 +651,11 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrType, Val: dwarf.Offset(0xb7f), Class: dwarf.ClassReference},
{Attr: dwarf.AttrDataMemberLoc, Val: []byte{0x23, 0x0}, Class: dwarf.ClassExprLoc},
},
}},
{204, &dwarf.Entry{
},
},
{
entryNumber: 204,
entry: &dwarf.Entry{
Offset: 0xc70,
Tag: dwarf.TagMember,
Children: false,
@ -629,42 +666,47 @@ var relocationTests = []relocationTest{
{Attr: dwarf.AttrType, Val: dwarf.Offset(0xb7f), Class: dwarf.ClassReference},
{Attr: dwarf.AttrDataMemberLoc, Val: []byte{0x23, 0x10}, Class: dwarf.ClassExprLoc},
},
}},
},
},
},
},
}
func TestDWARFRelocations(t *testing.T) {
for i, test := range relocationTests {
for _, test := range relocationTests {
test := test
t.Run(test.file, func(t *testing.T) {
t.Parallel()
f, err := Open(test.file)
if err != nil {
t.Error(err)
continue
t.Fatal(err)
}
dwarf, err := f.DWARF()
if err != nil {
t.Error(err)
continue
t.Fatal(err)
}
for _, testEntry := range test.entries {
reader := dwarf.Reader()
for j := 0; j < testEntry.entryNumber; j++ {
idx := 0
for _, testEntry := range test.entries {
if testEntry.entryNumber < idx {
t.Fatalf("internal test error: %d < %d", testEntry.entryNumber, idx)
}
for ; idx < testEntry.entryNumber; idx++ {
entry, err := reader.Next()
if entry == nil || err != nil {
t.Errorf("Failed to skip to entry %d: %v", testEntry.entryNumber, err)
continue
t.Fatalf("Failed to skip to entry %d: %v", testEntry.entryNumber, err)
}
}
entry, err := reader.Next()
idx++
if err != nil {
t.Error(err)
continue
t.Fatal(err)
}
if !reflect.DeepEqual(testEntry.entry, entry) {
t.Errorf("#%d/%d: mismatch: got:%#v want:%#v", i, testEntry.entryNumber, entry, testEntry.entry)
continue
t.Errorf("entry %d mismatch: got:%#v want:%#v", testEntry.entryNumber, entry, testEntry.entry)
}
}
})
}
}