From d731315cdbf9b2e6e1a70343a39f7c39b8eb99bb Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 29 Dec 2015 12:10:38 -0500 Subject: [PATCH] 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 Reviewed-by: Mikio Hara Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot --- src/net/timeout_test.go | 50 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/src/net/timeout_test.go b/src/net/timeout_test.go index ca94e24c81685c..5832306591eff3 100644 --- a/src/net/timeout_test.go +++ b/src/net/timeout_test.go @@ -33,6 +33,7 @@ var dialTimeoutTests = []struct { } func TestDialTimeout(t *testing.T) { + // Cannot use t.Parallel - modifies global hooks. origTestHookDialChannel := testHookDialChannel defer func() { testHookDialChannel = origTestHookDialChannel }() defer sw.Set(socktest.FilterConnect, nil) @@ -110,6 +111,8 @@ var acceptTimeoutTests = []struct { } func TestAcceptTimeout(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -161,6 +164,8 @@ func TestAcceptTimeout(t *testing.T) { } func TestAcceptTimeoutMustReturn(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -205,6 +210,8 @@ func TestAcceptTimeoutMustReturn(t *testing.T) { } func TestAcceptTimeoutMustNotReturn(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -254,6 +261,8 @@ var readTimeoutTests = []struct { } func TestReadTimeout(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -313,6 +322,8 @@ func TestReadTimeout(t *testing.T) { } func TestReadTimeoutMustNotReturn(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -454,6 +465,8 @@ var writeTimeoutTests = []struct { } func TestWriteTimeout(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -500,6 +513,8 @@ func TestWriteTimeout(t *testing.T) { } func TestWriteTimeoutMustNotReturn(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -569,6 +584,8 @@ var writeToTimeoutTests = []struct { } func TestWriteToTimeout(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "nacl", "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -620,6 +637,8 @@ func TestWriteToTimeout(t *testing.T) { } func TestReadTimeoutFluctuation(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -656,6 +675,8 @@ func TestReadTimeoutFluctuation(t *testing.T) { } func TestReadFromTimeoutFluctuation(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -692,6 +713,8 @@ func TestReadFromTimeoutFluctuation(t *testing.T) { } func TestWriteTimeoutFluctuation(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -731,12 +754,27 @@ func TestWriteTimeoutFluctuation(t *testing.T) { } } +func TestVariousDeadlines(t *testing.T) { + t.Parallel() + testVariousDeadlines(t) +} + func TestVariousDeadlines1Proc(t *testing.T) { - testVariousDeadlines(t, 1) + // Cannot use t.Parallel - modifies global GOMAXPROCS. + if testing.Short() { + t.Skip("skipping in short mode") + } + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1)) + testVariousDeadlines(t) } func TestVariousDeadlines4Proc(t *testing.T) { - testVariousDeadlines(t, 4) + // Cannot use t.Parallel - modifies global GOMAXPROCS. + if testing.Short() { + t.Skip("skipping in short mode") + } + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) + testVariousDeadlines(t) } type neverEnding byte @@ -748,14 +786,12 @@ func (b neverEnding) Read(p []byte) (int, error) { return len(p), nil } -func testVariousDeadlines(t *testing.T, maxProcs int) { +func testVariousDeadlines(t *testing.T) { switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) } - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(maxProcs)) - type result struct { n int64 err error @@ -869,6 +905,8 @@ func testVariousDeadlines(t *testing.T, maxProcs int) { // TestReadWriteProlongedTimeout tests concurrent deadline // modification. Known to cause data races in the past. func TestReadWriteProlongedTimeout(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) @@ -947,6 +985,8 @@ func TestReadWriteProlongedTimeout(t *testing.T) { } func TestReadWriteDeadlineRace(t *testing.T) { + t.Parallel() + switch runtime.GOOS { case "nacl", "plan9": t.Skipf("not supported on %s", runtime.GOOS)