From 6a47ac8d13a8a382686dc5ba1cadc64afccf10d0 Mon Sep 17 00:00:00 2001 From: "agl@chromium.org" Date: Fri, 8 Oct 2010 14:39:30 +0000 Subject: net: remove test flakyness caused by uncorking. r61546 (reverted r61546, landed r61638, reverted r61672; it was blameless for the first revert.) caused flakyness in the SSLClientSocket tests because the SSL_CONNECT event may be hidden by a SOCKET_SENT event in the case that the test takes over 200ms to run. This patch changes the test to match against either event. http://codereview.chromium.org/3531019 BUG=none TEST=net_unittests git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61956 0039d316-1c4b-4281-b951-d872f2087c98 --- net/socket/ssl_client_socket_unittest.cc | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'net/socket/ssl_client_socket_unittest.cc') diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc index e545388..24fbb87 100644 --- a/net/socket/ssl_client_socket_unittest.cc +++ b/net/socket/ssl_client_socket_unittest.cc @@ -35,6 +35,19 @@ class SSLClientSocketTest : public PlatformTest { //----------------------------------------------------------------------------- +// LogContainsSSLConnectEndEvent returns true if the given index in the given +// log is an SSL connect end event. The NSS sockets will cork in an attempt to +// merge the first application data record with the Finished message when false +// starting. However, in order to avoid the server timing out the handshake, +// they'll give up waiting for application data and send the Finished after a +// timeout. This means that an SSL connect end event may appear as a socket +// write. +static bool LogContainsSSLConnectEndEvent( + const net::CapturingNetLog::EntryList& log, int i) { + return net::LogContainsEndEvent(log, -1, net::NetLog::TYPE_SSL_CONNECT) || + net::LogContainsEndEvent(log, -1, net::NetLog::TYPE_SOCKET_BYTES_SENT); +}; + TEST_F(SSLClientSocketTest, Connect) { net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); ASSERT_TRUE(test_server.Start()); @@ -71,8 +84,7 @@ TEST_F(SSLClientSocketTest, Connect) { } EXPECT_TRUE(sock->IsConnected()); - EXPECT_TRUE(net::LogContainsEndEvent( - log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT)); + EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); sock->Disconnect(); EXPECT_FALSE(sock->IsConnected()); @@ -117,9 +129,7 @@ TEST_F(SSLClientSocketTest, ConnectExpired) { // We cannot test sock->IsConnected(), as the NSS implementation disconnects // the socket when it encounters an error, whereas other implementations // leave it connected. - - EXPECT_TRUE(net::LogContainsEndEvent( - log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT)); + EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); } TEST_F(SSLClientSocketTest, ConnectMismatched) { @@ -162,9 +172,7 @@ TEST_F(SSLClientSocketTest, ConnectMismatched) { // We cannot test sock->IsConnected(), as the NSS implementation disconnects // the socket when it encounters an error, whereas other implementations // leave it connected. - - EXPECT_TRUE(net::LogContainsEndEvent( - log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT)); + EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); } // Attempt to connect to a page which requests a client certificate. It should @@ -208,9 +216,7 @@ TEST_F(SSLClientSocketTest, FLAKY_ConnectClientAuthCertRequested) { // We cannot test sock->IsConnected(), as the NSS implementation disconnects // the socket when it encounters an error, whereas other implementations // leave it connected. - - EXPECT_TRUE(net::LogContainsEndEvent( - log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT)); + EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); } // Connect to a server requesting optional client authentication. Send it a @@ -260,8 +266,7 @@ TEST_F(SSLClientSocketTest, ConnectClientAuthSendNullCert) { } EXPECT_TRUE(sock->IsConnected()); - EXPECT_TRUE(net::LogContainsEndEvent( - log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT)); + EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); sock->Disconnect(); EXPECT_FALSE(sock->IsConnected()); -- cgit v1.1