mirror of https://github.com/golang/go.git
cmd/link: fix for package name attr testpoint in dwarf_test.go
Tighten up a testpoint that looks for the compile unit DW_AT_go_package_name attribute. The linker code that injects this attribute was accidentally broken on the dev.link branch, but in a way that wasn't detected by the test (attr was generated, but always with an empty string). The new test will fail if the attr is an empty string, or if we can't find the attribute for the runtime package. Change-Id: I8b065e7eb3486646364d0eaf48a73db6acffbd18 Reviewed-on: https://go-review.googlesource.com/c/go/+/218483 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
c6f678b6ef
commit
5db3c8f1fd
|
|
@ -1239,6 +1239,7 @@ func TestPackageNameAttr(t *testing.T) {
|
|||
}
|
||||
|
||||
rdr := d.Reader()
|
||||
runtimeUnitSeen := false
|
||||
for {
|
||||
e, err := rdr.Next()
|
||||
if err != nil {
|
||||
|
|
@ -1254,11 +1255,25 @@ func TestPackageNameAttr(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
|
||||
_, ok := e.Val(dwarfAttrGoPackageName).(string)
|
||||
pn, ok := e.Val(dwarfAttrGoPackageName).(string)
|
||||
if !ok {
|
||||
name, _ := e.Val(dwarf.AttrName).(string)
|
||||
t.Errorf("found compile unit without package name: %s", name)
|
||||
|
||||
}
|
||||
if pn == "" {
|
||||
name, _ := e.Val(dwarf.AttrName).(string)
|
||||
t.Errorf("found compile unit with empty package name: %s", name)
|
||||
} else {
|
||||
if pn == "runtime" {
|
||||
runtimeUnitSeen = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Something is wrong if there's no runtime compilation unit.
|
||||
if !runtimeUnitSeen {
|
||||
t.Errorf("no package name for runtime unit")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue