Commit 353795c8 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/link/internal/ld: run tests in parallel

Also skip TestNooptCgoBuild in short mode.

Also fix a couple of obscure constants to use values named in
cmd/internal/dwarf.

This brings the time of the cmd/link/internal/ld tests down to about 1
second on my laptop.

Updates #26470

Change-Id: I71c896f30fd314a81d9090f1b6d02edc4174a808
Reviewed-on: https://go-review.googlesource.com/c/153259
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent ea6259d5
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package ld package ld
import ( import (
intdwarf "cmd/internal/dwarf"
objfilepkg "cmd/internal/objfile" // renamed to avoid conflict with objfile function objfilepkg "cmd/internal/objfile" // renamed to avoid conflict with objfile function
"debug/dwarf" "debug/dwarf"
"errors" "errors"
...@@ -29,6 +30,7 @@ const ( ...@@ -29,6 +30,7 @@ const (
) )
func TestRuntimeTypesPresent(t *testing.T) { func TestRuntimeTypesPresent(t *testing.T) {
t.Parallel()
testenv.MustHaveGoBuild(t) testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" { if runtime.GOOS == "plan9" {
...@@ -145,6 +147,7 @@ func gobuildTestdata(t *testing.T, tdir string, gopathdir string, packtobuild st ...@@ -145,6 +147,7 @@ func gobuildTestdata(t *testing.T, tdir string, gopathdir string, packtobuild st
} }
func TestEmbeddedStructMarker(t *testing.T) { func TestEmbeddedStructMarker(t *testing.T) {
t.Parallel()
testenv.MustHaveGoBuild(t) testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" { if runtime.GOOS == "plan9" {
...@@ -224,7 +227,7 @@ func main() { ...@@ -224,7 +227,7 @@ func main() {
func findMembers(rdr *dwarf.Reader) (map[string]bool, error) { func findMembers(rdr *dwarf.Reader) (map[string]bool, error) {
memberEmbedded := map[string]bool{} memberEmbedded := map[string]bool{}
// TODO(hyangah): define in debug/dwarf package // TODO(hyangah): define in debug/dwarf package
const goEmbeddedStruct = dwarf.Attr(0x2903) const goEmbeddedStruct = dwarf.Attr(intdwarf.DW_AT_go_embedded_field)
for entry, err := rdr.Next(); entry != nil; entry, err = rdr.Next() { for entry, err := rdr.Next(); entry != nil; entry, err = rdr.Next() {
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -245,6 +248,7 @@ func TestSizes(t *testing.T) { ...@@ -245,6 +248,7 @@ func TestSizes(t *testing.T) {
if runtime.GOOS == "plan9" { if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables") t.Skip("skipping on plan9; no DWARF symbol table in executables")
} }
t.Parallel()
// DWARF sizes should never be -1. // DWARF sizes should never be -1.
// See issue #21097 // See issue #21097
...@@ -292,6 +296,7 @@ func TestFieldOverlap(t *testing.T) { ...@@ -292,6 +296,7 @@ func TestFieldOverlap(t *testing.T) {
if runtime.GOOS == "plan9" { if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables") t.Skip("skipping on plan9; no DWARF symbol table in executables")
} }
t.Parallel()
// This test grew out of issue 21094, where specific sudog<T> DWARF types // This test grew out of issue 21094, where specific sudog<T> DWARF types
// had elem fields set to values instead of pointers. // had elem fields set to values instead of pointers.
...@@ -348,6 +353,7 @@ func main() { ...@@ -348,6 +353,7 @@ func main() {
} }
func varDeclCoordsAndSubrogramDeclFile(t *testing.T, testpoint string, expectFile int, expectLine int, directive string) { func varDeclCoordsAndSubrogramDeclFile(t *testing.T, testpoint string, expectFile int, expectLine int, directive string) {
t.Parallel()
prog := fmt.Sprintf("package main\n\nfunc main() {\n%s\nvar i int\ni = i\n}\n", directive) prog := fmt.Sprintf("package main\n\nfunc main() {\n%s\nvar i int\ni = i\n}\n", directive)
...@@ -584,6 +590,8 @@ func TestInlinedRoutineRecords(t *testing.T) { ...@@ -584,6 +590,8 @@ func TestInlinedRoutineRecords(t *testing.T) {
t.Skip("skipping on solaris and darwin, pending resolution of issue #23168") t.Skip("skipping on solaris and darwin, pending resolution of issue #23168")
} }
t.Parallel()
const prog = ` const prog = `
package main package main
...@@ -720,6 +728,7 @@ func main() { ...@@ -720,6 +728,7 @@ func main() {
} }
func abstractOriginSanity(t *testing.T, gopathdir string, flags string) { func abstractOriginSanity(t *testing.T, gopathdir string, flags string) {
t.Parallel()
dir, err := ioutil.TempDir("", "TestAbstractOriginSanity") dir, err := ioutil.TempDir("", "TestAbstractOriginSanity")
if err != nil { if err != nil {
...@@ -881,6 +890,8 @@ func TestRuntimeTypeAttrExternal(t *testing.T) { ...@@ -881,6 +890,8 @@ func TestRuntimeTypeAttrExternal(t *testing.T) {
} }
func testRuntimeTypeAttr(t *testing.T, flags string) { func testRuntimeTypeAttr(t *testing.T, flags string) {
t.Parallel()
const prog = ` const prog = `
package main package main
...@@ -939,7 +950,7 @@ func main() { ...@@ -939,7 +950,7 @@ func main() {
if len(dies) != 1 { if len(dies) != 1 {
t.Fatalf("wanted 1 DIE named *main.X, found %v", len(dies)) t.Fatalf("wanted 1 DIE named *main.X, found %v", len(dies))
} }
rtAttr := dies[0].Val(0x2904) rtAttr := dies[0].Val(intdwarf.DW_AT_go_runtime_type)
if rtAttr == nil { if rtAttr == nil {
t.Fatalf("*main.X DIE had no runtime type attr. DIE: %v", dies[0]) t.Fatalf("*main.X DIE had no runtime type attr. DIE: %v", dies[0])
} }
...@@ -959,6 +970,8 @@ func TestIssue27614(t *testing.T) { ...@@ -959,6 +970,8 @@ func TestIssue27614(t *testing.T) {
t.Skip("skipping on plan9; no DWARF symbol table in executables") t.Skip("skipping on plan9; no DWARF symbol table in executables")
} }
t.Parallel()
dir, err := ioutil.TempDir("", "go-build") dir, err := ioutil.TempDir("", "go-build")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -1075,6 +1088,8 @@ func TestStaticTmp(t *testing.T) { ...@@ -1075,6 +1088,8 @@ func TestStaticTmp(t *testing.T) {
t.Skip("skipping on plan9; no DWARF symbol table in executables") t.Skip("skipping on plan9; no DWARF symbol table in executables")
} }
t.Parallel()
dir, err := ioutil.TempDir("", "go-build") dir, err := ioutil.TempDir("", "go-build")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
......
...@@ -14,6 +14,7 @@ import ( ...@@ -14,6 +14,7 @@ import (
) )
func TestUndefinedRelocErrors(t *testing.T) { func TestUndefinedRelocErrors(t *testing.T) {
t.Parallel()
testenv.MustHaveGoBuild(t) testenv.MustHaveGoBuild(t)
dir, err := ioutil.TempDir("", "go-build") dir, err := ioutil.TempDir("", "go-build")
if err != nil { if err != nil {
......
...@@ -15,6 +15,11 @@ import ( ...@@ -15,6 +15,11 @@ import (
) )
func TestNooptCgoBuild(t *testing.T) { func TestNooptCgoBuild(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
t.Parallel()
testenv.MustHaveGoBuild(t) testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t) testenv.MustHaveCGO(t)
dir, err := ioutil.TempDir("", "go-build") dir, err := ioutil.TempDir("", "go-build")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment