Exercise both Conscrypt implementations of SSLSocket.

Re-runs a subset of CtsLibcoreTestCases with the
soon-to-be deprecated file descriptor-based
implementation to ensure it is still tested.

Uses a new instrumentation listener to allow
selection of which implementation to use.

Bug: 148133102
Test: atest CtsLibcoreTestCases

Change-Id: I00e2209e2cf90bbcf5792ad0f81787a4fb795d27
Merged-In: I00e2209e2cf90bbcf5792ad0f81787a4fb795d27
(cherry picked from commit 0cc51f31a5210e83d3af630823faa3da2815a009)
diff --git a/tests/libcore/luni/Android.bp b/tests/libcore/luni/Android.bp
index 91adf0e..6d6903d 100644
--- a/tests/libcore/luni/Android.bp
+++ b/tests/libcore/luni/Android.bp
@@ -18,6 +18,7 @@
     platform_apis: true,
     static_libs: [
         "apache-harmony-tests",
+        "conscrypt-support",
         "conscrypt-tests",
         "core-tests",
         "cts-core-test-runner-axt",
diff --git a/tests/libcore/luni/AndroidTest.xml b/tests/libcore/luni/AndroidTest.xml
index b30e290..e0fc82a 100644
--- a/tests/libcore/luni/AndroidTest.xml
+++ b/tests/libcore/luni/AndroidTest.xml
@@ -41,6 +41,28 @@
         <!-- 20x default timeout of 600sec -->
         <option name="shell-timeout" value="12000000"/>
         <option name="hidden-api-checks" value="false"/>
+        <option name="device-listeners" value="org.conscrypt.ConscryptInstrumentationListener" />
+        <option name="instrumentation-arg" key="conscrypt_sslsocket_implementation" value="engine" />
+    </test>
+    <!-- Re-run a subset of tests using Conscrypt's file-descriptor based implementation to ensure
+         there are no regressions in this implementation before it is fully deprecated.
+
+         Expectations for these tests are the same as above, only timeout and SSLSocket
+         implementation are different.
+    -->
+    <test class="com.android.compatibility.testtype.LibcoreTest" >
+        <option name="package" value="android.libcore.cts" />
+        <option name="include-filter" value="libcore.javax.net.ssl" />
+        <option name="include-filter" value="com.android.org.conscrypt.javax.net.ssl" />
+        <option name="include-filter" value="org.apache.harmony.tests.javax.net.ssl" />
+        <option name="instrumentation-arg" key="filter"
+                value="com.android.cts.core.runner.ExpectationBasedFilter" />
+        <option name="core-expectation" value="/knownfailures.txt" />
+        <option name="virtual-device-core-expectation" value="/virtualdeviceknownfailures.txt" />
+        <option name="runtime-hint" value="5m"/>
+        <option name="hidden-api-checks" value="false"/>
+        <option name="device-listeners" value="org.conscrypt.ConscryptInstrumentationListener" />
+        <option name="instrumentation-arg" key="conscrypt_sslsocket_implementation" value="fd" />
     </test>
 
     <object type="module_controller" class="com.android.tradefed.testtype.suite.module.TestFailureModuleController">