all: sprinkle t.Parallel on some slow tests

I used the slowtests.go tool as described in
https://golang.org/cl/32684 on packages that stood out.

go test -short std drops from ~56 to ~52 seconds.

This isn't a huge win, but it was mostly an exercise.

Updates #17751

Change-Id: I9f3402e36a038d71e662d06ce2c1d52f6c4b674d
Reviewed-on: https://go-review.googlesource.com/32751
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2016-11-04 05:28:01 +00:00
parent a1b5b4eab5
commit 3dc6b2757e
3 changed files with 24 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
"sync"
"testing" "testing"
"time" "time"
) )
@ -420,7 +421,26 @@ func (test *clientTest) run(t *testing.T, write bool) {
} }
} }
var (
didParMu sync.Mutex
didPar = map[*testing.T]bool{}
)
// setParallel calls t.Parallel once. If you call it twice, it would
// panic.
func setParallel(t *testing.T) {
didParMu.Lock()
v := didPar[t]
didPar[t] = true
didParMu.Unlock()
if !v {
t.Parallel()
}
}
func runClientTestForVersion(t *testing.T, template *clientTest, prefix, option string) { func runClientTestForVersion(t *testing.T, template *clientTest, prefix, option string) {
setParallel(t)
test := *template test := *template
test.name = prefix + test.name test.name = prefix + test.name
if len(test.command) == 0 { if len(test.command) == 0 {
@ -1356,6 +1376,7 @@ func TestAlertFlushing(t *testing.T) {
} }
func TestHandshakeRace(t *testing.T) { func TestHandshakeRace(t *testing.T) {
t.Parallel()
// This test races a Read and Write to try and complete a handshake in // This test races a Read and Write to try and complete a handshake in
// order to provide some evidence that there are no races or deadlocks // order to provide some evidence that there are no races or deadlocks
// in the handshake locking. // in the handshake locking.

View File

@ -660,6 +660,7 @@ func (test *serverTest) run(t *testing.T, write bool) {
} }
func runServerTestForVersion(t *testing.T, template *serverTest, prefix, option string) { func runServerTestForVersion(t *testing.T, template *serverTest, prefix, option string) {
setParallel(t)
test := *template test := *template
test.name = prefix + test.name test.name = prefix + test.name
if len(test.command) == 0 { if len(test.command) == 0 {
@ -1054,6 +1055,7 @@ FMBexFe01MNvja5oHt1vzobhfm6ySD6B5U7ixohLZNz1MLvT/2XMW/TdtWo+PtAd
-----END EC PRIVATE KEY-----` -----END EC PRIVATE KEY-----`
func TestClientAuth(t *testing.T) { func TestClientAuth(t *testing.T) {
setParallel(t)
var certPath, keyPath, ecdsaCertPath, ecdsaKeyPath string var certPath, keyPath, ecdsaCertPath, ecdsaKeyPath string
if *update { if *update {

View File

@ -99,6 +99,7 @@ var keyPairTests = []struct {
} }
func TestX509KeyPair(t *testing.T) { func TestX509KeyPair(t *testing.T) {
t.Parallel()
var pem []byte var pem []byte
for _, test := range keyPairTests { for _, test := range keyPairTests {
pem = []byte(test.cert + test.key) pem = []byte(test.cert + test.key)