Skip to content

Commit d731315

Browse files
committed
net: run all timeout tests in parallel
For #10571. Change-Id: I9a42226078b9c52dbe0c65cb101b5f452233e911 Reviewed-on: https://go-review.googlesource.com/18205 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent f2c36df commit d731315

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

src/net/timeout_test.go

+45-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var dialTimeoutTests = []struct {
3333
}
3434

3535
func TestDialTimeout(t *testing.T) {
36+
// Cannot use t.Parallel - modifies global hooks.
3637
origTestHookDialChannel := testHookDialChannel
3738
defer func() { testHookDialChannel = origTestHookDialChannel }()
3839
defer sw.Set(socktest.FilterConnect, nil)
@@ -110,6 +111,8 @@ var acceptTimeoutTests = []struct {
110111
}
111112

112113
func TestAcceptTimeout(t *testing.T) {
114+
t.Parallel()
115+
113116
switch runtime.GOOS {
114117
case "plan9":
115118
t.Skipf("not supported on %s", runtime.GOOS)
@@ -161,6 +164,8 @@ func TestAcceptTimeout(t *testing.T) {
161164
}
162165

163166
func TestAcceptTimeoutMustReturn(t *testing.T) {
167+
t.Parallel()
168+
164169
switch runtime.GOOS {
165170
case "plan9":
166171
t.Skipf("not supported on %s", runtime.GOOS)
@@ -205,6 +210,8 @@ func TestAcceptTimeoutMustReturn(t *testing.T) {
205210
}
206211

207212
func TestAcceptTimeoutMustNotReturn(t *testing.T) {
213+
t.Parallel()
214+
208215
switch runtime.GOOS {
209216
case "plan9":
210217
t.Skipf("not supported on %s", runtime.GOOS)
@@ -254,6 +261,8 @@ var readTimeoutTests = []struct {
254261
}
255262

256263
func TestReadTimeout(t *testing.T) {
264+
t.Parallel()
265+
257266
switch runtime.GOOS {
258267
case "plan9":
259268
t.Skipf("not supported on %s", runtime.GOOS)
@@ -313,6 +322,8 @@ func TestReadTimeout(t *testing.T) {
313322
}
314323

315324
func TestReadTimeoutMustNotReturn(t *testing.T) {
325+
t.Parallel()
326+
316327
switch runtime.GOOS {
317328
case "plan9":
318329
t.Skipf("not supported on %s", runtime.GOOS)
@@ -454,6 +465,8 @@ var writeTimeoutTests = []struct {
454465
}
455466

456467
func TestWriteTimeout(t *testing.T) {
468+
t.Parallel()
469+
457470
switch runtime.GOOS {
458471
case "plan9":
459472
t.Skipf("not supported on %s", runtime.GOOS)
@@ -500,6 +513,8 @@ func TestWriteTimeout(t *testing.T) {
500513
}
501514

502515
func TestWriteTimeoutMustNotReturn(t *testing.T) {
516+
t.Parallel()
517+
503518
switch runtime.GOOS {
504519
case "plan9":
505520
t.Skipf("not supported on %s", runtime.GOOS)
@@ -569,6 +584,8 @@ var writeToTimeoutTests = []struct {
569584
}
570585

571586
func TestWriteToTimeout(t *testing.T) {
587+
t.Parallel()
588+
572589
switch runtime.GOOS {
573590
case "nacl", "plan9":
574591
t.Skipf("not supported on %s", runtime.GOOS)
@@ -620,6 +637,8 @@ func TestWriteToTimeout(t *testing.T) {
620637
}
621638

622639
func TestReadTimeoutFluctuation(t *testing.T) {
640+
t.Parallel()
641+
623642
switch runtime.GOOS {
624643
case "plan9":
625644
t.Skipf("not supported on %s", runtime.GOOS)
@@ -656,6 +675,8 @@ func TestReadTimeoutFluctuation(t *testing.T) {
656675
}
657676

658677
func TestReadFromTimeoutFluctuation(t *testing.T) {
678+
t.Parallel()
679+
659680
switch runtime.GOOS {
660681
case "plan9":
661682
t.Skipf("not supported on %s", runtime.GOOS)
@@ -692,6 +713,8 @@ func TestReadFromTimeoutFluctuation(t *testing.T) {
692713
}
693714

694715
func TestWriteTimeoutFluctuation(t *testing.T) {
716+
t.Parallel()
717+
695718
switch runtime.GOOS {
696719
case "plan9":
697720
t.Skipf("not supported on %s", runtime.GOOS)
@@ -731,12 +754,27 @@ func TestWriteTimeoutFluctuation(t *testing.T) {
731754
}
732755
}
733756

757+
func TestVariousDeadlines(t *testing.T) {
758+
t.Parallel()
759+
testVariousDeadlines(t)
760+
}
761+
734762
func TestVariousDeadlines1Proc(t *testing.T) {
735-
testVariousDeadlines(t, 1)
763+
// Cannot use t.Parallel - modifies global GOMAXPROCS.
764+
if testing.Short() {
765+
t.Skip("skipping in short mode")
766+
}
767+
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
768+
testVariousDeadlines(t)
736769
}
737770

738771
func TestVariousDeadlines4Proc(t *testing.T) {
739-
testVariousDeadlines(t, 4)
772+
// Cannot use t.Parallel - modifies global GOMAXPROCS.
773+
if testing.Short() {
774+
t.Skip("skipping in short mode")
775+
}
776+
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4))
777+
testVariousDeadlines(t)
740778
}
741779

742780
type neverEnding byte
@@ -748,14 +786,12 @@ func (b neverEnding) Read(p []byte) (int, error) {
748786
return len(p), nil
749787
}
750788

751-
func testVariousDeadlines(t *testing.T, maxProcs int) {
789+
func testVariousDeadlines(t *testing.T) {
752790
switch runtime.GOOS {
753791
case "plan9":
754792
t.Skipf("not supported on %s", runtime.GOOS)
755793
}
756794

757-
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(maxProcs))
758-
759795
type result struct {
760796
n int64
761797
err error
@@ -869,6 +905,8 @@ func testVariousDeadlines(t *testing.T, maxProcs int) {
869905
// TestReadWriteProlongedTimeout tests concurrent deadline
870906
// modification. Known to cause data races in the past.
871907
func TestReadWriteProlongedTimeout(t *testing.T) {
908+
t.Parallel()
909+
872910
switch runtime.GOOS {
873911
case "plan9":
874912
t.Skipf("not supported on %s", runtime.GOOS)
@@ -947,6 +985,8 @@ func TestReadWriteProlongedTimeout(t *testing.T) {
947985
}
948986

949987
func TestReadWriteDeadlineRace(t *testing.T) {
988+
t.Parallel()
989+
950990
switch runtime.GOOS {
951991
case "nacl", "plan9":
952992
t.Skipf("not supported on %s", runtime.GOOS)

0 commit comments

Comments
 (0)