From e54af069d85877fae4090f19851e689d35dd6190 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 8 Aug 2016 19:21:18 -0400 Subject: [PATCH] Configure common config bits in one place. Right now the logic happens twice which is a nuisance. Change-Id: Ia8155ada0b4479b2ca4be06152b8cd99816e14e8 Reviewed-on: https://boringssl-review.googlesource.com/10440 Reviewed-by: Nick Harper Reviewed-by: David Benjamin Commit-Queue: David Benjamin CQ-Verified: CQ bot account: commit-bot@chromium.org --- ssl/test/runner/runner.go | 63 +++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go index 75b421e1..54e601b8 100644 --- a/ssl/test/runner/runner.go +++ b/ssl/test/runner/runner.go @@ -414,6 +414,32 @@ func (t *timeoutConn) Write(b []byte) (int, error) { } func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool) error { + if !test.noSessionCache { + if config.ClientSessionCache == nil { + config.ClientSessionCache = NewLRUClientSessionCache(1) + } + if config.ServerSessionCache == nil { + config.ServerSessionCache = NewLRUServerSessionCache(1) + } + } + if test.testType == clientTest { + if len(config.Certificates) == 0 { + config.Certificates = []Certificate{rsaCertificate} + } + } else { + // Supply a ServerName to ensure a constant session cache key, + // rather than falling back to net.Conn.RemoteAddr. + if len(config.ServerName) == 0 { + config.ServerName = "test" + } + } + if *fuzzer { + config.Bugs.NullAllCiphers = true + } + if *deterministic { + config.Rand = &deterministicRand{} + } + conn = &timeoutConn{conn, *idleTimeout} if test.protocol == dtls { @@ -854,27 +880,6 @@ func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { go func() { waitChan <- shim.Wait() }() config := test.config - if !test.noSessionCache { - config.ClientSessionCache = NewLRUClientSessionCache(1) - config.ServerSessionCache = NewLRUServerSessionCache(1) - } - if test.testType == clientTest { - if len(config.Certificates) == 0 { - config.Certificates = []Certificate{rsaCertificate} - } - } else { - // Supply a ServerName to ensure a constant session cache key, - // rather than falling back to net.Conn.RemoteAddr. - if len(config.ServerName) == 0 { - config.ServerName = "test" - } - } - if *fuzzer { - config.Bugs.NullAllCiphers = true - } - if *deterministic { - config.Rand = &deterministicRand{} - } conn, err := acceptOrWait(listener, waitChan) if err == nil { @@ -886,25 +891,11 @@ func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { var resumeConfig Config if test.resumeConfig != nil { resumeConfig = *test.resumeConfig - if len(resumeConfig.ServerName) == 0 { - resumeConfig.ServerName = config.ServerName - } - if len(resumeConfig.Certificates) == 0 { - resumeConfig.Certificates = []Certificate{rsaCertificate} - } - if test.newSessionsOnResume { - if !test.noSessionCache { - resumeConfig.ClientSessionCache = NewLRUClientSessionCache(1) - resumeConfig.ServerSessionCache = NewLRUServerSessionCache(1) - } - } else { + if !test.newSessionsOnResume { resumeConfig.SessionTicketKey = config.SessionTicketKey resumeConfig.ClientSessionCache = config.ClientSessionCache resumeConfig.ServerSessionCache = config.ServerSessionCache } - if *fuzzer { - resumeConfig.Bugs.NullAllCiphers = true - } resumeConfig.Rand = config.Rand } else { resumeConfig = config