Commit 9b950356 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/nm: run tests in parallel, don't use Scanner on []byte

Saves about 35% on total test time on my laptop.

Fixes #26471

Change-Id: I15b28b1bc00f889934d577dc7996864bbab10105
Reviewed-on: https://go-review.googlesource.com/c/153499
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent a11aa2aa
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
package main package main
import ( import (
"bufio"
"bytes"
"fmt" "fmt"
"internal/testenv" "internal/testenv"
"io/ioutil" "io/ioutil"
...@@ -55,6 +53,7 @@ func testMain(m *testing.M) int { ...@@ -55,6 +53,7 @@ func testMain(m *testing.M) int {
} }
func TestNonGoExecs(t *testing.T) { func TestNonGoExecs(t *testing.T) {
t.Parallel()
testfiles := []string{ testfiles := []string{
"debug/elf/testdata/gcc-386-freebsd-exec", "debug/elf/testdata/gcc-386-freebsd-exec",
"debug/elf/testdata/gcc-amd64-linux-exec", "debug/elf/testdata/gcc-amd64-linux-exec",
...@@ -77,6 +76,7 @@ func TestNonGoExecs(t *testing.T) { ...@@ -77,6 +76,7 @@ func TestNonGoExecs(t *testing.T) {
} }
func testGoExec(t *testing.T, iscgo, isexternallinker bool) { func testGoExec(t *testing.T, iscgo, isexternallinker bool) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "TestGoExec") tmpdir, err := ioutil.TempDir("", "TestGoExec")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -154,10 +154,9 @@ func testGoExec(t *testing.T, iscgo, isexternallinker bool) { ...@@ -154,10 +154,9 @@ func testGoExec(t *testing.T, iscgo, isexternallinker bool) {
return false return false
} }
scanner := bufio.NewScanner(bytes.NewBuffer(out))
dups := make(map[string]bool) dups := make(map[string]bool)
for scanner.Scan() { for _, line := range strings.Split(string(out), "\n") {
f := strings.Fields(scanner.Text()) f := strings.Fields(line)
if len(f) < 3 { if len(f) < 3 {
continue continue
} }
...@@ -184,10 +183,6 @@ func testGoExec(t *testing.T, iscgo, isexternallinker bool) { ...@@ -184,10 +183,6 @@ func testGoExec(t *testing.T, iscgo, isexternallinker bool) {
delete(runtimeSyms, name) delete(runtimeSyms, name)
} }
} }
err = scanner.Err()
if err != nil {
t.Fatalf("error reading nm output: %v", err)
}
if len(names) > 0 { if len(names) > 0 {
t.Errorf("executable is missing %v symbols", names) t.Errorf("executable is missing %v symbols", names)
} }
...@@ -201,6 +196,7 @@ func TestGoExec(t *testing.T) { ...@@ -201,6 +196,7 @@ func TestGoExec(t *testing.T) {
} }
func testGoLib(t *testing.T, iscgo bool) { func testGoLib(t *testing.T, iscgo bool) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "TestGoLib") tmpdir, err := ioutil.TempDir("", "TestGoLib")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -269,9 +265,9 @@ func testGoLib(t *testing.T, iscgo bool) { ...@@ -269,9 +265,9 @@ func testGoLib(t *testing.T, iscgo bool) {
syms = append(syms, symType{"T", "cgofunc", true, false}) syms = append(syms, symType{"T", "cgofunc", true, false})
} }
} }
scanner := bufio.NewScanner(bytes.NewBuffer(out))
for scanner.Scan() { for _, line := range strings.Split(string(out), "\n") {
f := strings.Fields(scanner.Text()) f := strings.Fields(line)
var typ, name string var typ, name string
var csym bool var csym bool
if iscgo { if iscgo {
...@@ -298,10 +294,6 @@ func testGoLib(t *testing.T, iscgo bool) { ...@@ -298,10 +294,6 @@ func testGoLib(t *testing.T, iscgo bool) {
} }
} }
} }
err = scanner.Err()
if err != nil {
t.Fatalf("error reading nm output: %v", err)
}
for _, sym := range syms { for _, sym := range syms {
if !sym.Found { if !sym.Found {
t.Errorf("cannot found symbol %s %s", sym.Type, sym.Name) t.Errorf("cannot found symbol %s %s", sym.Type, sym.Name)
......
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