]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: shorten tests in all.bash
authorRuss Cox <rsc@golang.org>
Fri, 27 Oct 2017 17:30:09 +0000 (13:30 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 31 Oct 2017 13:20:27 +0000 (13:20 +0000)
This cuts 23 seconds from all.bash on my MacBook Pro.

Change-Id: Ibc4d7c01660b9e9ebd088dd55ba993f0d7ec6aa3
Reviewed-on: https://go-review.googlesource.com/73991
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/dist/test.go
src/runtime/crash_test.go
src/runtime/map_test.go
src/runtime/memmove_test.go
src/runtime/mfinal_test.go
src/runtime/runtime_test.go
src/runtime/testdata/testprogcgo/callback.go
src/runtime/testdata/testprogcgo/cgo.go

index 49791b6c1ddde66d5f0b728e4a773c2672c66613..5cb0ee587c26c05504ff1ca535c6a8ec4c800cc9 100644 (file)
@@ -402,9 +402,9 @@ func (t *tester) registerTests() {
                testName := "runtime:cpu124"
                t.tests = append(t.tests, distTest{
                        name:    testName,
-                       heading: "GOMAXPROCS=2 runtime -cpu=1,2,4",
+                       heading: "GOMAXPROCS=2 runtime -cpu=1,2,4 -quick",
                        fn: func(dt *distTest) error {
-                               cmd := t.addCmd(dt, "src", "go", "test", "-short", t.timeout(300), t.tags(), "runtime", "-cpu=1,2,4")
+                               cmd := t.addCmd(dt, "src", "go", "test", "-short", t.timeout(300), t.tags(), "runtime", "-cpu=1,2,4", "-quick")
                                // We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
                                // creation of first goroutines and first garbage collections in the parallel setting.
                                cmd.Env = append(os.Environ(), "GOMAXPROCS=2")
index 80ae4fa63e0e344ba6400fa557e129bf212f2064..54144c01de97e733c9126dc38cf47787898c1703 100644 (file)
@@ -44,6 +44,10 @@ type buildexe struct {
 }
 
 func runTestProg(t *testing.T, binary, name string, env ...string) string {
+       if *flagQuick {
+               t.Skip("-quick")
+       }
+
        testenv.MustHaveGoBuild(t)
 
        exe, err := buildTestProg(t, binary)
@@ -53,6 +57,9 @@ func runTestProg(t *testing.T, binary, name string, env ...string) string {
 
        cmd := testenv.CleanCmdEnv(exec.Command(exe, name))
        cmd.Env = append(cmd.Env, env...)
+       if testing.Short() {
+               cmd.Env = append(cmd.Env, "RUNTIME_TEST_SHORT=1")
+       }
        var b bytes.Buffer
        cmd.Stdout = &b
        cmd.Stderr = &b
@@ -93,6 +100,10 @@ func runTestProg(t *testing.T, binary, name string, env ...string) string {
 }
 
 func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) {
+       if *flagQuick {
+               t.Skip("-quick")
+       }
+
        checkStaleRuntime(t)
 
        testprog.Lock()
index d6054c05273e3a232affd189a4c5ec4835dce97e..0529cb8e8697e24cb65a08940833caac606b73dc 100644 (file)
@@ -244,7 +244,7 @@ func testConcurrentReadsAfterGrowth(t *testing.T, useReflect bool) {
        numGrowStep := 250
        numReader := 16
        if testing.Short() {
-               numLoop, numGrowStep = 2, 500
+               numLoop, numGrowStep = 2, 100
        }
        for i := 0; i < numLoop; i++ {
                m := make(map[int]int, 0)
index 74b8753b5f78f4f22f53346c2ce0b3f9113f2980..62de604e69c56571242aea6f8c88cc28331a5d08 100644 (file)
@@ -9,6 +9,7 @@ import (
        "encoding/binary"
        "fmt"
        "internal/race"
+       "internal/testenv"
        . "runtime"
        "testing"
 )
@@ -88,6 +89,10 @@ func TestMemmoveAlias(t *testing.T) {
 }
 
 func TestMemmoveLarge0x180000(t *testing.T) {
+       if testing.Short() && testenv.Builder() == "" {
+               t.Skip("-short")
+       }
+
        t.Parallel()
        if race.Enabled {
                t.Skip("skipping large memmove test under race detector")
@@ -96,6 +101,10 @@ func TestMemmoveLarge0x180000(t *testing.T) {
 }
 
 func TestMemmoveOverlapLarge0x120000(t *testing.T) {
+       if testing.Short() && testenv.Builder() == "" {
+               t.Skip("-short")
+       }
+
        t.Parallel()
        if race.Enabled {
                t.Skip("skipping large memmove test under race detector")
index 85a5f7acaef6b4ac25769ab81f426cde29e3f7e9..3ca8d31c60598bed5bd691712e785331d0055855 100644 (file)
@@ -243,6 +243,10 @@ var (
 )
 
 func TestDeferKeepAlive(t *testing.T) {
+       if *flagQuick {
+               t.Skip("-quick")
+       }
+
        // See issue 21402.
        t.Parallel()
        type T *int // needs to be a pointer base type to avoid tinyalloc and its never-finalized behavior.
index 922cd830bcc3e59dd39fe08a5220ef66a58c18f7..d5b6b3ac3ce53e0a9ffe208e49fde63a469d36f6 100644 (file)
@@ -5,6 +5,7 @@
 package runtime_test
 
 import (
+       "flag"
        "io"
        . "runtime"
        "runtime/debug"
@@ -13,6 +14,8 @@ import (
        "unsafe"
 )
 
+var flagQuick = flag.Bool("quick", false, "skip slow tests, for second run in all.bash")
+
 func init() {
        // We're testing the runtime, so make tracebacks show things
        // in the runtime. This only raises the level, so it won't
index 7d9d68ddd115aaa07389481c0aec1286e066b444..be0409f39d241275921acdb89bd63d4371f1c74c 100644 (file)
@@ -29,6 +29,7 @@ import "C"
 
 import (
        "fmt"
+       "os"
        "runtime"
 )
 
@@ -63,7 +64,10 @@ func grow1(x, sum *int) int {
 }
 
 func CgoCallbackGC() {
-       const P = 100
+       P := 100
+       if os.Getenv("RUNTIME_TESTING_SHORT") != "" {
+               P = 10
+       }
        done := make(chan bool)
        // allocate a bunch of stack frames and spray them with pointers
        for i := 0; i < P; i++ {
index 209524a24dbb95733c62420edd344ed51fa031b9..a587db385b32404001a15e35c55f39f9ab17aa00 100644 (file)
@@ -52,7 +52,11 @@ func CgoSignalDeadlock() {
        time.Sleep(time.Millisecond)
        start := time.Now()
        var times []time.Duration
-       for i := 0; i < 64; i++ {
+       n := 64
+       if os.Getenv("RUNTIME_TEST_SHORT") != "" {
+               n = 16
+       }
+       for i := 0; i < n; i++ {
                go func() {
                        runtime.LockOSThread()
                        select {}