summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Klyubin <klyubin@google.com>2014-04-21 11:36:23 -0700
committerBill Yi <byi@google.com>2014-06-17 14:19:45 -0700
commite502d40a6de7c7115827c7f4caace09032d01cca (patch)
tree0ec04c98f6ff0b8c02bd6a96b6fc9bc6b1eaad4d
parent3a90060f21ce8a31b30c28de9f25d98f92b1d0ee (diff)
downloadcts-e502d40a6de7c7115827c7f4caace09032d01cca.tar.gz
Fix a concurrency bug in OpenSSLHeartbleedTest.
The test was not guaranteed to observe all of the data transmitted by the client in the scenarios where the client failed. As a result, the test was occasionally failing (instead of passing) when the client terminated the TLS/SSL handshake with the fatal alert unexpected_message. This CL fixes the test by ensuring that the test observes all of the data exchanged between the client and the server. Bug: 13906893 (cherry picked from commit 352696d5699051ac2f92af8b0a1156ade0fc59a6) Change-Id: I5091ae7f5e12bdb6fe76a9f0f44618e0e55042c5
-rw-r--r--tests/tests/security/src/android/security/cts/OpenSSLHeartbleedTest.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/tests/security/src/android/security/cts/OpenSSLHeartbleedTest.java b/tests/tests/security/src/android/security/cts/OpenSSLHeartbleedTest.java
index 86957a81683..3aa02684e7e 100644
--- a/tests/tests/security/src/android/security/cts/OpenSSLHeartbleedTest.java
+++ b/tests/tests/security/src/android/security/cts/OpenSSLHeartbleedTest.java
@@ -215,10 +215,23 @@ public class OpenSSLHeartbleedTest extends InstrumentationTestCase {
}
});
+ // Wait for both client and server to terminate, to ensure that we observe all the traffic
+ // exchanged between them. Throw an exception if one of them failed.
Log.i(TAG, "Waiting for client");
- clientFuture.get(10, TimeUnit.SECONDS);
+ // Wait for the client, but don't yet throw an exception if it failed.
+ Exception clientException = null;
+ try {
+ clientFuture.get(10, TimeUnit.SECONDS);
+ } catch (Exception e) {
+ clientException = e;
+ }
Log.i(TAG, "Waiting for server");
- serverFuture.get(1, TimeUnit.SECONDS);
+ // Wait for the server and throw an exception if it failed.
+ serverFuture.get(5, TimeUnit.SECONDS);
+ // Throw an exception if the client failed.
+ if (clientException != null) {
+ throw clientException;
+ }
Log.i(TAG, "Handshake completed and application data exchanged");
}