Split OkHttp tests from other libcore tests

Having one CTSv2 module for most of libcore is
potentially causing flakiness. This commit pulls
out OkHttp tests into a separate module called
CtsLibcoreOkHttpTestCases.

Bug: 29384784
Bug: 29181264
Change-Id: I6fbab91911914ba10c4dd32113e409a0ed4c17e8
diff --git a/tests/libcore/luni/Android.mk b/tests/libcore/luni/Android.mk
index 02caf32..22a975d 100644
--- a/tests/libcore/luni/Android.mk
+++ b/tests/libcore/luni/Android.mk
@@ -20,14 +20,11 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     apache-harmony-tests \
-    bouncycastle-nojarjar \
     conscrypt-tests \
     core-tests \
     cts-core-test-runner \
     jsr166-tests \
     mockito-target \
-    okhttp-nojarjar \
-    okhttp-tests-nojarjar \
     tzdata_update-tests
 
 # Don't include this package in any target
diff --git a/tests/libcore/okhttp/Android.mk b/tests/libcore/okhttp/Android.mk
new file mode 100644
index 0000000..ad78841
--- /dev/null
+++ b/tests/libcore/okhttp/Android.mk
@@ -0,0 +1,53 @@
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := CtsLibcoreOkHttpTestCases
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    bouncycastle-nojarjar \
+    cts-core-test-runner \
+    okhttp-nojarjar \
+    okhttp-tests-nojarjar
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+LOCAL_JACK_FLAGS := --multi-dex native
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+# Include both the 32 and 64 bit versions of libjavacoretests,
+# where applicable.
+LOCAL_MULTILIB := both
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+LOCAL_JAVA_RESOURCE_FILES := \
+    libcore/expectations/brokentests.txt \
+    libcore/expectations/icebox.txt \
+    libcore/expectations/knownfailures.txt \
+    libcore/expectations/taggedtests.txt
+
+LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/okhttp/AndroidManifest.xml b/tests/libcore/okhttp/AndroidManifest.xml
new file mode 100644
index 0000000..d11d0be
--- /dev/null
+++ b/tests/libcore/okhttp/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.libcore.cts.okhttp">
+    <uses-permission android:name="android.permission.INTERNET" />
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="com.android.cts.core.runner.CoreTestRunner"
+                     android:targetPackage="android.libcore.cts.okhttp"
+                     android:label="CTS Libcore OkHttp test cases" />
+
+</manifest>
diff --git a/tests/libcore/okhttp/AndroidTest.xml b/tests/libcore/okhttp/AndroidTest.xml
new file mode 100644
index 0000000..00c390d
--- /dev/null
+++ b/tests/libcore/okhttp/AndroidTest.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Config for CTS Libcore OkHttp test cases">
+    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+        <option name="run-command" value="mkdir -p /data/local/tmp/ctslibcore/java.io.tmpdir" />
+        <option name="run-command" value="mkdir -p /data/local/tmp/ctslibcore/user.home" />
+        <option name="teardown-command" value="rm -rf /data/local/tmp/ctslibcore" />
+    </target_preparer>
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <!-- this has the CoreTestRunner which needs to be in a separate APK -->
+        <option name="test-file-name" value="CtsLibcoreTestRunner.apk" />
+        <!-- this has just the instrumentation which acts as the tests we want to run -->
+        <option name="test-file-name" value="CtsLibcoreOkHttpTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <!-- override AJUR -->
+        <option name="runner" value="com.android.cts.core.runner.CoreTestRunner" />
+        <option name="package" value="android.libcore.cts.okhttp" />
+        <option name="instrumentation-arg" key="core-listener"
+                value="com.android.cts.runner.CtsTestRunListener"/>
+        <option name="instrumentation-arg" key="core-expectations"
+                value="/knownfailures.txt,/brokentests.txt,/icebox.txt,/taggedtests.txt" />
+        <option name="runtime-hint" value="10m"/>
+        <!-- 20x default timeout of 600sec -->
+        <option name="shell-timeout" value="12000000"/>
+    </test>
+</configuration>