]> Cypherpunks repositories - gostls13.git/commitdiff
net: run all timeout tests in parallel
authorRuss Cox <rsc@golang.org>
Tue, 29 Dec 2015 17:10:38 +0000 (12:10 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 5 Jan 2016 14:19:39 +0000 (14:19 +0000)
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>

src/net/timeout_test.go

index ca94e24c81685cfc3e67655a544efea12a0a1e01..5832306591eff304cac978527493bfe6d96bb57b 100644 (file)
@@ -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)