]> Cypherpunks.ru repositories - gostls13.git/commitdiff
all: shorten some tests
authorRuss Cox <rsc@golang.org>
Thu, 16 May 2019 00:49:39 +0000 (20:49 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 22 May 2019 12:54:00 +0000 (12:54 +0000)
Shorten some of the longest tests that run during all.bash.
Removes 7r 50u 21s from all.bash.

After this change, all.bash is under 5 minutes again on my laptop.

For #26473.

Change-Id: Ie0460aa935808d65460408feaed210fbaa1d5d79
Reviewed-on: https://go-review.googlesource.com/c/go/+/177559
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
41 files changed:
src/archive/zip/zip_test.go
src/cmd/dist/test.go
src/cmd/go/internal/cache/cache_test.go
src/cmd/internal/obj/x86/pcrelative_test.go
src/cmd/link/dwarf_test.go
src/cmd/link/link_test.go
src/cmd/pack/pack_test.go
src/compress/flate/deflate_test.go
src/container/ring/ring_test.go
src/crypto/cipher/xor_test.go
src/crypto/elliptic/fuzz_test.go
src/crypto/rand/util_test.go
src/crypto/tls/handshake_client_test.go
src/crypto/x509/x509_test.go
src/debug/gosym/pclntab_test.go
src/encoding/json/encode_test.go
src/go/internal/srcimporter/srcimporter_test.go
src/internal/trace/gc_test.go
src/internal/trace/parser_test.go
src/math/big/floatmarsh_test.go
src/math/big/natconv_test.go
src/math/big/prime_test.go
src/math/big/sqrt_test.go
src/math/rand/rand_test.go
src/mime/multipart/formdata_test.go
src/mime/multipart/multipart_test.go
src/mime/quotedprintable/reader_test.go
src/net/http/serve_test.go
src/os/exec/exec_test.go
src/runtime/internal/atomic/atomic_test.go
src/runtime/pprof/pprof_test.go
src/runtime/pprof/proto_test.go
src/runtime/pprof/testdata/mappingtest/main.go
src/runtime/semasleep_test.go
src/runtime/testdata/testprog/deadlock.go
src/runtime/testdata/testprog/sleep.go [new file with mode: 0644]
src/runtime/trace/trace_test.go
src/sync/pool_test.go
src/syscall/getdirentries_test.go
src/testing/quick/quick_test.go
src/text/template/exec_test.go

index efdb5bd04477ea0d5717a98e1635663616740c73..b3a7caac7f2948d511d180d8c0163ab0aab45977 100644 (file)
@@ -11,7 +11,6 @@ import (
        "errors"
        "fmt"
        "hash"
-       "internal/race"
        "internal/testenv"
        "io"
        "io/ioutil"
@@ -309,7 +308,7 @@ func TestZip64EdgeCase(t *testing.T) {
 // Tests that we generate a zip64 file if the directory at offset
 // 0xFFFFFFFF, but not before.
 func TestZip64DirectoryOffset(t *testing.T) {
-       if testing.Short() && race.Enabled {
+       if testing.Short() {
                t.Skip("skipping in short mode")
        }
        t.Parallel()
@@ -354,7 +353,7 @@ func TestZip64DirectoryOffset(t *testing.T) {
 
 // At 16k records, we need to generate a zip64 file.
 func TestZip64ManyRecords(t *testing.T) {
-       if testing.Short() && race.Enabled {
+       if testing.Short() {
                t.Skip("skipping in short mode")
        }
        t.Parallel()
index 56ab64b8cf7885dc355eaa730acd5706b0148fbf..833baf8f915ac1ebcde8b6cf1924f4bf578b3d9f 100644 (file)
@@ -551,7 +551,9 @@ func (t *tester) registerTests() {
                        name:    "nolibgcc:" + pkg,
                        heading: "Testing without libgcc.",
                        fn: func(dt *distTest) error {
-                               t.addCmd(dt, "src", t.goTest(), "-ldflags=-linkmode=internal -libgcc=none", pkg, t.runFlag(run))
+                               // What matters is that the tests build and start up.
+                               // Skip expensive tests, especially x509 TestSystemRoots.
+                               t.addCmd(dt, "src", t.goTest(), "-ldflags=-linkmode=internal -libgcc=none", "-run=^Test[^CS]", pkg, t.runFlag(run))
                                return nil
                        },
                })
@@ -693,7 +695,10 @@ func (t *tester) registerTests() {
        }
 
        if goos != "android" && !t.iOS() {
-               t.registerTest("bench_go1", "../test/bench/go1", t.goTest(), t.timeout(600))
+               // There are no tests in this directory, only benchmarks.
+               // Check that the test binary builds but don't bother running it.
+               // (It has init-time work to set up for the benchmarks that is not worth doing unnecessarily.)
+               t.registerTest("bench_go1", "../test/bench/go1", t.goTest(), "-c", "-o="+os.DevNull)
        }
        if goos != "android" && !t.iOS() {
                // Only start multiple test dir shards on builders,
@@ -1292,8 +1297,12 @@ func (t *tester) raceTest(dt *distTest) error {
        // TODO(iant): Figure out how to catch this.
        // t.addCmd(dt, "src", t.goTest(),  "-race", "-run=TestParallelTest", "cmd/go")
        if t.cgoEnabled {
-               cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-race")
-               cmd.Env = append(os.Environ(), "GOTRACEBACK=2")
+               // Building misc/cgo/test takes a long time.
+               // There are already cgo-enabled packages being tested with the race detector.
+               // We shouldn't need to redo all of misc/cgo/test too.
+               // The race buildler will take care of this.
+               // cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-race")
+               // cmd.Env = append(os.Environ(), "GOTRACEBACK=2")
        }
        if t.extLink() {
                // Test with external linking; see issue 9133.
index 7229bc4cec49c335cff2e23633bc56f001f2b791..1988c3450234e3c80a8d86701fc536710f2837d9 100644 (file)
@@ -78,7 +78,7 @@ func TestGrowth(t *testing.T) {
 
        n := 10000
        if testing.Short() {
-               n = 1000
+               n = 10
        }
 
        for i := 0; i < n; i++ {
index 51b60cf93e558d29924e2594477a218dc31bcfb3..487a65d8dc8c84cfd0d1fc0c04860fd309a2a21f 100644 (file)
@@ -96,6 +96,9 @@ LOOP:
                for idx := len(data) - 1; idx >= 0; idx-- {
                        // check that RET wasn't overwritten.
                        if bytes.Index(data[idx], []byte("RET")) != -1 {
+                               if testing.Short() {
+                                       break LOOP
+                               }
                                continue LOOP
                        }
                }
index 235db39ddac80edff0d0b1df6b39cbc02791c446..e52e26af49a34e989194f4cee10acc2514bf60c4 100644 (file)
@@ -165,8 +165,10 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string)
 
 func TestDWARF(t *testing.T) {
        testDWARF(t, "", true)
-       if runtime.GOOS == "darwin" {
-               testDWARF(t, "c-archive", true)
+       if runtime.GOOS == "darwin" && !testing.Short() {
+               t.Run("c-archive", func(t *testing.T) {
+                       testDWARF(t, "c-archive", true)
+               })
        }
 }
 
index a783bddc50093f96431da74e8a37e2093b58cc9a..29b98e9c320ea8fd18ef46a9ac298f18aa5bf9c7 100644 (file)
@@ -170,7 +170,7 @@ main.x: relocation target main.zero not defined
        }
 }
 
-func TestBuildFortvOS(t *testing.T) {
+func TestBuildForTvOS(t *testing.T) {
        testenv.MustHaveCGO(t)
        testenv.MustHaveGoBuild(t)
 
@@ -178,6 +178,9 @@ func TestBuildFortvOS(t *testing.T) {
        if runtime.GOARCH != "amd64" || runtime.GOOS != "darwin" {
                t.Skip("skipping on non-darwin/amd64 platform")
        }
+       if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
+               t.Skip("skipping in -short mode with $GO_BUILDER_NAME empty")
+       }
        if err := exec.Command("xcrun", "--help").Run(); err != nil {
                t.Skipf("error running xcrun, required for iOS cross build: %v", err)
        }
index b2217c090fd3989f16040e3a8be38ca1d24b633b..6121bf08c0adf029c92a03e61e8b520272768064 100644 (file)
@@ -231,6 +231,9 @@ func TestHello(t *testing.T) {
 
 // Test that pack works with very long lines in PKGDEF.
 func TestLargeDefs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping in -short mode")
+       }
        testenv.MustHaveGoBuild(t)
 
        dir := tmpDir(t)
index 079c03c28352f45419b76eb0e760f227324dea1b..4b1ed549a46b32d8618358cae7a6e0e0b13874f5 100644 (file)
@@ -345,6 +345,9 @@ func testToFromWithLimit(t *testing.T, input []byte, name string, limit [11]int)
 func TestDeflateInflate(t *testing.T) {
        t.Parallel()
        for i, h := range deflateInflateTests {
+               if testing.Short() && len(h.in) > 10000 {
+                       continue
+               }
                testToFromWithLimit(t, h.in, fmt.Sprintf("#%d", i), [11]int{})
        }
 }
@@ -591,6 +594,9 @@ func TestBestSpeed(t *testing.T) {
        }
 
        for i, tc := range testCases {
+               if i >= 3 && testing.Short() {
+                       break
+               }
                for _, firstN := range []int{1, 65534, 65535, 65536, 65537, 131072} {
                        tc[0] = firstN
                outer:
index 552f0e24b55b964635c24a147c40c59d4b1d5522..41d18abf8b6b1c745cb280f7fd2a241340739a73 100644 (file)
@@ -179,7 +179,7 @@ func TestLink2(t *testing.T) {
 func TestLink3(t *testing.T) {
        var r Ring
        n := 1
-       for i := 1; i < 100; i++ {
+       for i := 1; i < 10; i++ {
                n += i
                verify(t, r.Link(New(i)), n, -1)
        }
index d49f1da77c05b1f92cc7a3ee96e856d1dd62feab..40d4e5afa3039ed0cf64f506b2362dda7b7a9a8b 100644 (file)
@@ -20,6 +20,9 @@ func TestXOR(t *testing.T) {
                testenv.SkipFlaky(t, 31812)
        }
        for j := 1; j <= 1024; j++ {
+               if testing.Short() && j > 16 {
+                       break
+               }
                for alignP := 0; alignP < 2; alignP++ {
                        for alignQ := 0; alignQ < 2; alignQ++ {
                                for alignD := 0; alignD < 2; alignD++ {
index 10196cf0bc994d3bfb7cbb72ea7257d28f5ffac4..eaeed0daccea00ad35d0ca85b73b288d13875775 100644 (file)
@@ -22,7 +22,7 @@ func TestFuzz(t *testing.T) {
        var timeout *time.Timer
 
        if testing.Short() {
-               timeout = time.NewTimer(500 * time.Millisecond)
+               timeout = time.NewTimer(10 * time.Millisecond)
        } else {
                timeout = time.NewTimer(2 * time.Second)
        }
index 685624e1b3dfbea04abfe46291dd8f294a63b6ba..e76ce2018afe23edaa9af1f99bf4269c821cd0b5 100644 (file)
@@ -84,6 +84,9 @@ func TestIntMask(t *testing.T) {
        for max := 1; max <= 256; max++ {
                t.Run(fmt.Sprintf("max=%d", max), func(t *testing.T) {
                        for i := 0; i < max; i++ {
+                               if testing.Short() && i == 0 {
+                                       i = max - 1
+                               }
                                var b bytes.Buffer
                                b.WriteByte(byte(i))
                                n, err := rand.Int(&b, big.NewInt(int64(max)))
index 40311b0a66a3c5aa8483c75ba30162eed7adde5e..a27f107ba7a9487aaa8e331502de7d38a16d76d0 100644 (file)
@@ -880,6 +880,9 @@ func TestResumption(t *testing.T) {
 }
 
 func testResumption(t *testing.T, version uint16) {
+       if testing.Short() {
+               t.Skip("skipping in -short mode")
+       }
        serverConfig := &Config{
                MaxVersion:   version,
                CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA},
@@ -1727,6 +1730,9 @@ func TestAlertFlushing(t *testing.T) {
 }
 
 func TestHandshakeRace(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping in -short mode")
+       }
        t.Parallel()
        // 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
index 833497d27523b097c90d529ec6ea3612e9c4db71..171509f7c4553d3bd635202d255409b241bf0619 100644 (file)
@@ -1243,6 +1243,9 @@ func TestParsePEMCRL(t *testing.T) {
 }
 
 func TestImports(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping in -short mode")
+       }
        testenv.MustHaveGoRun(t)
 
        if out, err := exec.Command(testenv.GoToolPath(t), "run", "x509_test_import.go").CombinedOutput(); err != nil {
index ef644f8454b107f3c8d2647c437d39b694d7b019..6baa53defd15a8048ebb93bbf94d210190d201fb 100644 (file)
@@ -196,6 +196,9 @@ func TestLineAline(t *testing.T) {
 }
 
 func TestPCLine(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping in -short mode")
+       }
        dotest(t)
        defer endtest()
 
index cd5eadf3c1cd2afab2c6da75b93eb8a367271299..bdf2a9f07923939f5258d6275e7843cd95960348 100644 (file)
@@ -580,6 +580,9 @@ func TestStringBytes(t *testing.T) {
        // Test that encodeState.stringBytes and encodeState.string use the same encoding.
        var r []rune
        for i := '\u0000'; i <= unicode.MaxRune; i++ {
+               if testing.Short() && i > 1000 {
+                       i = unicode.MaxRune
+               }
                r = append(r, i)
        }
        s := string(r) + "\xff\xff\xffhello" // some invalid UTF-8 too
@@ -864,6 +867,9 @@ func TestMarshalFloat(t *testing.T) {
 
        var digits = "1.2345678901234567890123"
        for i := len(digits); i >= 2; i-- {
+               if testing.Short() && i < len(digits)-4 {
+                       break
+               }
                for exp := -30; exp <= 30; exp++ {
                        for _, sign := range "+-" {
                                for bits := 32; bits <= 64; bits += 32 {
index 087f97461ee385b46bd5705a8f71f9c6240b46b7..56549434d14d3ec15611d46a8b265d1fc212b7e2 100644 (file)
@@ -81,10 +81,10 @@ func TestImportStdLib(t *testing.T) {
                t.Skip("no source code available")
        }
 
-       dt := maxTime
        if testing.Short() && testenv.Builder() == "" {
-               dt = 500 * time.Millisecond
+               t.Skip("skipping in -short mode")
        }
+       dt := maxTime
        nimports, _ := walkDir(t, "", time.Now().Add(dt)) // installed packages
        t.Logf("tested %d imports", nimports)
 }
index da1cb90f5cdf3a35ec6d6bfabbec972d84f735f4..4f9c77041a942bee05136190790a34c3b09b58da 100644 (file)
@@ -79,6 +79,10 @@ func TestMMU(t *testing.T) {
 func TestMMUTrace(t *testing.T) {
        // Can't be t.Parallel() because it modifies the
        // testingOneBand package variable.
+       if testing.Short() {
+               // test input too big for all.bash
+               t.Skip("skipping in -short mode")
+       }
 
        data, err := ioutil.ReadFile("testdata/stress_1_10_good")
        if err != nil {
index c9afa68c3c36c3c6543cacff4d6cdc6bd0deef39..6d87970157751527aff0112c5f22e1fcc4b4c727 100644 (file)
@@ -7,6 +7,7 @@ package trace
 import (
        "bytes"
        "io/ioutil"
+       "os"
        "path/filepath"
        "strings"
        "testing"
@@ -38,9 +39,17 @@ func TestParseCanned(t *testing.T) {
                t.Fatalf("failed to read ./testdata: %v", err)
        }
        for _, f := range files {
-               data, err := ioutil.ReadFile(filepath.Join("./testdata", f.Name()))
+               name := filepath.Join("./testdata", f.Name())
+               info, err := os.Stat(name)
                if err != nil {
-                       t.Fatalf("failed to read input file: %v", err)
+                       t.Fatal(err)
+               }
+               if testing.Short() && info.Size() > 10000 {
+                       continue
+               }
+               data, err := ioutil.ReadFile(name)
+               if err != nil {
+                       t.Fatal(err)
                }
                // Instead of Parse that requires a proper binary name for old traces,
                // we use 'parse' that omits symbol lookup if an empty string is given.
index 5bd906ddae40b9dcef52b8b816268bd743355c74..c056d78b8008cd338f72241a168bfe7d866d4fd7 100644 (file)
@@ -109,6 +109,9 @@ func TestFloatJSONEncoding(t *testing.T) {
        for _, test := range floatVals {
                for _, sign := range []string{"", "+", "-"} {
                        for _, prec := range []uint{0, 1, 2, 10, 53, 64, 100, 1000} {
+                               if prec > 53 && testing.Short() {
+                                       continue
+                               }
                                x := sign + test
                                var tx Float
                                _, _, err := tx.SetPrec(prec).Parse(x, 0)
index 9c2acca07e88bede5eb935b0fed768c33b9f7bf4..d39027210851529a124f9dcc1b827124243693b8 100644 (file)
@@ -446,6 +446,9 @@ func TestStringPowers(t *testing.T) {
        var p Word
        for b := 2; b <= 16; b++ {
                for p = 0; p <= 512; p++ {
+                       if testing.Short() && p > 10 {
+                               break
+                       }
                        x := nat(nil).expWW(Word(b), p)
                        xs := x.utoa(b)
                        xs2 := itoa(x, b)
index bf50f344192079a265e874527938ec0499c5339c..8596e33a13b86480df855ec7626a7891edb8b76b 100644 (file)
@@ -125,11 +125,11 @@ func cutSpace(r rune) rune {
 func TestProbablyPrime(t *testing.T) {
        nreps := 20
        if testing.Short() {
-               nreps = 3
+               nreps = 1
        }
        for i, s := range primes {
                p, _ := new(Int).SetString(s, 10)
-               if !p.ProbablyPrime(nreps) || !p.ProbablyPrime(1) || !p.ProbablyPrime(0) {
+               if !p.ProbablyPrime(nreps) || nreps != 1 && !p.ProbablyPrime(1) || !p.ProbablyPrime(0) {
                        t.Errorf("#%d prime found to be non-prime (%s)", i, s)
                }
        }
@@ -137,7 +137,7 @@ func TestProbablyPrime(t *testing.T) {
        for i, s := range composites {
                s = strings.Map(cutSpace, s)
                c, _ := new(Int).SetString(s, 10)
-               if c.ProbablyPrime(nreps) || c.ProbablyPrime(1) || c.ProbablyPrime(0) {
+               if c.ProbablyPrime(nreps) || nreps != 1 && c.ProbablyPrime(1) || c.ProbablyPrime(0) {
                        t.Errorf("#%d composite found to be prime (%s)", i, s)
                }
        }
@@ -197,6 +197,14 @@ func TestLucasPseudoprimes(t *testing.T) {
 func testPseudoprimes(t *testing.T, name string, cond func(nat) bool, want []int) {
        n := nat{1}
        for i := 3; i < 100000; i += 2 {
+               if testing.Short() {
+                       if len(want) == 0 {
+                               break
+                       }
+                       if i < want[0]-2 {
+                               i = want[0] - 2
+                       }
+               }
                n[0] = Word(i)
                pseudo := cond(n)
                if pseudo && (len(want) == 0 || i != want[0]) {
index 6a412d61fb67b084d0101f4b1d2be4a564f2fb31..d314711d74c4cb3cc4cd17382162ae649afacb33 100644 (file)
@@ -15,6 +15,9 @@ import (
 // behaves like float math.Sqrt.
 func TestFloatSqrt64(t *testing.T) {
        for i := 0; i < 1e5; i++ {
+               if i == 1e2 && testing.Short() {
+                       break
+               }
                r := rand.Float64()
 
                got := new(Float).SetPrec(53)
index e663b84f9fc3daeadb3db26678c3a9ba48b13f34..ee9c8f8e84b33e68961c7b2193fa49da94a8fcd2 100644 (file)
@@ -486,7 +486,7 @@ func TestUniformFactorial(t *testing.T) {
        r := New(NewSource(testSeeds[0]))
        top := 6
        if testing.Short() {
-               top = 4
+               top = 3
        }
        for n := 3; n <= top; n++ {
                t.Run(fmt.Sprintf("n=%d", n), func(t *testing.T) {
index 105a82c417063c997293579d4c72f5e1b50ea189..7d756c8c244a0742f368ce97ae34e047dcc986c0 100644 (file)
@@ -176,7 +176,11 @@ func (r *failOnReadAfterErrorReader) Read(p []byte) (n int, err error) {
 // TestReadForm_NonFileMaxMemory asserts that the ReadForm maxMemory limit is applied
 // while processing non-file form data as well as file form data.
 func TestReadForm_NonFileMaxMemory(t *testing.T) {
-       largeTextValue := strings.Repeat("1", (10<<20)+25)
+       n := 10<<20 + 25
+       if testing.Short() {
+               n = 10<<10 + 25
+       }
+       largeTextValue := strings.Repeat("1", n)
        message := `--MyBoundary
 Content-Disposition: form-data; name="largetext"
 
@@ -196,6 +200,9 @@ Content-Disposition: form-data; name="largetext"
        }
        for _, tc := range testCases {
                t.Run(tc.name, func(t *testing.T) {
+                       if tc.maxMemory == 0 && testing.Short() {
+                               t.Skip("skipping in -short mode")
+                       }
                        b := strings.NewReader(testBody)
                        r := NewReader(b, boundary)
                        f, err := r.ReadForm(tc.maxMemory)
index 5a8102b82236c75da43e938297ce06da1d4f171c..5dc74b5ffe130d8f17e680df6b53392983ee9291 100644 (file)
@@ -832,7 +832,10 @@ func partsFromReader(r *Reader) ([]headerBody, error) {
 
 func TestParseAllSizes(t *testing.T) {
        t.Parallel()
-       const maxSize = 5 << 10
+       maxSize := 5 << 10
+       if testing.Short() {
+               maxSize = 512
+       }
        var buf bytes.Buffer
        body := strings.Repeat("a", maxSize)
        bodyb := []byte(body)
index f870bdaa8dfcbdfe5f8534b372b4edb09abb3bfe..48a7ff64953be95be43ec2c365921927db7ea1b7 100644 (file)
@@ -116,7 +116,11 @@ func TestExhaustive(t *testing.T) {
 
        var buf bytes.Buffer
        res := make(map[string]int)
-       everySequence("", "0A \r\n=", 6, func(s string) {
+       n := 6
+       if testing.Short() {
+               n = 4
+       }
+       everySequence("", "0A \r\n=", n, func(s string) {
                if strings.HasSuffix(s, "=") || strings.Contains(s, "==") {
                        return
                }
@@ -200,6 +204,13 @@ func TestExhaustive(t *testing.T) {
 invalid bytes after =: 3949
 quotedprintable: invalid hex byte 0x0d: 2048
 unexpected EOF: 194`
+       if testing.Short() {
+               want = `OK: 896
+invalid bytes after =: 100
+quotedprintable: invalid hex byte 0x0d: 26
+unexpected EOF: 3`
+       }
+
        if got != want {
                t.Errorf("Got:\n%s\nWant:\n%s", got, want)
        }
index 32ddd3dde96fe50c9065df2b1ce0fe9b4e735beb..d774915719703eade873404a5646a3d0ccb7be8c 100644 (file)
@@ -5758,8 +5758,12 @@ func TestServerDuplicateBackgroundRead(t *testing.T) {
        setParallel(t)
        defer afterTest(t)
 
-       const goroutines = 5
-       const requests = 2000
+       goroutines := 5
+       requests := 2000
+       if testing.Short() {
+               goroutines = 3
+               requests = 100
+       }
 
        hts := httptest.NewServer(HandlerFunc(NotFound))
        defer hts.Close()
index f9d73060a3d8b06a68cbbad7339cd4cac2e7016f..c9322f6b0fde4c39ffa9f6a86de28037e6f58e09 100644 (file)
@@ -691,6 +691,9 @@ func TestExtraFilesRace(t *testing.T) {
        }
 
        for i := 0; i < 10; i++ {
+               if testing.Short() && i >= 3 {
+                       break
+               }
                la := listen()
                ca := helperCommand(t, "describefiles")
                ca.ExtraFiles = []*os.File{listenerFile(la)}
index 25ece4354eab75959666126819a9ad804ed4caa8..0ba75447e8c4a97af0abd047e0f36f4a785dfeed 100644 (file)
@@ -29,14 +29,18 @@ func runParallel(N, iter int, f func()) {
 }
 
 func TestXadduintptr(t *testing.T) {
-       const N = 20
-       const iter = 100000
+       N := 20
+       iter := 100000
+       if testing.Short() {
+               N = 10
+               iter = 10000
+       }
        inc := uintptr(100)
        total := uintptr(0)
        runParallel(N, iter, func() {
                atomic.Xadduintptr(&total, inc)
        })
-       if want := uintptr(N * iter * inc); want != total {
+       if want := uintptr(N*iter) * inc; want != total {
                t.Fatalf("xadduintpr error, want %d, got %d", want, total)
        }
        total = 0
index 59dee268678ff0a84adc45d6e078f9d54390cde9..53496371a011a7e72c41badd601e86bfcdbd54d6 100644 (file)
@@ -159,12 +159,27 @@ func testCPUProfile(t *testing.T, matches matchFunc, need []string, avoid []stri
                t.Skip("skipping on plan9")
        }
 
-       const maxDuration = 5 * time.Second
+       broken := false
+       switch runtime.GOOS {
+       case "darwin", "dragonfly", "netbsd", "illumos", "solaris":
+               broken = true
+       case "openbsd":
+               if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
+                       broken = true
+               }
+       }
+
+       maxDuration := 5 * time.Second
+       if testing.Short() && broken {
+               // If it's expected to be broken, no point waiting around.
+               maxDuration /= 10
+       }
+
        // If we're running a long test, start with a long duration
        // for tests that try to make sure something *doesn't* happen.
        duration := 5 * time.Second
        if testing.Short() {
-               duration = 200 * time.Millisecond
+               duration = 100 * time.Millisecond
        }
 
        // Profiling tests are inherently flaky, especially on a
@@ -190,14 +205,10 @@ func testCPUProfile(t *testing.T, matches matchFunc, need []string, avoid []stri
                }
        }
 
-       switch runtime.GOOS {
-       case "darwin", "dragonfly", "netbsd", "illumos", "solaris":
-               t.Skipf("ignoring failure on %s; see golang.org/issue/13841", runtime.GOOS)
-       case "openbsd":
-               if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
-                       t.Skipf("ignoring failure on %s/%s; see golang.org/issue/13841", runtime.GOOS, runtime.GOARCH)
-               }
+       if broken {
+               t.Skipf("ignoring failure on %s/%s; see golang.org/issue/13841", runtime.GOOS, runtime.GOARCH)
        }
+
        // Ignore the failure if the tests are running in a QEMU-based emulator,
        // QEMU is not perfect at emulating everything.
        // IN_QEMU environmental variable is set by some of the Go builders.
index 4452d5123158e5c40af264536d92a21624000ddc..bcb4d3386d54ba766f8a3c3e04f75155fd3735ec 100644 (file)
@@ -207,11 +207,11 @@ ffffffffff600000-ffffffffff601000 r-xp 00000090 00:00 0                  [vsysca
 7ffc34343000 7ffc34345000 00000000 [vdso]
 ffffffffff600000 ffffffffff601000 00000090 [vsyscall]
 
-00400000-07000000 r-xp 00000000 00:00 0 
+00400000-07000000 r-xp 00000000 00:00 0
 07000000-07093000 r-xp 06c00000 00:2e 536754                             /path/to/gobench_server_main
 07093000-0722d000 rw-p 06c92000 00:2e 536754                             /path/to/gobench_server_main
-0722d000-07b21000 rw-p 00000000 00:00 0 
-c000000000-c000036000 rw-p 00000000 00:00 0 
+0722d000-07b21000 rw-p 00000000 00:00 0
+c000000000-c000036000 rw-p 00000000 00:00 0
 ->
 07000000 07093000 06c00000 /path/to/gobench_server_main
 `
@@ -301,7 +301,7 @@ func TestProcSelfMaps(t *testing.T) {
        })
 }
 
-// TestMapping checkes the mapping section of CPU profiles
+// TestMapping checks the mapping section of CPU profiles
 // has the HasFunctions field set correctly. If all PCs included
 // in the samples are successfully symbolized, the corresponding
 // mapping entry (in this test case, only one entry) should have
index 7850faab0de11dec49dbabbba935bb77a5aef4e4..476b9e88a3297f3a06f652cdfcf280fedb66b87a 100644 (file)
@@ -69,7 +69,7 @@ func main() {
        if err := pprof.StartCPUProfile(os.Stdout); err != nil {
                log.Fatal("can't start CPU profile: ", err)
        }
-       time.Sleep(1 * time.Second)
+       time.Sleep(200 * time.Millisecond)
        pprof.StopCPUProfile()
 
        if err := os.Stdout.Close(); err != nil {
index b9310956197bbde0cbfc75c16f0e61ff11e73d14..f5b4a50697205948022081de7ba20933670c28ef 100644 (file)
@@ -7,11 +7,7 @@
 package runtime_test
 
 import (
-       "internal/testenv"
-       "io/ioutil"
-       "os"
        "os/exec"
-       "path/filepath"
        "syscall"
        "testing"
        "time"
@@ -24,39 +20,14 @@ func TestSpuriousWakeupsNeverHangSemasleep(t *testing.T) {
        if *flagQuick {
                t.Skip("-quick")
        }
-       testenv.MustHaveGoBuild(t)
-       tempDir, err := ioutil.TempDir("", "issue-27250")
-       if err != nil {
-               t.Fatalf("Failed to create the temp directory: %v", err)
-       }
-       defer os.RemoveAll(tempDir)
-
-       repro := `
-    package main
-
-    import "time"
 
-    func main() {
-        <-time.After(1 * time.Second)
-    }
-    `
-       mainPath := filepath.Join(tempDir, "main.go")
-       if err := ioutil.WriteFile(mainPath, []byte(repro), 0644); err != nil {
-               t.Fatalf("Failed to create temp file for repro.go: %v", err)
-       }
-       binaryPath := filepath.Join(tempDir, "binary")
-
-       // Build the binary so that we can send the signal to its PID.
-       out, err := exec.Command(testenv.GoToolPath(t), "build", "-o", binaryPath, mainPath).CombinedOutput()
+       exe, err := buildTestProg(t, "testprog")
        if err != nil {
-               t.Fatalf("Failed to compile the binary: err: %v\nOutput: %s\n", err, out)
-       }
-       if err := os.Chmod(binaryPath, 0755); err != nil {
-               t.Fatalf("Failed to chmod binary: %v", err)
+               t.Fatal(err)
        }
 
-       // Now run the binary.
-       cmd := exec.Command(binaryPath)
+       start := time.Now()
+       cmd := exec.Command(exe, "After1")
        if err := cmd.Start(); err != nil {
                t.Fatalf("Failed to start command: %v", err)
        }
@@ -85,6 +56,9 @@ func TestSpuriousWakeupsNeverHangSemasleep(t *testing.T) {
                        if err != nil {
                                t.Fatalf("The program returned but unfortunately with an error: %v", err)
                        }
+                       if time.Since(start) < 100*time.Millisecond {
+                               t.Fatalf("The program stopped too quickly.")
+                       }
                        return
                }
        }
index ca2be579114a0757193c786218f7b75636ec983d..5f0d1200047e0c34fc6a2cf65bbe351d199f9500 100644 (file)
@@ -112,12 +112,16 @@ func RecursivePanic() {
 }
 
 func GoexitExit() {
+       println("t1")
        go func() {
                time.Sleep(time.Millisecond)
        }()
        i := 0
+       println("t2")
        runtime.SetFinalizer(&i, func(p *int) {})
+       println("t3")
        runtime.GC()
+       println("t4")
        runtime.Goexit()
 }
 
diff --git a/src/runtime/testdata/testprog/sleep.go b/src/runtime/testdata/testprog/sleep.go
new file mode 100644 (file)
index 0000000..86e2f6c
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "time"
+
+// for golang.org/issue/27250
+
+func init() {
+       register("After1", After1)
+}
+
+func After1() {
+       <-time.After(1 * time.Second)
+}
index e289fa5e12a6a14de888983866f844557e641d81..235845df4e217b1d19d384cb18135e4c6b021ed5 100644 (file)
@@ -186,6 +186,10 @@ func TestTraceStress(t *testing.T) {
        if IsEnabled() {
                t.Skip("skipping because -test.trace is set")
        }
+       if testing.Short() {
+               t.Skip("skipping in -short mode")
+       }
+
        var wg sync.WaitGroup
        done := make(chan bool)
 
index 796a5a0a73fafa33f189a7eb4d8fdbf8a4fe8a56..ff1174cc15435aa81db48bce5a1d45f5d08df7f8 100644 (file)
@@ -105,6 +105,9 @@ func testPool(t *testing.T, drain bool) {
        const N = 100
 loop:
        for try := 0; try < 3; try++ {
+               if try == 1 && testing.Short() {
+                       break
+               }
                var fin, fin1 uint32
                for i := 0; i < N; i++ {
                        v := new(string)
index b20ae1d1e3e95faf015b3853d2ea15ef769aaf15..8505a0bb8972d99fc219c26e24bf3278cb20a1ba 100644 (file)
@@ -26,6 +26,9 @@ func TestGetdirentries(t *testing.T) {
        }
 }
 func testGetdirentries(t *testing.T, count int) {
+       if count > 100 && testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
+               t.Skip("skipping in -short mode")
+       }
        d, err := ioutil.TempDir("", "getdirentries-test")
        if err != nil {
                t.Fatalf("Tempdir: %v", err)
index 4246cd1d3ba7fa927f1871350be9f1dd5b714f71..9df6dd46791b85f0e2eb9dd769b008f0717e2785 100644 (file)
@@ -319,7 +319,7 @@ func TestInt64(t *testing.T) {
                }
                return true
        }
-       cfg := &Config{MaxCount: 100000}
+       cfg := &Config{MaxCount: 10000}
        Check(f, cfg)
        if uint64(lo)>>62 == 0 || uint64(hi)>>62 == 0 {
                t.Errorf("int64 returned range %#016x,%#016x; does not look like full range", lo, hi)
index c45df89d59ff61d536ae69f00aea2df76964d0e3..63ccd5c3c001b1f29621e300491c53ea851d5754 100644 (file)
@@ -1417,6 +1417,9 @@ func TestEvalFieldErrors(t *testing.T) {
 }
 
 func TestMaxExecDepth(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping in -short mode")
+       }
        tmpl := Must(New("tmpl").Parse(`{{template "tmpl" .}}`))
        err := tmpl.Execute(ioutil.Discard, nil)
        got := "<nil>"