diff options
Diffstat (limited to 'libgo/go/crypto/tls/handshake_test.go')
-rw-r--r-- | libgo/go/crypto/tls/handshake_test.go | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/libgo/go/crypto/tls/handshake_test.go b/libgo/go/crypto/tls/handshake_test.go index cfd9290..f55cd16 100644 --- a/libgo/go/crypto/tls/handshake_test.go +++ b/libgo/go/crypto/tls/handshake_test.go @@ -17,6 +17,7 @@ import ( "net" "os" "os/exec" + "runtime" "strconv" "strings" "sync" @@ -36,17 +37,31 @@ import ( // implementation. // // Tests can be updated by running them with the -update flag. This will cause -// the test files to be regenerated. Generally one should combine the -update -// flag with -test.run to updated a specific test. Since the reference -// implementation will always generate fresh random numbers, large parts of -// the reference connection will always change. +// the test files for failing tests to be regenerated. Since the reference +// implementation will always generate fresh random numbers, large parts of the +// reference connection will always change. var ( - update = flag.Bool("update", false, "update golden files on disk") + update = flag.Bool("update", false, "update golden files on failure") fast = flag.Bool("fast", false, "impose a quick, possibly flaky timeout on recorded tests") keyFile = flag.String("keylog", "", "destination file for KeyLogWriter") ) +func runTestAndUpdateIfNeeded(t *testing.T, name string, run func(t *testing.T, update bool), wait bool) { + success := t.Run(name, func(t *testing.T) { + if !*update && !wait { + t.Parallel() + } + run(t, false) + }) + + if !success && *update { + t.Run(name+"#update", func(t *testing.T) { + run(t, true) + }) + } +} + // checkOpenSSLVersion ensures that the version of OpenSSL looks reasonable // before updating the test data. func checkOpenSSLVersion() error { @@ -71,7 +86,7 @@ func checkOpenSSLVersion() error { println("to update the test data.") println("") println("Configure it with:") - println("./Configure enable-weak-ssl-ciphers enable-ssl3 enable-ssl3-method") + println("./Configure enable-weak-ssl-ciphers") println("and then add the apps/ directory at the front of your PATH.") println("***********************************************") @@ -243,19 +258,29 @@ func localServer(l net.Listener) { } } +var isConnRefused = func(err error) bool { return false } + func localPipe(t testing.TB) (net.Conn, net.Conn) { localListener.mu.Lock() defer localListener.mu.Unlock() addr := localListener.addr + var err error Dialing: // We expect a rare mismatch, but probably not 5 in a row. for i := 0; i < 5; i++ { tooSlow := time.NewTimer(1 * time.Second) defer tooSlow.Stop() - c1, err := net.Dial(addr.Network(), addr.String()) + var c1 net.Conn + c1, err = net.Dial(addr.Network(), addr.String()) if err != nil { + if runtime.GOOS == "dragonfly" && (isConnRefused(err) || os.IsTimeout(err)) { + // golang.org/issue/29583: Dragonfly sometimes returns a spurious + // ECONNREFUSED or ETIMEDOUT. + <-tooSlow.C + continue + } t.Fatalf("localPipe: %v", err) } if localFlakes == 2 && i == 0 { @@ -279,7 +304,7 @@ Dialing: } } - t.Fatalf("localPipe: failed to connect") + t.Fatalf("localPipe: failed to connect: %v", err) panic("unreachable") } @@ -345,8 +370,6 @@ func runMain(m *testing.M) int { Rand: zeroSource{}, Certificates: make([]Certificate, 2), InsecureSkipVerify: true, - MinVersion: VersionSSL30, - MaxVersion: VersionTLS13, CipherSuites: allCipherSuites(), } testConfig.Certificates[0].Certificate = [][]byte{testRSACertificate} |